1
- require 'bundler/gem_tasks'
2
- require 'rake/extensiontask'
3
- require 'rake/javaextensiontask'
4
-
5
- GEMSPEC = Gem ::Specification . load ( 'concurrent-ruby.gemspec' )
1
+ CORE_GEMSPEC = Gem ::Specification . load ( 'concurrent-ruby.gemspec' )
2
+ EXT_GEMSPEC = Gem ::Specification . load ( 'concurrent-ruby-ext.gemspec' )
6
3
EXTENSION_NAME = 'concurrent_ruby_ext'
7
4
8
- Bundler ::GemHelper . install_tasks
9
-
10
5
$:. push File . join ( File . dirname ( __FILE__ ) , 'lib' )
11
6
require 'extension_helper'
12
7
@@ -23,20 +18,22 @@ Dir.glob('tasks/**/*.rake').each do |rakefile|
23
18
safe_load rakefile
24
19
end
25
20
26
- desc 'Run benchmarks'
21
+ # desc 'Run benchmarks'
27
22
task :bench do
28
23
exec 'ruby -Ilib -Iext examples/bench_atomic.rb'
29
24
end
30
25
31
26
if defined? ( JRUBY_VERSION )
27
+ require 'rake/javaextensiontask'
32
28
33
- Rake ::JavaExtensionTask . new ( EXTENSION_NAME , GEMSPEC ) do |ext |
29
+ Rake ::JavaExtensionTask . new ( EXTENSION_NAME , CORE_GEMSPEC ) do |ext |
34
30
ext . ext_dir = 'ext'
35
31
end
36
32
37
33
elsif Concurrent . allow_c_extensions?
34
+ require 'rake/extensiontask'
38
35
39
- Rake ::ExtensionTask . new ( EXTENSION_NAME , GEMSPEC ) do |ext |
36
+ Rake ::ExtensionTask . new ( EXTENSION_NAME , EXT_GEMSPEC ) do |ext |
40
37
ext . ext_dir = "ext/#{ EXTENSION_NAME } "
41
38
ext . cross_compile = true
42
39
ext . cross_platform = [ 'x86-mingw32' , 'x64-mingw32' ]
@@ -61,7 +58,6 @@ elsif Concurrent.allow_c_extensions?
61
58
else
62
59
task :clean
63
60
task :compile
64
- task "compile:#{ EXTENSION_NAME } "
65
61
end
66
62
67
63
Rake ::Task [ :clean ] . enhance do
@@ -71,6 +67,7 @@ Rake::Task[:clean].enhance do
71
67
rm_rf 'lib/2.0'
72
68
rm_f Dir . glob ( './lib/*.jar' )
73
69
rm_f Dir . glob ( './**/*.bundle' )
70
+ mkdir_p 'pkg'
74
71
end
75
72
76
73
begin
85
82
rescue LoadError
86
83
puts 'Error loading Rspec rake tasks, probably building the gem...'
87
84
end
85
+
86
+ namespace :build do
87
+
88
+ build_deps = [ :clean ]
89
+ build_deps << :compile if defined? ( JRUBY_VERSION )
90
+
91
+ desc 'Build the concurrent-ruby gem'
92
+ task :core => build_deps do
93
+ sh "gem build #{ CORE_GEMSPEC . name } .gemspec"
94
+ sh 'mv *.gem pkg/'
95
+ Rake ::Task [ :clean ] . execute
96
+ end
97
+
98
+ if Concurrent . allow_c_extensions?
99
+ desc 'Build the concurrent-ruby-ext gem'
100
+ task :ext => [ :clean , :compile ] do
101
+ sh "gem build #{ EXT_GEMSPEC . name } .gemspec"
102
+ sh 'mv *.gem pkg/'
103
+ Rake ::Task [ :clean ] . execute
104
+ end
105
+ else
106
+ task :ext
107
+ end
108
+ end
109
+
110
+ desc 'Build all gems for this platform'
111
+ task :build => [ 'build:core' , 'build:ext' ]
0 commit comments