2 require 'rake/testtask'
3 require 'rake/gempackagetask'
7 desc "Remove build products"
9 rm Dir.glob( "lib/**/*.jar" )
10 rm Dir.glob( "lib/**/*.#{ Config::CONFIG['DLEXT'] }" )
11 rm Dir.glob( "ext/**/Makefile" )
12 rm Dir.glob( "ext/**/*.{o,#{ Config::CONFIG['DLEXT'] }}" )
13 rm Dir.glob( "java/**/*.{class,jar}" )
16 task :clobber => [ :clean ]
18 def setup_extension( dir, lib_dir, extension )
19 ext = File.join( "ext", dir )
20 so_name = "#{ extension }.#{ Config::CONFIG['DLEXT'] }"
21 ext_so = File.join( ext, so_name )
22 lib_so = File.join( "lib", lib_dir, so_name )
23 ext_files = FileList[ File.join( ext, "*.{c,h}" ) ]
24 ext_makefile = File.join( ext, "Makefile" )
25 extconf_rb = File.join( ext, "extconf.rb" )
27 file ext_makefile => [ extconf_rb ] do
33 file ext_so => ext_files + [ ext_makefile ] do
44 file lib_so => [ ext_so ] do
48 task :compile => [ lib_so ]
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' )
63 setup_extension( 'concurrent/primitives', 'concurrent', 'primitives' )
66 desc "Compile extensions"
69 task :test => [ :compile ]
70 Rake::TestTask.new do |task|
71 task.ruby_opts << '-rrubygems'
74 task.test_files = [ "test/test_all.rb" ]
78 gemspec = Gem::Specification.new do |gemspec|
79 gemspec.name = "concurrent"
80 gemspec.version = GEM_VERSION
81 gemspec.author = "MenTaLguY <mental@rydia.net>"
82 gemspec.summary = "Omnibus concurrency library for Ruby"
83 gemspec.test_file = 'test/test_all.rb'
84 gemspec.files = FileList[ 'Rakefile', 'test/*.rb', 'ext/**/*.{c,h,rb}',
86 "lib/**/*.{rb,jar,#{ Config::CONFIG['DLEXT'] }}" ]
87 gemspec.require_paths = [ 'lib' ]
88 gemspec.add_dependency 'scheduler', '>= 0.1'
92 gemspec.platform = 'jruby'
94 gemspec.platform = Gem::Platform::WIN32
96 gemspec.platform = Gem::Platform::RUBY
97 gemspec.extensions = FileList[ 'ext/**/extconf.rb' ]
101 task :package => [ :clean, :test ]
102 Rake::GemPackageTask.new( gemspec ) do |task|
103 task.gem_spec = gemspec
107 task :default => [ :clean, :test ]