CDSoft / pp

PP - Generic preprocessor (with pandoc in mind) - macros, literate programming, diagrams, scripts...
http://cdelord.fr/pp
GNU General Public License v3.0
252 stars 21 forks source link

Add mode to list all input files for dependency/up-to-date tracking for Make-like build systems #30

Closed trygvis closed 6 years ago

trygvis commented 7 years ago

GCC has a -M option that changes the output to be a Makefile snippet that lists all file dependencies of the source files instead of compiling it. This is useful for generating Makefiles and integration with other tools.

CDSoft commented 7 years ago

Interesting idea. But may be difficult to fully implement. It will be pretty easy to track all the included or imported files. But some dependencies may be used by calling scripts and pp does not parse the scripts it run. pp can also generate files (e.g. with a script) and include them later. Or include the result of a script.

Here is what pp could do:

Other dependencies will be explicitly given by the user.

pp doesn't know the name of the output, it can not exactly generate Makefile syntax. It may only generate the list of dependencies.

I don't know if it's better to generate the output or not with -M. There may be side effects that should not be made twice. One solution would be to use -M to generate the dependencies in a file and the output to stdout at once (dependencies can not be added if no already known dependency is modified).

trygvis commented 7 years ago

In a Makefile you would to a non-required include with -include foo.d, then have a dependency on foo.d that would be generated on the first run by a dependency on foo.c from foo.d.

I think it would make sense for pp to track recursively all files consumed, shells scripts would be nice to track, but I could live without it and specify them by hand in my build system. I also think it makes sense to not execute the build, but just analyze dependencies and output those. That would match how -M is done with GCC.

CDSoft commented 7 years ago

I have implemented the -M option. It tracks files that are imported, included, referenced by the mdate and csv macros. Scripts are not taken into account.

CDSoft commented 6 years ago

I propose to close this issue. Tracking dependencies in external script seems to be very ambiguous (what's the difference between dependancies and standard external tools, what if some "dependencies" need compilation from other sources, ...). So -M only tracks files that are imported, included and referenced in some macros (currently mdate and csv).