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' )
63EXTENSION_NAME = 'concurrent_ruby_ext'
74
8- Bundler ::GemHelper . install_tasks
9-
105$:. push File . join ( File . dirname ( __FILE__ ) , 'lib' )
116require 'extension_helper'
127
@@ -23,20 +18,22 @@ Dir.glob('tasks/**/*.rake').each do |rakefile|
2318 safe_load rakefile
2419end
2520
26- desc 'Run benchmarks'
21+ # desc 'Run benchmarks'
2722task :bench do
2823 exec 'ruby -Ilib -Iext examples/bench_atomic.rb'
2924end
3025
3126if defined? ( JRUBY_VERSION )
27+ require 'rake/javaextensiontask'
3228
33- Rake ::JavaExtensionTask . new ( EXTENSION_NAME , GEMSPEC ) do |ext |
29+ Rake ::JavaExtensionTask . new ( EXTENSION_NAME , CORE_GEMSPEC ) do |ext |
3430 ext . ext_dir = 'ext'
3531 end
3632
3733elsif Concurrent . allow_c_extensions?
34+ require 'rake/extensiontask'
3835
39- Rake ::ExtensionTask . new ( EXTENSION_NAME , GEMSPEC ) do |ext |
36+ Rake ::ExtensionTask . new ( EXTENSION_NAME , EXT_GEMSPEC ) do |ext |
4037 ext . ext_dir = "ext/#{ EXTENSION_NAME } "
4138 ext . cross_compile = true
4239 ext . cross_platform = [ 'x86-mingw32' , 'x64-mingw32' ]
@@ -61,7 +58,6 @@ elsif Concurrent.allow_c_extensions?
6158else
6259 task :clean
6360 task :compile
64- task "compile:#{ EXTENSION_NAME } "
6561end
6662
6763Rake ::Task [ :clean ] . enhance do
@@ -71,6 +67,7 @@ Rake::Task[:clean].enhance do
7167 rm_rf 'lib/2.0'
7268 rm_f Dir . glob ( './lib/*.jar' )
7369 rm_f Dir . glob ( './**/*.bundle' )
70+ mkdir_p 'pkg'
7471end
7572
7673begin
8582rescue LoadError
8683 puts 'Error loading Rspec rake tasks, probably building the gem...'
8784end
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