Rakefile in calc-nik-0.0.4 vs Rakefile in calc-nik-0.0.5
- old
+ new
@@ -17,5 +17,35 @@
desc "Generate code coverage"
RSpec::Core::RakeTask.new(:coverage) do |t|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
end
+
+require 'rake/testtask'
+require 'rake/clean'
+
+NAME = 'calc'
+
+# rule to build the extension: this says
+# that the extension should be rebuilt
+# after any change to the files in ext
+file "lib/#{NAME}/#{NAME}.so" =>
+ Dir.glob("ext/#{NAME}/*{.rb,.c}") do
+ Dir.chdir("ext/#{NAME}") do
+ # this does essentially the same thing
+ # as what RubyGems does
+ ruby "extconf.rb"
+ sh "make"
+ end
+ cp "ext/#{NAME}/#{NAME}.so", "lib/#{NAME}"
+end
+
+# make the :test task depend on the shared
+# object, so it will be built automatically
+# before running the tests
+task :spec => "lib/#{NAME}/#{NAME}.so"
+
+# use 'rake clean' and 'rake clobber' to
+# easily delete generated files
+CLEAN.include('ext/**/*{.o,.log,.so}')
+CLEAN.include('ext/**/Makefile')
+CLOBBER.include('lib/**/*.so')