views:

105

answers:

3

I appreciate makefiles and make in all their glory, but I wonder if there isn't a more intuitive way to maintain my c/c++ builds.

Has anyone tried replacing their makefiles with ruby scripts to allow for complex and adaptive builds without sacrificing readability? Are there gems that make this easier?

+4  A: 

Take a look at Rake, a make replacement written in Ruby. It's basically a small domain specific language, geared towards typical make-like tasks, with the possibility of writing normal ruby code in the Rakefile.

calmh
Promising. I'll look into this. Has anyone been on a decent-sized team that compiled their c++ code with rake? (We're building on Windows, too, if that matters).
thebretness
http://Rubini.us/ is a sizeable C++ project (well, actually a Ruby project containing a sizeable chunk of C++) which uses Rake as its build system. http://IronRuby.Net/ also uses Rake; it's not C++ but C#, but probably close enough. Rubinius doesn't work on Windows yet, but that doesn't have anything to do with the build process. And Microsoft IronRuby obviously works on Windows. There's also some embedded and robotics companies that build C++, C and even assembly with Rake.
Jörg W Mittag
After a lot of tinkering, I've constructed a rakefile I'm happy with. Thanks.
thebretness
+3  A: 

This is a very old idea and has been tried with many scripting languages. SRC Modula-3 shipped with a language called "Quake" in which all the m3makefiles for the project were written. The challenge is to provide something approaching the succinctness and transparency of a Makefile while allowing much more expressive power. Rake has a ways to go before it approaches the simplicity and clarity of make or quake, but it is eminently usable. I think some readability is sacrificed relative to a tool like Plan 9's mk, but Rake is far more readable than the more baroque uses of Gnu Make.

Norman Ramsey
+2  A: 

I have converted large, multiple and complex C projects using Rake, and a few small Java ones.

And I will never go back to makefiles! The rakefiles to my eyes are far more readable than either makefiles or ant.

Rake and ruby do have their own set of problems, the main one being decent documentation, and it will still take some learning and experience to craft decent build systems unless you are very handy with Ruby.

Jim