Sha256: 2fb70475f4b2d082e7849684d161ee85598d397cb5052814a117705650bcdb1c

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

require 'mkmf'
require 'open3'
require File.expand_path '../compiler/generic_compiler', __FILE__
require File.expand_path '../compiler/gcc', __FILE__
require File.expand_path '../compiler/clang', __FILE__

module Libv8
  module Compiler
    KNOWN_COMPILERS = [
                       'c++',
                       'g++48', 'g++46', 'g++44', 'g++',
                       'clang++',
                      ]

    module_function

    def system_compilers
      available_compilers *Compiler::KNOWN_COMPILERS
    end

    def available_compilers(*compiler_names)
      compiler_paths = compiler_names.map { |name| find name }.reject &:nil?
    end

    def find(name)
      return nil if name.empty?
      path, _, status = Open3.capture3 "which #{name}"
      path.chomp!
      determine_type(path).new(path) if status.success?
    end

    def determine_type(compiler_path)
      compiler_version = Open3.capture3("#{compiler_path} -v")[0..1].join

      case compiler_version
      when /\bclang\b/i then Clang
      when /^gcc/i      then GCC
      else                   GenericCompiler
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
libv8-tmpfork-3.16.14.13 ext/libv8/compiler.rb
libv8-3.16.14.13 ext/libv8/compiler.rb
libv8-3.16.14.12 ext/libv8/compiler.rb
libv8-3.16.14.11 ext/libv8/compiler.rb
libv8-3.16.14.10 ext/libv8/compiler.rb
libv8-3.16.14.8 ext/libv8/compiler.rb
libv8-3.16.14.8.rc1 ext/libv8/compiler.rb
libv8-3.16.14.7 ext/libv8/compiler.rb
libv8-3.16.14.6 ext/libv8/compiler.rb
libv8-3.16.14.5 ext/libv8/compiler.rb
libv8-3.16.14.4 ext/libv8/compiler.rb