summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rake/extensiontask.rb2
-rw-r--r--spec/lib/rake/extensiontask_spec.rb14
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|