diff options
Diffstat (limited to 'lib/rake')
-rw-r--r-- | lib/rake/extensiontask.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/rake/extensiontask.rb b/lib/rake/extensiontask.rb index d5c6c85..9df8743 100644 --- a/lib/rake/extensiontask.rb +++ b/lib/rake/extensiontask.rb @@ -25,6 +25,7 @@ module Rake @cross_compiling = nil @no_native = false @config_includes = [] + @ruby_versions_per_platform = Hash.new([]) end def cross_platform @@ -253,6 +254,13 @@ Java extension should be preferred. # adjust to specified platform spec.platform = Gem::Platform.new(platf) + # set ruby version constraints + cross_rubies = @ruby_versions_per_platform[platf] + spec.required_ruby_version = [ + ">= #{version_ary2str( cross_rubies.min[0,2] )}", + "< #{version_ary2str( cross_rubies.max[0,2].succ )}" + ] + # clear the extensions defined in the specs spec.extensions.clear @@ -346,6 +354,9 @@ Java extension should be preferred. @lib_dir = "#{@lib_dir}/#{$1}" end + # Update cross compiled platform/version combinations + @ruby_versions_per_platform[for_platform] << version_str2ary(version) + define_cross_platform_tasks_with_version(for_platform, version) # restore lib_dir @@ -497,6 +508,14 @@ Java extension should be preferred. [*@cross_platform].map { |p| "native:#{p}" } end + def version_str2ary(version_string) + version_string[/\A[^-]+/].split(".").map(&:to_i).pack("C*") + end + + def version_ary2str(version_ary) + version_ary.unpack("C*").join(".") + end + def fake_rb(platform, version) <<-FAKE_RB # Pre-load resolver library before faking, in order to avoid error |