hook_receipt should return self
[concurrent.git] / Rakefile
blob84f83651708a19e4f1d1fc3e81c599e5929ea2cd
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,#{ Config::CONFIG['DLEXT'] }}" )
8   rm Dir.glob( "ext/**/Makefile" )
9   rm Dir.glob( "ext/**/*.{o,#{ Config::CONFIG['DLEXT'] }}" )
10   rm Dir.glob( "java/**/*.{class,jar}" )
11 end
13 def setup_extension( dir, lib_dir, extension )
14   ext = File.join( "ext", dir )
15   so_name = "#{ extension }.#{ Config::CONFIG['DLEXT'] }"
16   ext_so = File.join( ext, so_name )
17   lib_so = File.join( "lib", lib_dir, so_name )
18   ext_files = FileList[ File.join( ext, "*.{c,h}" ) ]
19   ext_makefile = File.join( ext, "Makefile" )
20   extconf_rb = File.join( ext, "extconf.rb" )
21   
22   file ext_makefile => [ extconf_rb ] do
23     Dir.chdir ext do
24       ruby "extconf.rb"
25     end
26   end
28   file ext_so => ext_files + [ ext_makefile ] do
29     Dir.chdir ext do
30       case PLATFORM
31       when /win32/
32         sh 'nmake'
33       else
34         sh 'make'
35       end
36     end
37   end
39   file lib_so => [ ext_so ] do
40     cp ext_so, lib_so
41   end
43   task :compile => [ lib_so ]
44 end
46 case RUBY_PLATFORM
47 when /java/
48   file 'lib/concurrent/futures.jar' => [ 'java/concurrent/FuturesService.java' ] do
49     Dir.chdir( 'java' ) do
50       sh 'javac', '-classpath', "#{ ENV['JRUBY_HOME'] }/lib/jruby.jar", 'concurrent/FuturesService.java'
51       sh 'jar', 'cf', 'concurrent/futures.jar', *Dir.glob( 'concurrent/**/*.class' )
52     end
53     cp 'java/concurrent/futures.jar', 'lib/concurrent/futures.jar'
54   end
55   task :compile => [ "lib/concurrent/futures.jar" ]
56 else
57   setup_extension( 'concurrent/futures', 'concurrent', 'futures' )
58 end
60 desc "Compile extensions"
61 task :compile
63 task :test => [ :compile ]
64 Rake::TestTask.new do |task|
65   task.libs << 'lib'
66   task.libs << 'test'
67   task.test_files = [ "test/test_all.rb" ]
68   task.verbose = true
69 end
71 gemspec = Gem::Specification.new do |gemspec|
72   gemspec.name = "concurrent"
73   gemspec.version = "0.0.1"
74   gemspec.author = "MenTaLguY <mental@rydia.net>"
75   gemspec.summary = "Omnibus concurrency library for Ruby"
76   gemspec.test_file = 'test/test_all.rb'
77   gemspec.files = FileList[ 'Rakefile', 'test/*.rb', 'ext/**/*.{c,h,rb}',
78                             'java/**/*.java',
79                             "lib/**/*.{rb,jar,#{ Config::CONFIG['DLEXT'] }}" ]
80   gemspec.require_paths = [ 'lib' ]
82   case RUBY_PLATFORM
83   when /java/
84     gemspec.platform = 'jruby'
85   when /win32/
86     gemspec.platform = Gem::Platform::WIN32
87   else
88     gemspec.platform = Gem::Platform::RUBY
89     gemspec.extensions = FileList[ 'ext/**/extconf.rb' ]
90   end
91 end
93 task :package => [ :clean, :test ]
94 Rake::GemPackageTask.new( gemspec ) do |task|
95   task.gem_spec = gemspec
96   task.need_tar = true
97 end
99 task :default => [ :clean, :test ]