Sha256: 9ee9a8f6f6563ed0b70250d3445bd7d4dcb495b413f64fec8eb83b0b86fe0bb1

Contents?: true

Size: 1.47 KB

Versions: 20

Compression:

Stored size: 1.47 KB

Contents

module Rake

  #
  # HACK: Lousy API design, sue me. At least works ;-)
  #
  # Define a series of helpers to aid in search and usage of MinGW (GCC) Compiler
  # by gem developer/creators.
  #
  module ExtensionCompiler
    # return the host portion from the installed MinGW
    def self.mingw_host
      return @mingw_host if @mingw_host

      # the mingw_gcc_executable is helpful here
      if target = mingw_gcc_executable then
        # we only care for the filename
        target = File.basename(target)

        # now strip the extension (if present)
        target.sub!(File.extname(target), '')

        # get rid of '-gcc' portion too ;-)
        target.sub!('-gcc', '')
      end

      raise "No MinGW tools or unknown setup platform?" unless target

      @mingw_host = target
    end

    # return the first compiler found that includes both mingw and gcc conditions
    # (this assumes you have one installed)
    def self.mingw_gcc_executable
      return @mingw_gcc_executable if @mingw_gcc_executable

      # grab the paths defined in the environment
      paths = ENV['PATH'].split(File::PATH_SEPARATOR)

      # the pattern to look into (captures *nix and windows executables)
      pattern = "{mingw32-,i?86*mingw*,x86*mingw*}gcc{,.*}"

      @mingw_gcc_executable = paths.find do |path|
        # cleanup paths before globbing
        gcc = Dir.glob("#{File.expand_path(path)}/#{pattern}").first
        break gcc if gcc
      end

      @mingw_gcc_executable
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
rake-compiler-1.2.9 lib/rake/extensioncompiler.rb
rake-compiler-1.2.8 lib/rake/extensioncompiler.rb
rake-compiler-1.2.7 lib/rake/extensioncompiler.rb
rake-compiler-1.2.6 lib/rake/extensioncompiler.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/rake-compiler-1.2.5/lib/rake/extensioncompiler.rb
rake-compiler-1.2.5 lib/rake/extensioncompiler.rb
rake-compiler-1.2.4 lib/rake/extensioncompiler.rb
rake-compiler-1.2.3 lib/rake/extensioncompiler.rb
rake-compiler-1.2.2 lib/rake/extensioncompiler.rb
rake-compiler-1.2.1 lib/rake/extensioncompiler.rb
rake-compiler-1.2.0 lib/rake/extensioncompiler.rb
rake-compiler-1.1.9 lib/rake/extensioncompiler.rb
rake-compiler-1.1.8 lib/rake/extensioncompiler.rb
rake-compiler-1.1.7 lib/rake/extensioncompiler.rb
rake-compiler-1.1.6 lib/rake/extensioncompiler.rb
rake-compiler-1.1.5 lib/rake/extensioncompiler.rb
rake-compiler-1.1.4 lib/rake/extensioncompiler.rb
rake-compiler-1.1.3 lib/rake/extensioncompiler.rb
rake-compiler-1.1.2 lib/rake/extensioncompiler.rb
rake-compiler-1.1.1 lib/rake/extensioncompiler.rb