Permalink
Browse files

Completed missing pieces for cross-compile feature.

  • Loading branch information...
1 parent 858ea34 commit 3fb7599204ddc2d4b738a4459a48994148222729 @luislavena luislavena committed Nov 29, 2008
View
10 features/step_definitions/compilation.rb
@@ -3,11 +3,21 @@
generate_source_code_for extension_name
end
+Given /^a extension cross-compilable '(.*)'$/ do |extension_name|
+ generate_cross_compile_extension_task_for extension_name
+ generate_source_code_for extension_name
+end
+
Given /^a extension '(.*)' with forced platform '(.*)'$/ do |extension_name, forced_platform|
generate_extension_task_for extension_name, forced_platform
generate_source_code_for extension_name
end
+Given /^that all my source files are in place$/ do
+ Given "a safe project directory"
+ 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
View
7 features/step_definitions/cross_compilation.rb
@@ -4,7 +4,7 @@
end
end
-Given %r{^I've cross compile tools installed$} do
+Given %r{^I've installed cross compile toolchain$} do
compiler = 'i586-mingw32msvc-gcc'
found = false
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
@@ -13,3 +13,8 @@
end
raise "Cannot locate '#{compiler}' in the PATH." unless found
end
+
+Then /^binaries for platform '(.*)' get generated$/ do |platform|
+ ext_for_platform = Dir.glob("tmp/#{platform}/**/*.#{RbConfig::CONFIG['DLEXT']}")
+ ext_for_platform.should_not be_empty
+end
View
9 features/support/file_templates.rb
@@ -53,6 +53,15 @@ def template_rake_extension_with_platform(extension_name, platform)
EOF
end
+def template_rake_extension_cross_compile(extension_name)
+<<-EOF
+require 'rake/extensiontask'
+Rake::ExtensionTask.new("#{extension_name}") do |ext|
+ ext.cross_compile = true
+end
+EOF
+end
+
def template_extconf(extension_name)
<<-EOF
require 'mkmf'
View
12 features/support/generators.rb
@@ -40,6 +40,18 @@ def generate_extension_task_for(extension_name, platform = nil)
end
end
+def generate_cross_compile_extension_task_for(extension_name)
+ # create folder structure
+ FileUtils.mkdir_p "ext/#{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)
+ end
+end
+
def generate_source_code_for(extension_name)
# source C file
File.open("ext/#{extension_name}/source.c", 'w') do |c|

0 comments on commit 3fb7599

Please sign in to comment.