Browse files

Generate packages (gems) of your extensions, across platforms, for free.

Implemented feature that describe the process.
Modified steps to accomodate the new functionality.
  • Loading branch information...
1 parent 3fb7599 commit 6e9386cb4a8f2bccf7233c57e83c99160cdcf4a0 @luislavena luislavena committed Nov 29, 2008
@@ -0,0 +1,14 @@
+Feature: Generate Windows gems from Linux
+ In order to keep sanity in the Ruby world
+ As a Gem developer on Linux
+ I want more rake magic that turns monotony into joy.
+ Scenario: package a gem for Windows
+ Given that my gem source is all in place
+ And I'm running a POSIX operating system
+ And I've installed cross compile toolchain
+ And I've already successfully executed rake task 'cross compile'
+ When rake task 'cross native gem' is invoked
+ Then rake task 'cross native gem' succeeded
+ And gem for platform 'x86-mingw32' get generated
@@ -18,6 +18,12 @@
Given "a extension cross-compilable 'extension_one'"
+Given /^that my gem source is all in place$/ do
+ Given "a safe project directory"
+ Given "a gem named 'gem_abc'"
+ Given "a extension cross-compilable 'extension_one'"
Given /^not changed any file since$/ do
# don't do anything, that's the purpose of this step!
@@ -14,6 +14,10 @@
File.exist?(gem_file_platform(folder, name, version, platform)).should be_true
+Then /^gem for platform '(.*)' get generated$/ do |platform|
+ Then "a gem for 'gem_abc' version '0.1.0' platform '#{platform}' do exist in 'pkg'"
def gem_file(folder, name, version)
@@ -21,6 +21,8 @@ def template_rake_gemspec(gem_name)
s.files = FileList["ext/**/*.{rb,c,h}", "Rakefile", "tasks/*.rake", "lib/**/*.rb"]
+ s.extensions = FileList["ext/**/extconf.rb"]
s.has_rdoc = true
s.homepage = ''
@@ -53,10 +55,10 @@ def template_rake_extension_with_platform(extension_name, platform)
-def template_rake_extension_cross_compile(extension_name)
+def template_rake_extension_cross_compile(extension_name, gem_spec = nil)
require 'rake/extensiontask'"#{extension_name}") do |ext|"#{extension_name}"#{', SPEC' if gem_spec}) do |ext|
ext.cross_compile = true
@@ -47,8 +47,15 @@ def generate_cross_compile_extension_task_for(extension_name)
return if File.exist?("tasks/#{extension_name}.rake")
# create specific extension rakefile
-"tasks/#{extension_name}.rake", 'w') do |ext_rake|
- ext_rake.puts template_rake_extension_cross_compile(extension_name)
+ # Building a gem?
+ if File.exist?("tasks/gem.rake") then
+"tasks/gem.rake", 'a+') do |ext_in_gem|
+ ext_in_gem.puts template_rake_extension_cross_compile(extension_name, true)
+ end
+ else
+"tasks/#{extension_name}.rake", 'w') do |ext_rake|
+ ext_rake.puts template_rake_extension_cross_compile(extension_name)
+ end

0 comments on commit 6e9386c

Please sign in to comment.