Sha256: 305c9dc59f58c2a003010272bfbc47939be96198e9f3e5231ec6e7c83f59faab

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'rbconfig'
require 'mkmf'

def darwin?
  RUBY_PLATFORM =~ /darwin/
end

def cpu_x64?
  unless defined?(RUBY_ENGINE) and RUBY_ENGINE == 'rbx'
    !!(RbConfig::MAKEFILE_CONFIG['arch'] =~ /x86_64/ ||
       RbConfig::MAKEFILE_CONFIG['target_cpu'] == 'x86_64' ||
       RbConfig::MAKEFILE_CONFIG['build_cpu'] == 'x86_64' ||
       RbConfig::MAKEFILE_CONFIG['ARCH_FLAG'] =~ /x86_64/)
  else
    ['x'].pack('y').size == 8
  end
end

def make_sure_scons_installed!
  unless `hash scons; echo $?`.to_i == 0
    raise RuntimeError, "ERROR: To compile V8 engine you need to install the Scons library!"
  end
end

def compile_v8!(v8_dir)
  Dir.chdir v8_dir do 
    if Dir["**/libv8.a"].empty?
      make_sure_scons_installed!
      defaults, ENV['CCFLAGS'] = ENV['CCFLAGS'], V8_FLAGS
      build_cmd = "scons mode=release snapshot=off library=static arch=#{V8_ARCH}"
      puts build_cmd
      system build_cmd
      ENV['CCFLAGS'] = defaults
    end
  end
end

V8_DIR = File.expand_path("../../../vendor/v8", __FILE__)
V8_ARCH = cpu_x64? ? 'x64' : 'ia32' 
V8_FLAGS = '-fPIC -fno-builtin-memcpy'
           
compile_v8!(V8_DIR)

dir_config('mustang/v8')
find_header('v8.h', File.join(V8_DIR, "include"))
have_library('pthread')
have_library('objc') if darwin?

CONFIG['LDSHARED'] = '$(CXX) -shared' unless darwin?
$LOCAL_LIBS << Dir[File.join(V8_DIR, "**/**/libv8.a")].first

%w[-Wall -g -rdynamic -fPIC].each { |flag|
  $CPPFLAGS += " #{flag}" unless $CPPFLAGS.include?(flag)
}

create_makefile('v8')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mustang-0.1.0 ext/v8/extconf.rb