fix Promise#fulfilled?
[concurrent.git] / Rakefile
blob11e0f4407efb987f45f1420fad4b2ab469576b77
1 require 'rake'
2 require 'rake/testtask'
3 require 'rake/gempackagetask'
5 GEM_VERSION = "0.5"
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   setup_extension( 'concurrent/primitives', 'concurrent', 'primitives' )
64 end
66 desc "Compile extensions"
67 task :compile
69 task :test => [ :compile ]
70 Rake::TestTask.new do |task|
71   task.ruby_opts << '-rrubygems'
72   task.libs << 'lib'
73   task.libs << 'test'
74   task.test_files = [ "test/test_all.rb" ]
75   task.verbose = true
76 end
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}',
85                             'java/**/*.java',
86                             "lib/**/*.{rb,jar,#{ Config::CONFIG['DLEXT'] }}" ]
87   gemspec.require_paths = [ 'lib' ]
88   gemspec.add_dependency 'scheduler', '>= 0.1'
90   case RUBY_PLATFORM
91   when /java/
92     gemspec.platform = 'jruby'
93   when /win32/
94     gemspec.platform = Gem::Platform::WIN32
95   else
96     gemspec.platform = Gem::Platform::RUBY
97     gemspec.extensions = FileList[ 'ext/**/extconf.rb' ]
98   end
99 end
101 task :package => [ :clean, :test ]
102 Rake::GemPackageTask.new( gemspec ) do |task|
103   task.gem_spec = gemspec
104   task.need_tar = true
107 task :default => [ :clean, :test ]