Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add fat-binary stub when cross compiling
And generate it using RUBY_VERSION and proper require.
  • Loading branch information
luislavena committed Jan 8, 2012
1 parent 38ab15d commit 21327ca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Rakefile
Expand Up @@ -62,15 +62,30 @@ Rake::ExtensionTask.new("puma_http11", HOE.spec) do |ext|

ext.cross_compile = true
ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32']
ext.cross_compiling do |spec|
# add fat-binary stub only when cross compiling
spec.files << "lib/puma/puma_http11.rb"
end

CLEAN.include "lib/puma/{1.8,1.9}"
CLEAN.include "lib/puma/puma_http11.rb"
end

# Java (JRuby)
Rake::JavaExtensionTask.new("puma_http11", HOE.spec) do |ext|
ext.lib_dir = "lib/puma"
end

# the following is a fat-binary stub that will be used when
# require 'puma/puma_http11' and will use either 1.8 or 1.9 version depending
# on RUBY_VERSION
file "lib/puma/puma_http11.rb" do |t|
File.open(t.name, "w") do |f|
f.puts "RUBY_VERSION =~ /(\d+.\d+)/"
f.puts 'require "puma/#{$1}/puma_http11"'
end
end

# tests require extension be compiled, but depend on the platform
if IS_JRUBY
task :test => [:java]
Expand Down

0 comments on commit 21327ca

Please sign in to comment.