Module: Libv8::Compiler

Included in:
Builder
Defined in:
ext/libv8/compiler.rb

Class Method Summary collapse

Class Method Details

.check_clang_compiler(name) ⇒ Object



40
41
42
43
44
# File 'ext/libv8/compiler.rb', line 40

def check_clang_compiler(name)
  compiler = `which #{name}`
  return nil unless $?.success?
  compiler.chomp
end

.check_gcc_compiler(name) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'ext/libv8/compiler.rb', line 29

def check_gcc_compiler(name)
  compiler = `which #{name}`
  return nil unless $?.success?

  compiler.chomp!
  return nil unless `#{compiler} --version` =~ /([0-9]\.[0-9]\.[0-9])/

  return nil if $1 < "4.4"
  compiler
end

.compilerObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'ext/libv8/compiler.rb', line 5

def compiler
  unless defined?(@compiler)
    cc   = check_gcc_compiler "g++"

    # Check alternative GCC names
    # These are common on BSD's after
    # GCC has been installed by a port
    cc ||= check_gcc_compiler "g++44"
    cc ||= check_gcc_compiler "g++46"
    cc ||= check_gcc_compiler "g++48"

    if cc.nil?
      warn "Unable to find a compiler officially supported by v8."
      warn "It is recommended to use GCC v4.4 or higher"
      @compiler = cc = 'g++'
    end

    puts "Using compiler: #{cc}"
    @compiler = cc
  end

  @compiler
end