C++ Rakefiles

Sample Rakefile
OUTPUT_DIR     = "/some/dir" COMPILE_OPTIONS = '-g' INCLUDE_DIRS = FileList["somewhere/include"] LINK_OPTIONS   = '' LIBRARY_OPTIONS = "-Lsomewhere -lsomelib" file 'something.o'       => ['something.cpp', 'something.h'] file 'test-something.o'  => ['test-something.cpp'] file 'test-something.exe' => ['test-something.o', 'something.o'] COMMON_OBJECTS = FileList['something.o'] desc 'Build everything.' task :default => [:tests] task :tests  => ['test-something.exe'] INCLUDE_OPTIONS = INCLUDE_DIRS.collect do |i| "-I" + i end rule '.o' => '.cpp' do |target| # rule: object files are made from source files sh "g++ #{INCLUDE_OPTIONS} #{COMPILE_OPTIONS} -c -o #{target.name} #{target.source}" end rule '.exe' => '.o' do |target| sh "g++ -o #{target.name} #{LINK_OPTIONS} #{LIBRARY_OPTIONS} #{target.sources} #{COMMON_OBJECTS}" cp target.name, OUTPUT_DIR end
 * 1) Options
 * 1) Dependencies
 * 1) Tasks
 * 1) Compiling

ctags Support
change: task :default => [..., :ctags] add: task :ctags  => 'tags' CTAGS          = 'c:/bin/ctags' TAG_DIRS       = INCLUDE_DIRS + ['/path/to/gcc/include/dir'] file 'tags' => 'tags.library' do    sh "cp tags.library tags" sh "#{CTAGS} -a tags -R --c++-kinds=+p --fields=+iaS --extra=+q *.cpp" end file 'tags.library' do    sh "#{CTAGS} -f tags.library -R --c++-kinds=+p --fields=+iaS --extra=+q #{TAG_DIRS}" end
 * 1) Tags
 * 1) which dirs should be scanned recursively by ctags apart from the current:

cscope Support
change: task :default => [..., :cscope] add: task :cscope => 'cscope.out' CSCOPE = 'c:/bin/cscope' file 'cscope' do   sh "find -name "*.cpp" -or -name "*.h">cscope.file" sh "#{CSCOPE} -b" end
 * 1) CScope

doxygen support
change: task :default => [..., :doxygen] add: task :doxygen => 'html/index.html' file 'html/index.html' => FileList['*.cpp', '*.h', 'doxygen.cfg'] do    sh "doxygen doxygen.cfg" end
 * 1) doxygen