1
0
Fork 0
mirror of https://github.com/rubyjs/libv8 synced 2023-03-27 23:21:48 -04:00

Use RbConfig to determine default compiler

This commit is contained in:
ignisf 2014-06-15 17:36:17 +03:00
parent a7f92a02ed
commit 1762e38cf9
2 changed files with 20 additions and 10 deletions

View file

@ -75,7 +75,7 @@ module Libv8
def choose_compiler
compiler_names = if with_config('cxx') then [with_config('cxx')]
elsif ENV['CXX'] then [ENV['CXX']]
else Compiler::KNOWN_COMPILERS
else Compiler::well_known_compilers
end
available_compilers = Compiler.available_compilers(*compiler_names)

View file

@ -1,5 +1,4 @@
require 'mkmf'
require 'open3'
require 'rbconfig'
require File.expand_path '../compiler/generic_compiler', __FILE__
require File.expand_path '../compiler/gcc', __FILE__
require File.expand_path '../compiler/clang', __FILE__
@ -7,15 +6,26 @@ require File.expand_path '../compiler/apple_llvm', __FILE__
module Libv8
module Compiler
KNOWN_COMPILERS = [
::MakeMakefile::CONFIG['CXX'],
'c++',
'g++48', 'g++46', 'g++44', 'g++',
'clang++',
].uniq
module_function
def well_known_compilers
compilers = []
# The command Ruby was compiled with
compilers << RbConfig::CONFIG['CXX']
# The default system compiler
compilers << 'c++'
# FreeBSD GCC command names
compilers += ['g++48', 'g++46', 'g++44']
# Default compiler names
compilers << ['g++', 'clang++']
compilers.uniq
end
def available_compilers(*compiler_names)
available = compiler_names.select { |compiler_name| available? compiler_name }
available.map { |compiler_name| type_of(compiler_name).new compiler_name }