View mode: basic / threaded / horizontal-split · Log in · Help
December 27, 2006
Let the D compiler print the dependencies.
While thinking about build tools and IDE integration, why not let the D
compiler have a switch to print the dependencies?

# dmd t.d -c -deps
depends: std.string

This has the advantage, that if there is a change in the rules how
version/debug/static-if are evaluated, the build tool does not need to
know about them. The build tool can use different compilers and compiler
versions and can ask the compiler for the list of dependencies for a
given module.

-deps
Prints the dependencies, each in one line, starting with "depends: ".
-deps=filename
Prints the dependencies into the given file, each in one line without
additional text.

Does this make sense?
What do you think?

Frank
December 27, 2006
Re: Let the D compiler print the dependencies.
Frank Benoit (keinfarbton) wrote:
> While thinking about build tools and IDE integration, why not let the D
> compiler have a switch to print the dependencies?
> 
> # dmd t.d -c -deps
> depends: std.string
> 
> This has the advantage, that if there is a change in the rules how
> version/debug/static-if are evaluated, the build tool does not need to
> know about them. The build tool can use different compilers and compiler
> versions and can ask the compiler for the list of dependencies for a
> given module.
> 
> -deps
> Prints the dependencies, each in one line, starting with "depends: ".
> -deps=filename
> Prints the dependencies into the given file, each in one line without
> additional text.
> 
> Does this make sense?
> What do you think?

Absolutely!

The compiler should be the only thing that needs to know the 
dependencies, and the other tools should ask it.
December 27, 2006
Re: Let the D compiler print the dependencies.
Frank Benoit (keinfarbton) wrote:

> While thinking about build tools and IDE integration, why not let the D
> compiler have a switch to print the dependencies?
> 
> # dmd t.d -c -deps
> depends: std.string
> 
> This has the advantage, that if there is a change in the rules how
> version/debug/static-if are evaluated, the build tool does not need to
> know about them. The build tool can use different compilers and compiler
> versions and can ask the compiler for the list of dependencies for a
> given module.
> 
> -deps
> Prints the dependencies, each in one line, starting with "depends: ".
> -deps=filename
> Prints the dependencies into the given file, each in one line without
> additional text.
> 
> Does this make sense?
> What do you think?
> 
> Frank

Itsounds like a good idea but I think that printing depend: infront of th e
dependencies could complicate the use of the command. for example if you
want to pipe it to another command. (I also think it should print filnames
and not moduenames, or have two switches)
December 27, 2006
Re: Let the D compiler print the dependencies.
> It sounds like a good idea but I think that printing depend: in front of the
> dependencies could complicate the use of the command. for example if you
> want to pipe it to another command. 

My idea behind that was, that printing the dependencies is independent
from doing compilation or other tasks (ddoc). Prefixing the message,
makes this possible.

The build tool can cache the dependencies from a previous run. First it
calls the compiler with all files from the last run. If it turns out,
that dependencies changed since the last run, it can rerun the compiler
with the new complete set of files. With this, it is possible to compile
most of the time without loading all source two times.
All other messages can be filtered and printed to stdout/stderr.
December 27, 2006
Re: Let the D compiler print the dependencies.
> (I also think it should print filnames
> and not moduenames, or have two switches)

If the file is actually missing, the compiler perhaps does not know the
filename. It can be in a missing search path and it can be a .d or .di
file. So printing the module name will always work.

The build tool can than search in in the project folders or can start a
download of the missing sources, or something like that... then start a
new compile run.
December 27, 2006
Re: Let the D compiler print the dependencies.
Frank Benoit (keinfarbton) wrote:

>> (I also think it should print filnames
>> and not moduenames, or have two switches)
> 
> If the file is actually missing, the compiler perhaps does not know the
> filename. It can be in a missing search path and it can be a .d or .di
> file. So printing the module name will always work.
> 
> The build tool can than search in in the project folders or can start a
> download of the missing sources, or something like that... then start a
> new compile run.

Ok I see the problem with missing files.

The reason I wanted it was to be able to write somthing like this.

# bash code
grep text `dmd -deps file.d`
December 27, 2006
Re: Let the D compiler print the dependencies.
Johan Granberg wrote:
> 
> Ok I see the problem with missing files.
> 
> The reason I wanted it was to be able to write somthing like this.
> 
> # bash code
> grep text `dmd -deps file.d`

The previous message got sent beore it was finnished. here it goes.

I wanted the above comand to search for the text in all modules that file.d
depends on (including file.d but that could be a special case). Things like
this can be usefull when searcing for function signatures when one does not
know in which file they are defined.
December 27, 2006
Re: Let the D compiler print the dependencies.
This should do it:
dmd -deps file.d | grep "depends : " | cut -c 10- | xargs grep text
December 27, 2006
Re: Let the D compiler print the dependencies.
Ah sorry, certainly you need the filename here :)
forget about my previous posting
December 27, 2006
Re: Let the D compiler print the dependencies.
On Wed, 27 Dec 2006 15:32:04 +0100, Frank Benoit (keinfarbton) wrote:

> While thinking about build tools and IDE integration, why not let the D
> compiler have a switch to print the dependencies?

While this is a good idea, you do realize that the Bud tool can already do
this? There is a switch to get it to create a file that contains a list of
all the files is depends on.

-- 
Derek Parnell
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home