"Andrej Mitrovic" <andrej.mitrov...@gmail.com> wrote in message news:mailman.1624.1310612000.14074.digitalmar...@puremagic.com... > Why build a tool anyway? Why not make a build library that we can use > in our build scripts? > > Then we just import the library in our `build.d` script, write the > build script with the help of those library functions, and let the > user run `rdmd build.d`. No need to install any tools, just run rdmd. > > I'm already using this approach for DWinProj., the only issue is that > the build script is a little large (~300 lines), but a lot of its code > could be put into a library (e.g. it has file traversing, parallel > builds, checking if all tools are present, checking if all libraries > are present, converting header files, etc..). > > This would reduce the script to a few dozen lines. And that's probably > what I'll do to make my other projects easier to build.
Yea, I've given that some thought. Heck, I wrote the D-based buildscript for the recent versions of DDMD, so I know D's good for scripts like that :) It's definitely not a bad idea. Ultimately, I think going with a rake/scons-like build-system approach just allows for a little bit more boilerplate to be removed, which is good for something like a buildscript. For example, if done as a library, once you've defined all your targets, you'd have to call some function to actually do the build. As a build system, defining the targets is all you need to do, and the build gets invoked automatically. It's kinda like how dmain() calls the user's main() instead of the work inside dmain() being a library functions that the main() author needs to call. Plus, as a build-system, the "void main(string[] args) {" part can eventually be removed (once sticking normally-module-level things inside a function is mature enough, if it isn't already). That said, making Drake's functionality at least available in library form does sound like a good idea. And the buildscript-wrapping system (for people who want it) can, of course, be built on top of that.