2 require 'rake/testtask'
3 require 'rake/gempackagetask'
5 desc "Remove build products"
7 rm Dir.glob( "lib/**/*.jar" )
8 rm Dir.glob( "lib/**/*.#{ Config::CONFIG['DLEXT'] }" )
9 rm Dir.glob( "ext/**/Makefile" )
10 rm Dir.glob( "ext/**/*.{o,#{ Config::CONFIG['DLEXT'] }}" )
11 rm Dir.glob( "java/**/*.{class,jar}" )
12 rm Dir.glob( "java/concurrent/FuturesService.java" )
15 def setup_extension( dir, lib_dir, extension )
16 ext = File.join( "ext", dir )
17 so_name = "#{ extension }.#{ Config::CONFIG['DLEXT'] }"
18 ext_so = File.join( ext, so_name )
19 lib_so = File.join( "lib", lib_dir, so_name )
20 ext_files = FileList[ File.join( ext, "*.{c,h}" ) ]
21 ext_makefile = File.join( ext, "Makefile" )
22 extconf_rb = File.join( ext, "extconf.rb" )
24 file ext_makefile => [ extconf_rb ] do
30 file ext_so => ext_files + [ ext_makefile ] do
41 file lib_so => [ ext_so ] do
45 task :compile => [ lib_so ]
50 file 'java/concurrent/FuturesService.java' => [ 'java/concurrent/FuturesService.java.rb' ] do
51 sh File.join( ENV['JRUBY_HOME'], 'bin/jruby' ), 'java/concurrent/FuturesService.java.rb', 'java/concurrent/FuturesService.java'
53 file 'lib/concurrent/futures.jar' => [ 'java/concurrent/FuturesService.java' ] do
54 Dir.chdir( 'java' ) do
55 sh 'javac', '-classpath', File.join( ENV['JRUBY_HOME'], 'lib/jruby.jar' ), 'concurrent/FuturesService.java'
56 sh 'jar', 'cf', 'concurrent/futures.jar', *Dir.glob( 'concurrent/**/*.class' )
58 cp 'java/concurrent/futures.jar', 'lib/concurrent/futures.jar'
60 task :compile => [ "lib/concurrent/futures.jar" ]
62 setup_extension( 'concurrent/futures', 'concurrent', 'futures' )
65 desc "Compile extensions"
68 task :test => [ :compile ]
69 Rake::TestTask.new do |task|
72 task.test_files = [ "test/test_all.rb" ]
76 gemspec = Gem::Specification.new do |gemspec|
77 gemspec.name = "concurrent"
78 gemspec.version = "0.1"
79 gemspec.author = "MenTaLguY <mental@rydia.net>"
80 gemspec.summary = "Omnibus concurrency library for Ruby"
81 gemspec.test_file = 'test/test_all.rb'
82 gemspec.files = FileList[ 'Rakefile', 'test/*.rb', 'ext/**/*.{c,h,rb}',
83 'java/**/*.{java,rb}',
84 "lib/**/*.{rb,jar,#{ Config::CONFIG['DLEXT'] }}" ]
85 gemspec.require_paths = [ 'lib' ]
86 gemspec.add_dependency 'scheduler', '>= 0.1'
90 gemspec.platform = 'jruby'
92 gemspec.platform = Gem::Platform::WIN32
94 gemspec.platform = Gem::Platform::RUBY
95 gemspec.extensions = FileList[ 'ext/**/extconf.rb' ]
99 task :package => [ :clean, :test ]
100 Rake::GemPackageTask.new( gemspec ) do |task|
101 task.gem_spec = gemspec
105 task :default => [ :clean, :test ]