Module: Libv8::Compiler

Defined in:
ext/libv8/compiler.rb,
ext/libv8/compiler/gcc.rb,
ext/libv8/compiler/clang.rb,
ext/libv8/compiler/apple_llvm.rb,
ext/libv8/compiler/generic_compiler.rb

Defined Under Namespace

Classes: AppleLLVM, Clang, ExecutionResult, GCC, GenericCompiler

Class Method Summary collapse

Class Method Details

.execute_command(command) ⇒ Object



30
31
32
33
34
# File 'ext/libv8/compiler.rb', line 30

def execute_command(command)
  output = `#{command}`
  status = $?
  ExecutionResult.new output, status
end

.type_of(compiler) ⇒ Object



11
12
13
14
15
16
17
18
# File 'ext/libv8/compiler.rb', line 11

def type_of(compiler)
  case version_string_of(compiler)
  when /^Apple LLVM\b/ then AppleLLVM
  when /\bclang\b/i then Clang
  when /^gcc/i then GCC
  else GenericCompiler
  end
end

.version_string_of(compiler) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'ext/libv8/compiler.rb', line 20

def version_string_of(compiler)
  command_result = execute_command "env LC_ALL=C LANG=C #{compiler} -v 2>&1"

  unless command_result.status.success?
    raise "Could not get version string of compiler #{compiler}"
  end

  command_result.output
end