fix creation of lazy futures
[concurrent.git] / Rakefile
blob4ad7f926d0f01d6f91ccb84a35f58d3dc28b8c41
1 require 'rake'
2 require 'rake/testtask'
3 require 'rake/gempackagetask'
5 GEM_VERSION = "0.2.2"
7 desc "Remove build products"
8 task :clean do
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}" )
14 end
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" )
26   
27   file ext_makefile => [ extconf_rb ] do
28     Dir.chdir ext do
29       ruby "extconf.rb"
30     end
31   end
33   file ext_so => ext_files + [ ext_makefile ] do
34     Dir.chdir ext do
35       case PLATFORM
36       when /win32/
37         sh 'nmake'
38       else
39         sh 'make'
40       end
41     end
42   end
44   file lib_so => [ ext_so ] do
45     cp ext_so, lib_so
46   end
48   task :compile => [ lib_so ]
49 end
51 case RUBY_PLATFORM
52 when /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' )
57     end
58     cp 'java/concurrent/futures.jar', 'lib/concurrent/futures.jar'
59   end
60   task :compile => [ "lib/concurrent/futures.jar" ]
61 else
62   setup_extension( 'concurrent/futures', 'concurrent', 'futures' )
63 end
65 desc "Compile extensions"
66 task :compile
68 task :test => [ :compile ]
69 Rake::TestTask.new do |task|
70   task.ruby_opts << '-rrubygems'
71   task.libs << 'lib'
72   task.libs << 'test'
73   task.test_files = [ "test/test_all.rb" ]
74   task.verbose = true
75 end
77 gemspec = Gem::Specification.new do |gemspec|
78   gemspec.name = "concurrent"
79   gemspec.version = GEM_VERSION
80   gemspec.author = "MenTaLguY <mental@rydia.net>"
81   gemspec.summary = "Omnibus concurrency library for Ruby"
82   gemspec.test_file = 'test/test_all.rb'
83   gemspec.files = FileList[ 'Rakefile', 'test/*.rb', 'ext/**/*.{c,h,rb}',
84                             'java/**/*.java',
85                             "lib/**/*.{rb,jar,#{ Config::CONFIG['DLEXT'] }}" ]
86   gemspec.require_paths = [ 'lib' ]
87   gemspec.add_dependency 'scheduler', '>= 0.1'
89   case RUBY_PLATFORM
90   when /java/
91     gemspec.platform = 'jruby'
92   when /win32/
93     gemspec.platform = Gem::Platform::WIN32
94   else
95     gemspec.platform = Gem::Platform::RUBY
96     gemspec.extensions = FileList[ 'ext/**/extconf.rb' ]
97   end
98 end
100 task :package => [ :clean, :test ]
101 Rake::GemPackageTask.new( gemspec ) do |task|
102   task.gem_spec = gemspec
103   task.need_tar = true
106 task :default => [ :clean, :test ]