Sha256: fc2c389de87cb1af9a07dd0342493f0536e81d8f83a662eafe3708c8857699d7

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

module Rake
  class CompilerConfig
    def initialize(config_path)
      require "yaml"
      @config = YAML.load_file(config_path)
    end

    def find(ruby_version, gem_platform)
      gem_platform = Gem::Platform.new(gem_platform)

      @config.each do |config_name, config_location|
        # There are two variations we might find in the rake-compiler config.yml
        #
        # 1. config_name: rbconfig-x86_64-linux-3.0.0
        #    runtime_platform_name: x86_64-linux
        #    runtime_version: 3.0.0
        #
        # 2. config_name: rbconfig-x86_64-linux-gnu-3.0.0
        #    runtime_platform_name: x86_64-linux-gnu
        #    runtime_version: 3.0.0
        #
        # With rubygems < 3.3.21, both variations will be present (two entries pointing at the same
        # installation).
        #
        # With rubygems >= 3.3.21, only the second variation will be present.
        runtime_platform_name = config_name.split("-")[1..-2].join("-")
        runtime_version = config_name.split("-").last
        runtime_platform = Gem::Platform.new(runtime_platform_name)

        if (ruby_version == runtime_version) && (gem_platform =~ runtime_platform)
          return config_location
        end
      end

      nil
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
rake-compiler-1.2.9 lib/rake/compiler_config.rb
rake-compiler-1.2.8 lib/rake/compiler_config.rb
rake-compiler-1.2.7 lib/rake/compiler_config.rb
rake-compiler-1.2.6 lib/rake/compiler_config.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/rake-compiler-1.2.5/lib/rake/compiler_config.rb
rake-compiler-1.2.5 lib/rake/compiler_config.rb
rake-compiler-1.2.4 lib/rake/compiler_config.rb
rake-compiler-1.2.3 lib/rake/compiler_config.rb
rake-compiler-1.2.2 lib/rake/compiler_config.rb
rake-compiler-1.2.1 lib/rake/compiler_config.rb