Sha256: 95782490474e6eacaf50ec2465cdd3a8d61bb340ea1e9996b8ed8072a19bb3da

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module Libv8
  module Compiler
    module_function

    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

        @compiler = cc
      end

      @compiler
    end

    def check_gcc_compiler(name)
      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

4 entries across 4 versions & 1 rubygems

Version Path
libv8-3.16.14.1 ext/libv8/compiler.rb
libv8-3.16.14.0 ext/libv8/compiler.rb
libv8-3.11.8.17 ext/libv8/compiler.rb
libv8-3.11.8.16 ext/libv8/compiler.rb