11CORE_GEMSPEC = Gem ::Specification . load ( 'concurrent-ruby.gemspec' )
22EXT_GEMSPEC = Gem ::Specification . load ( 'concurrent-ruby-ext.gemspec' )
3- EXTENSION_NAME = 'concurrent_ruby_ext'
3+ GEM_NAME = 'concurrent-ruby'
4+ EXTENSION_NAME = 'extension'
45
56$:. push File . join ( File . dirname ( __FILE__ ) , 'lib' )
67require 'extension_helper'
@@ -18,25 +19,20 @@ Dir.glob('tasks/**/*.rake').each do |rakefile|
1819 safe_load rakefile
1920end
2021
21- #desc 'Run benchmarks'
22- task :bench do
23- exec 'ruby -Ilib -Iext examples/bench_atomic.rb'
24- end
25-
2622if defined? ( JRUBY_VERSION )
2723 require 'rake/javaextensiontask'
2824
29- Rake ::JavaExtensionTask . new ( EXTENSION_NAME , CORE_GEMSPEC ) do |ext |
25+ Rake ::JavaExtensionTask . new ( 'concurrent_ruby_ext' , CORE_GEMSPEC ) do |ext |
3026 ext . ext_dir = 'ext'
3127 end
3228
3329elsif Concurrent . allow_c_extensions?
3430 require 'rake/extensiontask'
3531
3632 Rake ::ExtensionTask . new ( EXTENSION_NAME , EXT_GEMSPEC ) do |ext |
37- ext . ext_dir = " ext/#{ EXTENSION_NAME } "
38- ext . cross_compile = true
39- ext . cross_platform = [ 'x86-mingw32' , 'x64-mingw32' ]
33+ ext . ext_dir = ' ext/concurrent'
34+ ext . lib_dir = 'lib/concurrent'
35+ ext . source_pattern = '*.{c,h}'
4036 end
4137
4238 ENV [ 'RUBY_CC_VERSION' ] . to_s . split ( ':' ) . each do |ruby_version |
@@ -56,11 +52,10 @@ elsif Concurrent.allow_c_extensions?
5652 end
5753 end
5854else
59- task :clean
6055 task :compile
6156end
6257
63- Rake :: Task [ : clean] . enhance do
58+ task : clean do
6459 rm_rf 'pkg/classes'
6560 rm_rf 'tmp'
6661 rm_rf 'lib/1.9'
@@ -84,29 +79,39 @@ rescue LoadError
8479 puts 'Error loading Rspec rake tasks, probably building the gem...'
8580end
8681
82+ build_deps = [ :clean ]
83+ build_deps << :compile if defined? ( JRUBY_VERSION )
84+
85+ build_tasks = [ 'build:core' ]
86+ build_tasks += [ 'build:ext' , 'build:native' ] if Concurrent . allow_c_extensions?
87+
88+ CoreGem = "#{ GEM_NAME } -#{ Concurrent ::VERSION } .gem"
89+ ExtensionGem = "#{ GEM_NAME } -ext-#{ Concurrent ::VERSION } .gem"
90+ NativeGem = "#{ GEM_NAME } -ext-#{ Concurrent ::VERSION } -#{ Gem ::Platform . new ( RUBY_PLATFORM ) } .gem"
91+
8792namespace :build do
88-
89- build_deps = [ :clean ]
90- build_deps << :compile if defined? ( JRUBY_VERSION )
9193
92- desc ' Build the concurrent-ruby gem'
94+ desc " Build #{ CoreGem } into the pkg directory"
9395 task :core => build_deps do
9496 sh "gem build #{ CORE_GEMSPEC . name } .gemspec"
9597 sh 'mv *.gem pkg/'
96- Rake ::Task [ :clean ] . execute
9798 end
9899
99100 if Concurrent . allow_c_extensions?
100- desc 'Build the concurrent-ruby-ext gem'
101- task :ext => [ :clean , :compile ] do
101+
102+ desc "Build #{ ExtensionGem } .gem into the pkg directory"
103+ task :ext => [ :clean ] do
102104 sh "gem build #{ EXT_GEMSPEC . name } .gemspec"
103105 sh 'mv *.gem pkg/'
104- Rake ::Task [ :clean ] . execute
105106 end
106- else
107- task :ext
107+
108+ desc "Build #{ NativeGem } into the pkg directory"
109+ task :native do
110+ sh "gem compile pkg/#{ ExtensionGem } "
111+ sh 'mv *.gem pkg/'
112+ end
108113 end
109114end
110115
111116desc 'Build all gems for this platform'
112- task :build => [ 'build:core' , 'build:ext' ]
117+ task :build => build_tasks
0 commit comments