From: Joe Van Dyk Date: 2005-07-17T09:28:01+09:00 Subject: Re: rake question On 7/15/05, Stefan Lang wrote: > On Friday 15 July 2005 22:24, Joe Van Dyk wrote: > [...] > > > What I'm trying to do is become a better software developer. So, I've > > > got a couple C and C++ books. I want to do the examples in them. So > > > I'll have directories like > > > / > > > /c/ > > > /c/problem_1_1/ > > > /c/problem_1_2/ > > > /c/problem_1_2/main.c > > > /c/problem_1_2/foo.c > > > /c/problem_1_2/foo.h > > > /c/problem_1_2/test_foo.c > > > /c++/ > > > > > > > > > And so on. I want a Rake file that will go into the directory > > > structure, compile all the code, compile all the test code, and run > > > the tests. Then I want it to create syntax-highlighted webpages that > > > shows for each example the code and the output and the tests, and then > > > posts them to a website where I can get comments on them. > > > > > > Perhaps I'll have separate build directories (so I can build and test > > > the code on Windows, Linux, FreeBSD, and OS X).. > > > > > > So, I'm looking for help for that. > > > > And I haven't looked at Rant much, would it be better for my purposes? > > Rake and Rant are both general purpose build utilities, right? > > Yes, but Rant can automatically determine the dependencies between > C/C++ sources files (by extracting #include statements) and it has > some support for multiple directories (i.e. more than one Rantfile). > > Actually a good example. I came up with the following solution for Rant: > > % ls > c c++ Rantfile rule.rf > % ls c > problem_1_1 template.rf > % ls c++ > problem_1_1 template.rf > > The main Rantfile in the root directory copies the c/template.rf Rantfile > into all c/problem_* directories and the c++/template.rf into all > c++/problem_* directories. > > If you run rant in the root directory, it will compile all tests > and run them. To compile only, run rant with "build" as only argument. > During work on one of the exercises you can change into the c(++)/problem* > directory and run rant to only compile/run the current exercise. > > The example is in the attachment. The only problem is, that the last > Rant release contains a bug with regards to the Rule/subdirectory > combination. If you want, I can send you my development version offlist. Yeah, when I run 'rant', I get: rant: [ERROR] Name error when loading `/home/joe/repos/joe/learning/c_cpp_exercises/c++/problem_1_1/Rantfile': undefined method `sub_ext' for # /usr/lib/ruby/gems/1.8/gems/rant-0.4.0/lib/rant/rantsys.rb:122:in `method_missing' /home/joe/repos/joe/learning/c_cpp_exercises/c++/problem_1_1/Rantfile:13:in `instance_eval' /usr/lib/ruby/gems/1.8/gems/rant-0.4.0/lib/rant/rantlib.rb:1002:in `instance_eval' /usr/lib/ruby/gems/1.8/gems/rant-0.4.0/lib/rant/rantlib.rb:1002:in `load_file' /usr/lib/ruby/gems/1.8/gems/rant-0.4.0/lib/rant/rantlib.rb:686:in `subdirs' And so on. Would that be fixed in the development version?