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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'ext/libv8/builder.rb', line 58 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} LINK=#{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 |
# 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 GPLv3 ld.gold binary on Linux defines << 'linux_use_bundled_gold=0' # Pass clang flag to GYP in order to work around GCC compilation failures defines << "clang=#{@compiler.is_a?(Compiler::Clang) ? '1' : '0'}" "GYP_DEFINES=\"#{defines.join ' '}\"" end |
#make_flags(*flags) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'ext/libv8/builder.rb', line 41 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 "#{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.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'ext/libv8/builder.rb', line 102 def setup_build_deps! ENV['PATH'] = "#{File.('../../../vendor/depot_tools', __FILE__)}:#{ENV['PATH']}" Dir.chdir(File.('../../../vendor', __FILE__)) do unless Dir.exists? 'v8' system "fetch v8" or fail "unable to fetch v8 source" else system "gclient fetch" or fail "could not fetch v8 build dependencies commits" end Dir.chdir('v8') do unless system "git checkout #{source_version} -- ." fail "unable to checkout source for v8 #{source_version}" end system "gclient sync" or fail "could not sync v8 build dependencies" system "git checkout Makefile" # Work around a weird bug on FreeBSD end end end |
#setup_python! ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'ext/libv8/builder.rb', line 74 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 |