2006-01-28 14:03:53 -05:00
|
|
|
def make(makedir)
|
2006-05-23 00:09:35 -04:00
|
|
|
Dir.chdir(makedir) do
|
|
|
|
sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
|
|
|
|
end
|
2006-01-28 14:03:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def extconf(dir)
|
2006-05-23 00:09:35 -04:00
|
|
|
Dir.chdir(dir) do ruby "extconf.rb" end
|
2006-01-28 14:03:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def setup_tests
|
2006-05-23 00:09:35 -04:00
|
|
|
Rake::TestTask.new do |t|
|
|
|
|
t.libs << "test"
|
|
|
|
t.test_files = FileList['test/test*.rb']
|
|
|
|
t.verbose = true
|
|
|
|
end
|
2006-01-28 14:03:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def setup_clean otherfiles
|
2006-05-23 00:09:35 -04:00
|
|
|
files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
|
|
|
|
CLEAN.include(files)
|
2006-01-28 14:03:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def setup_rdoc files
|
2006-05-23 00:09:35 -04:00
|
|
|
Rake::RDocTask.new do |rdoc|
|
|
|
|
rdoc.rdoc_dir = 'doc/rdoc'
|
|
|
|
rdoc.options << '--line-numbers'
|
|
|
|
rdoc.rdoc_files.add(files)
|
|
|
|
end
|
2006-01-28 14:03:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def setup_extension(dir, extension)
|
2006-05-23 00:09:35 -04:00
|
|
|
ext = "ext/#{dir}"
|
|
|
|
ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
|
|
|
|
ext_files = FileList[
|
2006-01-28 14:03:53 -05:00
|
|
|
"#{ext}/*.c",
|
|
|
|
"#{ext}/*.h",
|
|
|
|
"#{ext}/extconf.rb",
|
|
|
|
"#{ext}/Makefile",
|
|
|
|
"lib"
|
2006-05-23 00:09:35 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
task "lib" do
|
|
|
|
directory "lib"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Builds just the #{extension} extension"
|
|
|
|
task extension.to_sym => ["#{ext}/Makefile", ext_so ]
|
|
|
|
|
|
|
|
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
|
|
|
extconf "#{ext}"
|
|
|
|
end
|
|
|
|
|
|
|
|
file ext_so => ext_files do
|
|
|
|
make "#{ext}"
|
|
|
|
cp ext_so, "lib"
|
|
|
|
end
|
2006-01-28 14:03:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2006-03-10 01:46:45 -05:00
|
|
|
def base_gem_spec(pkg_name, pkg_version)
|
2006-08-05 14:05:47 -04:00
|
|
|
rm_rf "test/coverage"
|
2006-02-11 22:37:38 -05:00
|
|
|
pkg_version = pkg_version
|
|
|
|
pkg_name = pkg_name
|
|
|
|
pkg_file_name = "#{pkg_name}-#{pkg_version}"
|
2006-02-15 18:17:23 -05:00
|
|
|
Gem::Specification.new do |s|
|
2006-02-11 22:37:38 -05:00
|
|
|
s.name = pkg_name
|
|
|
|
s.version = pkg_version
|
|
|
|
s.platform = Gem::Platform::RUBY
|
|
|
|
s.has_rdoc = true
|
|
|
|
s.extra_rdoc_files = [ "README" ]
|
2006-05-23 00:09:35 -04:00
|
|
|
|
2006-03-10 01:46:45 -05:00
|
|
|
s.files = %w(COPYING LICENSE README Rakefile) +
|
2006-08-05 14:05:47 -04:00
|
|
|
Dir.glob("{bin,doc/rdoc,test}/**/*") +
|
|
|
|
Dir.glob("ext/**/*.{h,c,rb,rl}") +
|
|
|
|
Dir.glob("{examples,tools,lib}/**/*.rb")
|
2006-05-23 00:09:35 -04:00
|
|
|
|
2006-02-11 22:37:38 -05:00
|
|
|
s.require_path = "lib"
|
|
|
|
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
|
|
|
s.bindir = "bin"
|
|
|
|
end
|
2006-02-15 18:17:23 -05:00
|
|
|
end
|
|
|
|
|
2006-03-10 01:46:45 -05:00
|
|
|
def setup_gem(pkg_name, pkg_version)
|
|
|
|
spec = base_gem_spec(pkg_name, pkg_version)
|
2006-02-15 18:17:23 -05:00
|
|
|
yield spec if block_given?
|
2006-05-23 00:09:35 -04:00
|
|
|
|
2006-02-11 22:37:38 -05:00
|
|
|
Rake::GemPackageTask.new(spec) do |p|
|
|
|
|
p.gem_spec = spec
|
2006-06-01 23:02:06 -04:00
|
|
|
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
2006-02-11 22:37:38 -05:00
|
|
|
end
|
2006-01-28 14:03:53 -05:00
|
|
|
end
|
2006-02-15 18:17:23 -05:00
|
|
|
|
2006-03-12 14:40:35 -05:00
|
|
|
def sub_project(project, *targets)
|
|
|
|
targets.each do |target|
|
2006-06-16 17:01:12 -04:00
|
|
|
Dir.chdir "projects/#{project}" do
|
|
|
|
sh %{rake --trace #{target.to_s} }
|
|
|
|
end
|
2006-03-12 14:40:35 -05:00
|
|
|
end
|
2006-03-11 11:35:53 -05:00
|
|
|
end
|
2006-05-19 22:56:30 -04:00
|
|
|
|
2006-06-01 16:41:34 -04:00
|
|
|
# Conditional require rcov/rcovtask if present
|
|
|
|
begin
|
|
|
|
require 'rcov/rcovtask'
|
|
|
|
|
|
|
|
Rcov::RcovTask.new do |t|
|
|
|
|
t.test_files = FileList['test/test*.rb']
|
|
|
|
t.rcov_opts << "-x /usr"
|
|
|
|
t.output_dir = "test/coverage"
|
|
|
|
end
|
2006-06-10 03:02:19 -04:00
|
|
|
rescue Object
|
2006-05-19 22:56:30 -04:00
|
|
|
end
|