Skip to content

Instantly share code, notes, and snippets.

@nazgob
Created November 14, 2010 00:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nazgob/675780 to your computer and use it in GitHub Desktop.
Save nazgob/675780 to your computer and use it in GitHub Desktop.
simple/sample Rakefile for C++
# 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