implement timeouts for actor receives; add dependency on Scheduler
[concurrent.git] / Rakefile
blob927880ac6d705774eebb97da06a13431b3e43fdf
1 require 'rake'
2 require 'rake/testtask'
3 require 'rake/gempackagetask'
5 desc "Remove build products"
6 task :clean do
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" )
13 end
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" )
23   
24   file ext_makefile => [ extconf_rb ] do
25     Dir.chdir ext do
26       ruby "extconf.rb"
27     end
28   end
30   file ext_so => ext_files + [ ext_makefile ] do
31     Dir.chdir ext do
32       case PLATFORM
33       when /win32/
34         sh 'nmake'
35       else
36         sh 'make'
37       end
38     end
39   end
41   file lib_so => [ ext_so ] do
42     cp ext_so, lib_so
43   end
45   task :compile => [ lib_so ]
46 end
48 case RUBY_PLATFORM
49 when /java/
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'
52   end
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.libs << 'lib'
71   task.libs << 'test'
72   task.test_files = [ "test/test_all.rb" ]
73   task.verbose = true
74 end
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'
88   case RUBY_PLATFORM
89   when /java/
90     gemspec.platform = 'jruby'
91   when /win32/
92     gemspec.platform = Gem::Platform::WIN32
93   else
94     gemspec.platform = Gem::Platform::RUBY
95     gemspec.extensions = FileList[ 'ext/**/extconf.rb' ]
96   end
97 end
99 task :package => [ :clean, :test ]
100 Rake::GemPackageTask.new( gemspec ) do |task|
101   task.gem_spec = gemspec
102   task.need_tar = true
105 task :default => [ :clean, :test ]