www.digitalmars.com         C & C++   DMDScript  

D - (Ann): Dependency walker for D source files

reply "Lars Ivar Igesund" <larsivi stud.ntnu.no> writes:
Hi!

I've made a dependency walker for D source files. Given an input
file, it searches through it and the imported modules to find all
d files that the input file depend on. (Source is attached, compile
with "dmd depsrc.d", only deps are to platform independent parts
of phobos. Therefore it should work on both win32 and linux, but
only win32 has been tested.)

If an imported module imports other modules privately, these aren't
searched.
If the imported module is part of phobos, it is ignored.
The output consists of the base file that is checked, all the modules
it depends on, a path where this module is found and the depths
where the modules are found. (If a module is imported from a
module that is imported from the base file, the module is said to be
found on depth 2.)

By default, the found dependencies are printed to the console. Use
-w/--writetofile to have them written to the file "depfile". (This don't
work due to recently reported phobos bug.).
There are no known bugs :)
The source code is free in all ways (except that it is copyrighted.)

The dependencies should be easy to automatically process. Given
the command
depsrc -Isomepath foo.d bar.d, the output will be something like:

# foo.d ## moduledep1 pathtomoduledep1 1,2 moduledep2 pathtomoduledep2 3 # bar.d ## moduledep3 pathtomoduledep3 1 ... ... What's the use for this program? It might be a nice diagnostic if you don't have control over which modules have have been imported from where. Also it can be used by build systems to find the dependencies such that it knows when to recompile/relink. If anyone wants to include it in their packages, feel free (dmd, dide, leds, etc.) It would be nice if someone would like to test it on linux. Suggestions, fixes, etc are welcome. Lars Ivar Igesund
Oct 26 2003
parent "Lars Ivar Igesund" <larsivi stud.ntnu.no> writes:
I've now added a switch "-m" or "--make-syntax" that when used
will print out the dependencies in make syntax. It looks like this:

 depsrc -m foo.d

foo.obj : foo.d dep1.d dep2.d dep3.d ... The object suffix is .obj on Windows and .o on linux. One hitch; only one input file is supported when using this switch. Lars Ivar Igesund "Lars Ivar Igesund" <larsivi stud.ntnu.no> wrote in message news:bngc8g$mel$1 digitaldaemon.com...
 Hi!

 I've made a dependency walker for D source files. Given an input
 file, it searches through it and the imported modules to find all
 d files that the input file depend on. (Source is attached, compile
 with "dmd depsrc.d", only deps are to platform independent parts
 of phobos. Therefore it should work on both win32 and linux, but
 only win32 has been tested.)

 If an imported module imports other modules privately, these aren't
 searched.
 If the imported module is part of phobos, it is ignored.
 The output consists of the base file that is checked, all the modules
 it depends on, a path where this module is found and the depths
 where the modules are found. (If a module is imported from a
 module that is imported from the base file, the module is said to be
 found on depth 2.)

 By default, the found dependencies are printed to the console. Use
 -w/--writetofile to have them written to the file "depfile". (This don't
 work due to recently reported phobos bug.).
 There are no known bugs :)
 The source code is free in all ways (except that it is copyrighted.)

 The dependencies should be easy to automatically process. Given
 the command
depsrc -Isomepath foo.d bar.d, the output will be something like:

# foo.d ## moduledep1 pathtomoduledep1 1,2 moduledep2 pathtomoduledep2 3 # bar.d ## moduledep3 pathtomoduledep3 1 ... ... What's the use for this program? It might be a nice diagnostic if you don't have control over which modules have have been imported from where. Also it can be used by build systems to find the dependencies such that it knows when to recompile/relink. If anyone wants to include it in their packages, feel free (dmd, dide,

 etc.)

 It would be nice if someone would like to test it on linux.
 Suggestions, fixes, etc are welcome.

 Lars Ivar Igesund

Oct 27 2003