Sha256: af26d4870918230f4121c1b5e0d78db1373d3cf3ab94f34418e2553985e16728

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module Libv8
  module Compiler
    module_function

    def compiler
      unless defined?(@compiler)
        cc   = check_gcc_compiler with_config("cxx")
        cc ||= check_gcc_compiler ENV["CXX"]
        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

        @compiler = cc
      end

      @compiler
    end

    def check_gcc_compiler(name)
      # in SmartOS, `which` returns success with no arguments. 'with_config' above may return nil
      return nil if "#{name}".empty?

      compiler = `which #{name} 2> /dev/null`
      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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
libv8-3.16.14.3 ext/libv8/compiler.rb
libv8-3.16.14.2 ext/libv8/compiler.rb