Skip to content

Commit c736e1a

Browse files
committed
Gems built with new build boxes and tested no several operating systems.
C extensions added back to platform-independent gem. Fixed platform-independent gem build. Platform-independent build now works the way we intend. Fixed package and build problems in Rakefile. Better error messages. Reduced the number of threads in atomic parallel tests.
1 parent 49ffb91 commit c736e1a

File tree

13 files changed

+35
-44
lines changed

13 files changed

+35
-44
lines changed

Rakefile

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
require 'rake'
21
require 'bundler/gem_tasks'
32
require 'rake/extensiontask'
43
require 'rake/javaextensiontask'
54

6-
GEMSPEC = Gem::Specification.load(File.expand_path('../concurrent-ruby.gemspec', __FILE__))
5+
GEMSPEC = Gem::Specification.load('concurrent-ruby.gemspec')
6+
EXTENSION_NAME = 'concurrent_ruby_ext'
7+
8+
Bundler::GemHelper.install_tasks
79

810
$:.push File.join(File.dirname(__FILE__), 'lib')
911
require 'extension_helper'
@@ -13,27 +15,21 @@ Dir.glob('tasks/**/*.rake').each do|rakefile|
1315
load rakefile
1416
end
1517

16-
Bundler::GemHelper.install_tasks
17-
1818
desc 'Run benchmarks'
1919
task :bench do
2020
exec 'ruby -Ilib -Iext examples/bench_atomic.rb'
2121
end
2222

2323
if defined?(JRUBY_VERSION)
2424

25-
EXTENSION_NAME = 'concurrent_jruby'
26-
2725
Rake::JavaExtensionTask.new(EXTENSION_NAME, GEMSPEC) do |ext|
2826
ext.ext_dir = 'ext'
2927
end
3028

3129
elsif Concurrent.use_c_extensions?
3230

33-
EXTENSION_NAME = 'concurrent_cruby'
34-
3531
Rake::ExtensionTask.new(EXTENSION_NAME, GEMSPEC) do |ext|
36-
ext.ext_dir = 'ext'
32+
ext.ext_dir = "ext/#{EXTENSION_NAME}"
3733
ext.cross_compile = true
3834
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
3935
end
@@ -54,6 +50,10 @@ elsif Concurrent.use_c_extensions?
5450
end
5551
end
5652
end
53+
else
54+
task :clean
55+
task :compile
56+
task "compile:#{EXTENSION_NAME}"
5757
end
5858

5959
Rake::Task[:clean].enhance do
@@ -75,11 +75,7 @@ begin
7575
t.rspec_opts = '--tag ~@not_on_travis'
7676
end
7777

78-
if defined?(EXTENSION_NAME)
79-
task :default => [:clean, "compile:#{EXTENSION_NAME}", :travis_spec]
80-
else
81-
task :default => [:clean, :travis_spec]
82-
end
78+
task :default => [:clean, :compile, :travis_spec]
8379
rescue LoadError
8480
puts 'Error loading Rspec rake tasks, probably building the gem...'
8581
end

concurrent-ruby.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ Gem::Specification.new do |s|
2323
s.require_paths = ['lib']
2424

2525
if defined?(JRUBY_VERSION)
26-
s.files = Dir['lib/concurrent_jruby.jar']
26+
s.files += Dir['lib/concurrent_ruby_ext.jar']
2727
s.platform = 'java'
2828
else
29-
s.extensions = 'ext/extconf.rb'
29+
s.extensions = 'ext/concurrent_ruby_ext/extconf.rb'
30+
s.files += Dir['ext/**/*.{h,c,cpp}']
3031
end
3132

3233
s.required_ruby_version = '>= 1.9.3'

examples/bench_atomic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
N = ARGV[1] ? ARGV[1].to_i : 100_000
1111

1212
# number of threads for parallel test
13-
M = ARGV[0] ? ARGV[0].to_i : 100
13+
M = ARGV[0] ? ARGV[0].to_i : 10
1414

1515
# list of platform-specific implementations
1616
ATOMICS = [

ext/ConcurrentJrubyService.java renamed to ext/ConcurrentRubyExtService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.jruby.Ruby;
44
import org.jruby.runtime.load.BasicLibraryService;
55

6-
public class ConcurrentJrubyService implements BasicLibraryService {
6+
public class ConcurrentRubyExtService implements BasicLibraryService {
77
public boolean basicLoad(final Ruby runtime) throws IOException {
88
new com.concurrent_ruby.ext.AtomicReferenceLibrary().load(runtime, false);
99
return true;

ext/Makefile

Lines changed: 0 additions & 5 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
require 'fileutils'
22

3-
$:.push File.join(File.dirname(__FILE__), '../lib')
3+
$:.push File.join(File.dirname(__FILE__), '../../lib')
44
require 'extension_helper'
55

6-
EXTENSION_NAME = 'concurrent_cruby'
6+
EXTENSION_NAME = 'concurrent_ruby_ext'
77

8-
if defined?(JRUBY_VERSION)
9-
puts 'JRuby detected. Pure Java optimizations will be used.'
10-
elsif ! Concurrent.use_c_extensions?
11-
puts 'C optimizations are only supported on MRI 2.0 and above.'
12-
else
13-
14-
def fake_build
15-
# http://yorickpeterse.com/articles/hacking-extconf-rb/
16-
FileUtils.touch(File.join(Dir.pwd, EXTENSION_NAME + '.' + RbConfig::CONFIG['DLEXT']))
17-
$makefile_created = true
8+
def create_dummy_makefile
9+
File.open('Makefile', 'w') do |f|
10+
f.puts 'all:'
11+
f.puts 'install:'
1812
end
13+
end
1914

15+
if defined?(JRUBY_VERSION) || ! Concurrent.use_c_extensions?
16+
create_dummy_makefile
17+
warn 'C optimizations are not supported on this version of Ruby.'
18+
else
2019
begin
2120

2221
require 'mkmf'
@@ -54,7 +53,7 @@ def compiler_is_gcc
5453

5554
create_makefile(EXTENSION_NAME)
5655
rescue
57-
puts 'C optimizations are not supported on this version of Ruby.'
58-
fake_build
56+
create_dummy_makefile
57+
warn 'C optimizations cannot be compiled on this version of Ruby.'
5958
end
6059
end

ext/rb_concurrent.c renamed to ext/concurrent_ruby_ext/rb_concurrent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
static VALUE rb_mConcurrent;
88
static VALUE rb_cAtomic;
99

10-
// Init_concurrent_cruby
10+
// Init_concurrent_ruby_ext
1111

12-
void Init_concurrent_cruby() {
12+
void Init_concurrent_ruby_ext() {
1313

1414
// define modules and classes
1515
rb_mConcurrent = rb_define_module("Concurrent");

lib/concurrent/atomic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
require "concurrent/atomic_reference/#{ruby_engine}"
1313
rescue LoadError
14-
warn "#{__FILE__}:#{__LINE__}: unsupported Ruby engine `#{RUBY_ENGINE}', using less-efficient Atomic impl"
14+
warn "Unsupported Ruby engine `#{RUBY_ENGINE}', using less-efficient Atomic impl"
1515
end
1616

1717
if defined? Concurrent::JavaAtomic

0 commit comments

Comments
 (0)