Class: Libv8::Builder
- Inherits:
-
Object
- Object
- Libv8::Builder
- Defined in:
- ext/libv8/builder.rb
Constant Summary
Constants included from Patcher
Instance Method Summary collapse
- #build_libv8! ⇒ Object
- #gyp_defines(*defines) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #make_flags(*flags) ⇒ Object
- #make_target ⇒ Object
-
#setup_build_deps! ⇒ Object
Checkout all of the V8 source and its dependencies using the chromium depot tools.
- #setup_python! ⇒ Object
-
#source_version ⇒ Object
The release tag to checkout.
Methods included from Patcher
Methods included from Make
Methods included from Arch
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
19 20 21 |
# File 'ext/libv8/builder.rb', line 19 def initialize @compiler = choose_compiler end |
Instance Method Details
#build_libv8! ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'ext/libv8/builder.rb', line 69 def build_libv8! setup_python! setup_build_deps! Dir.chdir(File.('../../../vendor/v8', __FILE__)) do fail 'No compilers available' if @compiler.nil? patch! print_build_info puts 'Beginning compilation. This will take some time.' command = "env CXX=#{Shellwords.escape @compiler.to_s} #{make} #{make_flags}" puts "Building v8 with #{command}" system command end return $?.exitstatus end |
#gyp_defines(*defines) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'ext/libv8/builder.rb', line 28 def gyp_defines(*defines) # Do not use an external snapshot as we don't really care for binary size defines << 'v8_use_external_startup_data=0' # Do not use the embedded toolchain defines << 'use_sysroot=0' defines << 'linux_use_bundled_binutils=0' defines << 'linux_use_bundled_gold=0' defines << 'make_clang_dir=""' defines << 'clang_dir=""' # Pass clang flag to GYP in order to work around GCC compilation failures defines << "clang=#{@compiler.is_a?(Compiler::Clang) ? '1' : '0'}" # Add contents of the GYP_DEFINES environment variable if present defines << ENV['GYP_DEFINES'] unless ENV['GYP_DEFINES'].nil? "GYP_DEFINES=\"#{defines.join ' '}\"" end |
#make_flags(*flags) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'ext/libv8/builder.rb', line 48 def make_flags(*flags) # Disable i18n flags << 'i18nsupport=off' # Solaris / Smart OS requires additional -G flag to use with -fPIC flags << "CFLAGS=-G" if @compiler.target =~ /solaris/ # Disable werror as this version of v8 is getting difficult to maintain # with it on flags << 'werror=no' # Append GYP variable definitions flags << gyp_defines # Append manually specified MAKEFLAGS flags << ENV['MAKEFLAGS'] if ENV['MAKEFLAGS'] ENV['MAKEFLAGS'] = nil "#{make_target} #{flags.join ' '}" end |
#make_target ⇒ Object
23 24 25 26 |
# File 'ext/libv8/builder.rb', line 23 def make_target profile = enable_config('debug') ? 'debug' : 'release' "#{libv8_arch}.#{profile}" end |
#setup_build_deps! ⇒ Object
Checkout all of the V8 source and its dependencies using the chromium depot tools.
113 114 115 116 117 118 119 120 121 122 |
# File 'ext/libv8/builder.rb', line 113 def setup_build_deps! ENV['PATH'] = "#{File.('../../../vendor/depot_tools', __FILE__)}:#{ENV['PATH']}" Dir.chdir(File.('../../../vendor/v8', __FILE__)) do unless system "git checkout #{source_version}" fail "unable to checkout source for v8 #{source_version}" end system "env #{gyp_defines} gclient sync -n" or fail "could not sync v8 build dependencies" system "git checkout Makefile" # Work around a weird bug on FreeBSD end end |
#setup_python! ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'ext/libv8/builder.rb', line 85 def setup_python! # If python v2 cannot be found in PATH, # create a symbolic link to python2 the current directory and put it # at the head of PATH. That way all commands that inherit this environment # will use ./python -> python2 if python_version !~ /^2/ unless system 'which python2 2>&1 > /dev/null' fail "libv8 requires python 2 to be installed in order to build, but it is currently #{python_version}" end `ln -fs #{`which python2`.chomp} python` ENV['PATH'] = "#{File. '.'}:#{ENV['PATH']}" end end |