From 21327cad9bee7b80db0d8e3d4a2e56699dc80fc7 Mon Sep 17 00:00:00 2001 From: Luis Lavena Date: Sun, 8 Jan 2012 17:23:37 -0300 Subject: [PATCH] Add fat-binary stub when cross compiling And generate it using RUBY_VERSION and proper require. --- Rakefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Rakefile b/Rakefile index f37ed507c6..0dc6920791 100644 --- a/Rakefile +++ b/Rakefile @@ -62,8 +62,13 @@ 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) @@ -71,6 +76,16 @@ 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]