Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 6e9386cb4a8f2bccf7233c57e83c99160cdcf4a0 1 parent 3fb7599
Luis Lavena luislavena authored
14 features/cross-package.feature
View
@@ -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
6 features/step_definitions/compilation.rb
View
@@ -18,6 +18,12 @@
Given "a extension cross-compilable 'extension_one'"
end
+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'"
+end
+
Given /^not changed any file since$/ do
# don't do anything, that's the purpose of this step!
end
4 features/step_definitions/gem.rb
View
@@ -14,6 +14,10 @@
File.exist?(gem_file_platform(folder, name, version, platform)).should be_true
end
+Then /^gem for platform '(.*)' get generated$/ do |platform|
+ Then "a gem for 'gem_abc' version '0.1.0' platform '#{platform}' do exist in 'pkg'"
+end
+
def gem_file(folder, name, version)
"#{folder}/#{name}-#{version}.gem"
end
6 features/support/file_templates.rb
View
@@ -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 = 'http://github.com/luislavena/rake-compiler'
@@ -53,10 +55,10 @@ def template_rake_extension_with_platform(extension_name, platform)
EOF
end
-def template_rake_extension_cross_compile(extension_name)
+def template_rake_extension_cross_compile(extension_name, gem_spec = nil)
<<-EOF
require 'rake/extensiontask'
-Rake::ExtensionTask.new("#{extension_name}") do |ext|
+Rake::ExtensionTask.new("#{extension_name}"#{', SPEC' if gem_spec}) do |ext|
ext.cross_compile = true
end
EOF
11 features/support/generators.rb
View
@@ -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
- File.open("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
+ File.open("tasks/gem.rake", 'a+') do |ext_in_gem|
+ ext_in_gem.puts template_rake_extension_cross_compile(extension_name, true)
+ end
+ else
+ File.open("tasks/#{extension_name}.rake", 'w') do |ext_rake|
+ ext_rake.puts template_rake_extension_cross_compile(extension_name)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.