I have been looking into Rake for build script in our CI system (Projects built with C++). I have been playing about with a simple 'hello world' application to see what rake is capable of doing. All was well until i decided to put the .h files into a include folder and the .cpp files into src folder. Rake was able to find the .cpp files but not the include header files. File structure like this:
src/main.cpp
src/greet.cpp
include/greet.h
rake script was as follows:
require 'rake/clean'
require 'rake/loaders/makefile'
APPLICATION = 'hello.exe'
C_FILES = FileList['src/*.cpp']
HDR_FILES = FileList['include/*.h']
ALL_FILES = [C_FILES] + HDR_FILES
O_FILES = C_FILES.sub(/\.cpp$/, '.o')
file '.depend.mf' do
sh "makedepend -f- -- -- #{ALL_FILES} > .depend.mf"
end
import ".depend.mf"
file APPLICATION => O_FILES do |t|
sh "gcc #{O_FILES} -o #{t.name}"
end
rule ".o" => [".cpp"] do |t|
sh "gcc -c -o #{t.name} #{t.source}"
end
C_FILES.each do |src|
file src.ext(".o") => src
end
CLEAN.include("**/*.o")
CLEAN.include(APPLICATION)
CLEAN.include(".depend.mf")
task :default => APPLICATION
Any help would be much appreciated.