forked from dan-manges/mixology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
99 lines (89 loc) · 2.93 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
88
89
90
91
92
93
94
95
96
97
98
require "rake"
require 'rake/clean'
require 'rake/gempackagetask'
require "rake/testtask"
desc "clean, compile, test"
task :default => %w[clean compile test]
Rake::TestTask.new("test") do |t|
t.pattern = "test/**/*_test.rb"
end
desc "Builds the extension"
if RUBY_PLATFORM =~ /java/
task :compile => :compile_java
else
task :compile => %W[ext/mixology/Makefile ext/mixology/mixology.#{Config::CONFIG['DLEXT']}]
end
file "ext/mixology/Makefile" => ["ext/mixology/extconf.rb"] do
Dir.chdir("ext/mixology") do
ruby "extconf.rb"
end
end
file "ext/mixology/mixology.#{Config::CONFIG['DLEXT']}" do
Dir.chdir("ext/mixology") do
sh "make"
end
cp "ext/mixology/mixology.#{Config::CONFIG['DLEXT']}", "lib"
end
CLEAN.include %w[ext/mixology/Makefile ext/mixology/mixology.bundle ext/mixology/mixology.so lib/mixology.bundle lib/mixology.so ext/mixology/mixology.o]
CLEAN.include %w[ext/mixology/MixableService.class ext/mixology/mixable.jar lib/mixology.jar]
specification = Gem::Specification.new do |s|
s.name = "mixology"
s.summary = "Mixology enables objects to mixin and unmix modules."
s.version = "0.2.0"
s.author = "anonymous z, Pat Farley, Dan Manges"
s.description = s.summary
s.homepage = "http://mixology.rubyforge.org"
s.rubyforge_project = "mixology"
s.has_rdoc = false
s.autorequire = "mixology"
s.files = FileList['ext/**/*.{c,rb}', '{lib,test}/**/*.rb', '^[A-Z]+$', 'Rakefile'].to_a
if RUBY_PLATFORM =~ /mswin/
s.platform = Gem::Platform::WIN32
s.files += ["lib/mixology.so"]
elsif RUBY_PLATFORM =~ /java/
s.platform = "java"
s.files += ["lib/mixology.jar"]
else
s.platform = Gem::Platform::RUBY
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
end
Rake::GemPackageTask.new(specification) do |package|
package.need_zip = false
package.need_tar = false
end
desc "Compiles the JRuby extension"
task :compile_java do
Dir.chdir("ext/mixology") do
sh %{javac -source 1.5 -target 1.5 -classpath $JRUBY_HOME/lib/jruby.jar MixologyService.java}
sh %{jar cf mixology.jar MixologyService.class}
cp "mixology.jar", "../../lib/mixology.jar"
end
end
desc "test against multiple ruby implementations"
task :test_multi do
# this is specific to how I have Ruby installed on my machine -Dan
jruby = %w[1.1.3 1.1.4]
mri = %w[1.8.6-p368 1.9.1-p129]
failed = false
test_implementation = proc do |implementation, command|
print "#{implementation}: "
output = `#{command} 2>&1`
if $?.success? && output =~ /\d\d+ tests.*0 failures, 0 errors/
puts "PASS"
else
puts "FAIL"
failed = true
end
end
jruby.each do |jruby_version|
test_implementation.call(
"JRuby #{jruby_version}",
"JRUBY_HOME=/usr/local/jruby-#{jruby_version} /usr/local/jruby-#{jruby_version}/bin/jruby -S rake"
)
end
mri.each do |mri_version|
test_implementation.call "MRI #{mri_version}", "/usr/local/ruby-#{mri_version}/bin/rake"
end
fail if failed
end