forked from ruby-concurrency/concurrent-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
87 lines (72 loc) · 2.04 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'bundler/gem_tasks'
require 'rake/extensiontask'
require 'rake/javaextensiontask'
GEMSPEC = Gem::Specification.load('concurrent-ruby.gemspec')
EXTENSION_NAME = 'concurrent_ruby_ext'
Bundler::GemHelper.install_tasks
$:.push File.join(File.dirname(__FILE__), 'lib')
require 'extension_helper'
def safe_load(file)
begin
load file
rescue LoadError => ex
puts 'Error loading rake tasks, but will continue...'
puts ex.message
end
end
Dir.glob('tasks/**/*.rake').each do |rakefile|
safe_load rakefile
end
desc 'Run benchmarks'
task :bench do
exec 'ruby -Ilib -Iext examples/bench_atomic.rb'
end
if defined?(JRUBY_VERSION)
Rake::JavaExtensionTask.new(EXTENSION_NAME, GEMSPEC) do |ext|
ext.ext_dir = 'ext'
end
elsif Concurrent.use_c_extensions?
Rake::ExtensionTask.new(EXTENSION_NAME, GEMSPEC) do |ext|
ext.ext_dir = "ext/#{EXTENSION_NAME}"
ext.cross_compile = true
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
end
ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
platforms = {
'x86-mingw32' => 'i686-w64-mingw32',
'x64-mingw32' => 'x86_64-w64-mingw32'
}
platforms.each do |platform, prefix|
task "copy:#{EXTENSION_NAME}:#{platform}:#{ruby_version}" do |t|
%w[lib tmp/#{platform}/stage/lib].each do |dir|
so_file = "#{dir}/#{ruby_version[/^\d+\.\d+/]}/#{EXTENSION_NAME}.so"
if File.exists?(so_file)
sh "#{prefix}-strip -S #{so_file}"
end
end
end
end
end
else
task :clean
task :compile
task "compile:#{EXTENSION_NAME}"
end
Rake::Task[:clean].enhance do
rm_rf 'pkg/classes'
rm_rf 'tmp'
rm_rf 'lib/1.9'
rm_rf 'lib/2.0'
rm_f Dir.glob('./lib/*.jar')
rm_f Dir.glob('./**/*.bundle')
end
begin
require 'rspec'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = '--color --backtrace --format documentation'
end
task :default => [:clean, :compile, :spec]
rescue LoadError
puts 'Error loading Rspec rake tasks, probably building the gem...'
end