Created
November 14, 2010 00:30
-
-
Save nazgob/675780 to your computer and use it in GitHub Desktop.
simple/sample Rakefile for C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# constants | |
COMPILER = "g++" | |
EXEC = "hello" | |
FLAGS = "-Wall -Wextra" | |
OBJECTS = ['hello.o', 'add.o'] | |
file 'hello' => OBJECTS | |
# tasks | |
desc "Compiling release version" | |
task :release => ["#{EXEC}"] | |
desc "Compiling debug version" | |
task :debug do | |
end | |
desc "Running unit tests" | |
task :test do | |
end | |
desc "Generating docs" | |
task :docs do | |
end | |
desc "Clean stuff" | |
task :clean do | |
files = (Dir["*.o"] + Dir["#{EXEC}"]).uniq | |
rm_f files unless files.empty? | |
end | |
desc "Compiling debug version and running tests" | |
task :default => [:debug, :test] do | |
end | |
# rules | |
rule '.o' => '.cpp' do |target| | |
sh "#{COMPILER} #{FLAGS} -c -o #{target.name} #{target.source}" | |
end | |
rule "#{EXEC}" => '.o' do |target| | |
sh "#{COMPILER} #{FLAGS} #{OBJECTS.join(" ")} -o #{EXEC}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment