Module: Libv8::Compiler
- Defined in:
- ext/libv8/compiler.rb,
ext/libv8/compiler/gcc.rb,
ext/libv8/compiler/clang.rb,
ext/libv8/compiler/generic_compiler.rb
Defined Under Namespace
Classes: Clang, GCC, GenericCompiler
Constant Summary
collapse
- KNOWN_COMPILERS =
[
'c++',
'g++48', 'g++46', 'g++44', 'g++',
'clang++',
]
Class Method Summary
collapse
Class Method Details
.available_compilers(*compiler_names) ⇒ Object
21
22
23
|
# File 'ext/libv8/compiler.rb', line 21
def available_compilers(*compiler_names)
compiler_paths = compiler_names.map { |name| find name }.reject &:nil?
end
|
.determine_type(compiler_path) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'ext/libv8/compiler.rb', line 32
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
|
.find(name) ⇒ Object
25
26
27
28
29
30
|
# File 'ext/libv8/compiler.rb', line 25
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
|
.system_compilers ⇒ Object
17
18
19
|
# File 'ext/libv8/compiler.rb', line 17
def system_compilers
available_compilers *Compiler::KNOWN_COMPILERS
end
|