diff options
author | Luis Lavena <luislavena@gmail.com> | 2008-12-07 14:13:35 -0500 |
---|---|---|
committer | Luis Lavena <luislavena@gmail.com> | 2008-12-07 14:13:35 -0500 |
commit | 07e3d7c899f0d110144731959fe22a05a28f12cd (patch) | |
tree | 16dba1549d5f033b42593081c67cd7ae80717241 | |
parent | 125e407c363e5eeed53492f945d321fd809af2aa (diff) | |
download | rake-compiler-07e3d7c899f0d110144731959fe22a05a28f12cd.tar.gz |
Allow RUBY_CC_VERSION to specify target Ruby version.
This makes 'rake cross compile' more flexible when multiple Ruby versions
exists into rake-compiler directory.
-rw-r--r-- | lib/rake/extensiontask.rb | 2 | ||||
-rw-r--r-- | spec/lib/rake/extensiontask_spec.rb | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/rake/extensiontask.rb b/lib/rake/extensiontask.rb index f942c89..20efa39 100644 --- a/lib/rake/extensiontask.rb +++ b/lib/rake/extensiontask.rb @@ -200,7 +200,7 @@ module Rake def define_cross_platform_tasks config_path = File.expand_path("~/.rake-compiler/config.yml") - major_ver = RUBY_VERSION.match(/(\d+.\d+)/)[1] + major_ver = (ENV['RUBY_CC_VERSION'] || RUBY_VERSION).match(/(\d+.\d+)/)[1] # warn the user about the need of configuration to use cross compilation. unless File.exist?(config_path) diff --git a/spec/lib/rake/extensiontask_spec.rb b/spec/lib/rake/extensiontask_spec.rb index 181d24b..a2d9415 100644 --- a/spec/lib/rake/extensiontask_spec.rb +++ b/spec/lib/rake/extensiontask_spec.rb @@ -277,6 +277,20 @@ describe Rake::ExtensionTask do }.should raise_error(RuntimeError, /no configuration section for this version of Ruby/) end + it 'should allow usage of RUBY_CC_VERSION to indicate a different version of ruby' do + config = mock(Hash) + config.should_receive(:[]).with("rbconfig-2.0").and_return('/path/to/ruby/2.0/rbconfig.rb') + YAML.stub!(:load_file).and_return(config) + begin + ENV['RUBY_CC_VERSION'] = '2.0' + Rake::ExtensionTask.new('extension_one') do |ext| + ext.cross_compile = true + end + ensure + ENV.delete('RUBY_CC_VERSION') + end + end + describe "(cross for 'universal-unknown' platform)" do before :each do @ext = Rake::ExtensionTask.new('extension_one', @spec) do |ext| |