Created
July 14, 2009 14:35
-
-
Save mrkn/146975 to your computer and use it in GitHub Desktop.
This file contains 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
require 'rake/clean' | |
require 'rake/testtask' | |
STAGE_DIR = '.stage' | |
CLEAN.include '*.o' | |
CLEAN.include '*.so' | |
CLEAN.include STAGE_DIR | |
EXTCONF_LIST = FileList['ext/**/extconf.rb'].map{|x| x.sub(%r!^ext/!, '') } | |
desc "build all extension libraries" | |
task :build_extensions do |t| | |
EXTCONF_LIST.each do |extconf| | |
dir = File.dirname(extconf) | |
Dir.chdir(File.join('ext', dir)) do | |
system 'ruby extconf.rb' | |
system 'make' | |
end | |
end | |
end | |
desc "stage all extension libraries" | |
task :stage_extensions => [ :build_extensions ] do |t| | |
EXTCONF_LIST.each do |extconf| | |
libname = File.basename(File.dirname(extconf)) | |
libpath = File.join(File.dirname(extconf), libname + '.so') | |
stage_extension(libpath) | |
end | |
end | |
def stage_extension(libpath, stage_dir=STAGE_DIR) | |
target_dir = File.join(stage_dir, File.dirname(libpath)) | |
FileUtils.mkdir_p target_dir | |
FileUtils.cp File.join('ext', libpath), target_dir | |
end | |
task :test => [ :stage_extensions ] | |
Rake::TestTask.new :test do |t| | |
t.libs += ['test', STAGE_DIR] | |
t.test_files = FileList['test/test*.rb'] | |
t.verbose = true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment