|Posted by Travis||PermalinkReply|
DMD currently follows a fairly standard compiler methodology:
- Compile a bunch of source files into binary objects (to generate .o).
- Act as a front end to an archiver (to generate .a).
- Act as a front end to a linker (to generate final binary).
This makes integration with most build systems and IDEs not only possible, but in most cases reasonably trivial.
The one thing I have been wondering however is why doesn't DMD have a flag for easy project building which compiles dependencies in a single command.
DMD already can generate a recursive list of module dependencies (-deps=), why not go one step towards a full build system and have it build those dependencies (and check timestamps). This could create behaviours similar to that of simple dsss/rebuild/bud/xfBuild configuration but keep up to date with the DMD syntax.
The behaviour I am thinking/suggesting for the '-R' flag (recursive) is:
- Generate dependency tree of each .d file provided on the command line
- If -o- is provided on the command line, treat each dependant .d file in the
dependency tree as if it was provided on the command line.
- If -o- is not provided on the command line only compile the .d files that are
newer than the .o files.
- Link/Archive the resulting .o files.
Adding in pragma('link', 'foo') would also be really nice to add in as well for this sort of system. Even better would be some way of passing command line arguments to dmd via a pragma such as pragma('cmd', '-Jfoo') which would add a string imports path relative to the file being compiled.
I think this sort of feature would allow alot of newcomers to D to get writing modular code faster without learning build systems and all of the crap associated cross platform issues.
I don't know the dmd internals well enough to implement it myself, but I'd love to hear Walter's or Andrei's input on a feature like this. From what I do know about dmd's current functionality, it seems like it would be a fairly easy feature to implement.