Dependency management in D

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 18 22:17:31 PDT 2014


On 9/18/2014 9:48 AM, Scott Wilson wrote:
> Im running some tests with D. Was wondering whats the dependency
> story. Cant find any info online, searched for dlang dependency
> management and dlang dependency. Found bunch o dub stuff but not
> the nitty gritty.
>
> Unit of compilation is one D file but I saw if I pass several D
> files to the compiler only one .o file is generated. Whats the
> story there.

The idea is to essentially "pre-link" the object files that would have been 
generated if the files were compiled individually into one object file. This is 
faster and more convenient.

It also means that semantic analysis is done only once for each file, and the 
imports, rather than doing it over and over as is done with separate compilation.


> Plus if I change a non template function in one module then
> theres no way to tell make no rebuild of modules importing it.
> The dmd -deps call seems to generate all recursively. In
> gcc/makedepend if one function changes only relinking is needed
> or nothing if dynamic loading.

Dependency management is the same as in C++, if you are willing to use .di files 
to represent 'headers' of corresponding .d files.


> Overall as far as I understand compiler is fast but dependency
> mgmt is coarse. Also whats the deal with cyclic dependencies. I
> saw discussion that its not possible but wrote a few test modules
> and it works fine.

If two modules import each other, then if one changes, both should get recompiled.



More information about the Digitalmars-d mailing list