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}" )
14 task :clobber => [ :clean ]
16 def setup_extension( dir, lib_dir, extension )
17 ext = File.join( "ext", dir )
18 so_name = "#{ extension }.#{ Config::CONFIG['DLEXT'] }"
19 ext_so = File.join( ext, so_name )
20 lib_so = File.join( "lib", lib_dir, so_name )
21 ext_files = FileList[ File.join( ext, "*.{c,h}" ) ]
22 ext_makefile = File.join( ext, "Makefile" )
23 extconf_rb = File.join( ext, "extconf.rb" )
25 file ext_makefile => [ extconf_rb ] do
31 file ext_so => ext_files + [ ext_makefile ] do
42 file lib_so => [ ext_so ] do
46 task :compile => [ lib_so ]
51 file 'lib/concurrent/futures.jar' => [ 'java/concurrent/FuturesService.java' ] do
52 Dir.chdir( 'java' ) do
53 sh 'javac', '-classpath', File.join( ENV['JRUBY_HOME'], 'lib/jruby.jar' ), 'concurrent/FuturesService.java'
54 sh 'jar', 'cf', 'concurrent/futures.jar', *Dir.glob( 'concurrent/**/*.class' )
56 cp 'java/concurrent/futures.jar', 'lib/concurrent/futures.jar'
58 task :compile => [ "lib/concurrent/futures.jar" ]
60 setup_extension( 'concurrent/futures', 'concurrent', 'futures' )
63 desc "Compile extensions"
66 task :test => [ :compile ]
67 Rake::TestTask.new do |task|
68 task.ruby_opts << '-rrubygems'
71 task.test_files = [ "test/test_all.rb" ]
75 gemspec = Gem::Specification.new do |gemspec|
76 gemspec.name = "concurrent"
77 gemspec.version = "0.1"
78 gemspec.author = "MenTaLguY <mental@rydia.net>"
79 gemspec.summary = "Omnibus concurrency library for Ruby"
80 gemspec.test_file = 'test/test_all.rb'
81 gemspec.files = FileList[ 'Rakefile', 'test/*.rb', 'ext/**/*.{c,h,rb}',
83 "lib/**/*.{rb,jar,#{ Config::CONFIG['DLEXT'] }}" ]
84 gemspec.require_paths = [ 'lib' ]
85 gemspec.add_dependency 'scheduler', '>= 0.1'
89 gemspec.platform = 'jruby'
91 gemspec.platform = Gem::Platform::WIN32
93 gemspec.platform = Gem::Platform::RUBY
94 gemspec.extensions = FileList[ 'ext/**/extconf.rb' ]
98 task :package => [ :clean, :test ]
99 Rake::GemPackageTask.new( gemspec ) do |task|
100 task.gem_spec = gemspec
104 task :default => [ :clean, :test ]