Skip to content

Commit 3369e46

Browse files
committed
Updated extensions and build tasks based on Heroku testing.
1 parent d3d9ab4 commit 3369e46

13 files changed

+40
-34
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ gemspec name: 'concurrent-ruby'
55
group :development do
66
gem 'rake', '~> 10.3.2'
77
gem 'rake-compiler', '~> 0.9.2'
8+
gem 'gem-compiler', '~> 0.3.0'
89
end
910

1011
group :testing do

Rakefile

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CORE_GEMSPEC = Gem::Specification.load('concurrent-ruby.gemspec')
22
EXT_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')
67
require 'extension_helper'
@@ -18,25 +19,20 @@ Dir.glob('tasks/**/*.rake').each do |rakefile|
1819
safe_load rakefile
1920
end
2021

21-
#desc 'Run benchmarks'
22-
task :bench do
23-
exec 'ruby -Ilib -Iext examples/bench_atomic.rb'
24-
end
25-
2622
if 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

3329
elsif 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
5854
else
59-
task :clean
6055
task :compile
6156
end
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...'
8580
end
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+
8792
namespace :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
109114
end
110115

111116
desc 'Build all gems for this platform'
112-
task :build => ['build:core', 'build:ext']
117+
task :build => build_tasks

concurrent-ruby-ext.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ Gem::Specification.new do |s|
2020

2121
s.files = Dir['ext/**/*.{h,c,cpp}']
2222
s.files += [
23+
'lib/extension_helper.rb',
2324
'lib/concurrent/atomic_reference/concurrent_update_error.rb',
2425
'lib/concurrent/atomic_reference/direct_update.rb',
2526
'lib/concurrent/atomic_reference/numeric_cas_wrapper.rb',
2627
]
2728
s.extra_rdoc_files = Dir['README*', 'LICENSE*', 'CHANGELOG*']
28-
s.require_paths = ['lib']
29-
s.extensions = 'ext/concurrent_ruby_ext/extconf.rb'
29+
s.require_paths = ['lib', 'ext']
30+
s.extensions = 'ext/concurrent/extconf.rb'
3031

3132
s.required_ruby_version = '>= 1.9.3'
3233

ext/concurrent_ruby_ext/extconf.rb renamed to ext/concurrent/extconf.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
require 'fileutils'
22

3-
$:.push File.join(File.dirname(__FILE__), '../../lib')
4-
require 'extension_helper'
3+
require_relative '../../lib/extension_helper'
54

6-
EXTENSION_NAME = 'concurrent_ruby_ext'
5+
EXTENSION_NAME = 'extension'
76

87
def create_dummy_makefile
98
File.open('Makefile', 'w') do |f|
@@ -50,7 +49,7 @@ def compiler_is_gcc
5049
}
5150
CODE
5251

53-
create_makefile(EXTENSION_NAME)
52+
create_makefile('concurrent/' + EXTENSION_NAME)
5453
rescue
5554
create_dummy_makefile
5655
warn 'C optimizations cannot be compiled on this version of Ruby.'

0 commit comments

Comments
 (0)