dependency analysis for makefile construction

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 5 11:22:08 PDT 2016


On 09/04/2016 12:07 AM, dan wrote:
> Are there any FOSS tools for doing dependency analysis of (e.g.) all the
> d files in a directory, to let you know when a .o file needs to be
> regenerated?
>
> This presumably would depend mostly on the import statements (including
> import of any file to be used in string construction, as in 'auto
> my_string = import("my_file");').

dmd itself has two related switches:

* -deps prints out imports and such.
* -v prints out the same information in different format, and also a lot 
more other stuff, including which dmd binary is being used and the 
config file.

rdmd uses -v to figure out the dependencies of the root module. Here's 
how it parses the output:
https://github.com/dlang/tools/blob/master/rdmd.d#L643-L691

I'm not aware of a standalone tool that does something like this. If you 
want to write one, you could do like rdmd and use `dmd -deps`/`dmd -v`, 
or you could use a standalone D parser like libdparse.

http://code.dlang.org/packages/libdparse

[...]
> (I'm using gdc, and building with gnumake.)

I'm not sure how similar or different gdc is to dmd with regards to the 
-deps/-v switches. A quick test suggests that gdc has a --deps switch 
that behaves like dmd's -deps. It seems to be undocumented. The output 
of gdc's -v does apparently not include the imports, though.


More information about the Digitalmars-d-learn mailing list