1
1
CORE_GEMSPEC = Gem ::Specification . load ( 'concurrent-ruby.gemspec' )
2
2
EXT_GEMSPEC = Gem ::Specification . load ( 'concurrent-ruby-ext.gemspec' )
3
- EXTENSION_NAME = 'concurrent_ruby_ext'
3
+ GEM_NAME = 'concurrent-ruby'
4
+ EXTENSION_NAME = 'extension'
4
5
5
6
$:. push File . join ( File . dirname ( __FILE__ ) , 'lib' )
6
7
require 'extension_helper'
@@ -18,25 +19,20 @@ Dir.glob('tasks/**/*.rake').each do |rakefile|
18
19
safe_load rakefile
19
20
end
20
21
21
- #desc 'Run benchmarks'
22
- task :bench do
23
- exec 'ruby -Ilib -Iext examples/bench_atomic.rb'
24
- end
25
-
26
22
if defined? ( JRUBY_VERSION )
27
23
require 'rake/javaextensiontask'
28
24
29
- Rake ::JavaExtensionTask . new ( EXTENSION_NAME , CORE_GEMSPEC ) do |ext |
25
+ Rake ::JavaExtensionTask . new ( 'concurrent_ruby_ext' , CORE_GEMSPEC ) do |ext |
30
26
ext . ext_dir = 'ext'
31
27
end
32
28
33
29
elsif Concurrent . allow_c_extensions?
34
30
require 'rake/extensiontask'
35
31
36
32
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}'
40
36
end
41
37
42
38
ENV [ 'RUBY_CC_VERSION' ] . to_s . split ( ':' ) . each do |ruby_version |
@@ -56,11 +52,10 @@ elsif Concurrent.allow_c_extensions?
56
52
end
57
53
end
58
54
else
59
- task :clean
60
55
task :compile
61
56
end
62
57
63
- Rake :: Task [ : clean] . enhance do
58
+ task : clean do
64
59
rm_rf 'pkg/classes'
65
60
rm_rf 'tmp'
66
61
rm_rf 'lib/1.9'
@@ -84,29 +79,39 @@ rescue LoadError
84
79
puts 'Error loading Rspec rake tasks, probably building the gem...'
85
80
end
86
81
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
+
87
92
namespace :build do
88
-
89
- build_deps = [ :clean ]
90
- build_deps << :compile if defined? ( JRUBY_VERSION )
91
93
92
- desc ' Build the concurrent-ruby gem'
94
+ desc " Build #{ CoreGem } into the pkg directory"
93
95
task :core => build_deps do
94
96
sh "gem build #{ CORE_GEMSPEC . name } .gemspec"
95
97
sh 'mv *.gem pkg/'
96
- Rake ::Task [ :clean ] . execute
97
98
end
98
99
99
100
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
102
104
sh "gem build #{ EXT_GEMSPEC . name } .gemspec"
103
105
sh 'mv *.gem pkg/'
104
- Rake ::Task [ :clean ] . execute
105
106
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
108
113
end
109
114
end
110
115
111
116
desc 'Build all gems for this platform'
112
- task :build => [ 'build:core' , 'build:ext' ]
117
+ task :build => build_tasks
0 commit comments