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.
17 18 19 |
# File 'ext/libv8/builder.rb', line 17 def initialize @compiler = choose_compiler end |
Instance Method Details
#build_libv8! ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'ext/libv8/builder.rb', line 57 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=#{@compiler} LINK=#{@compiler} #{make} #{make_flags}" puts "Building v8 with #{command}" system command end return $?.exitstatus end |
#gyp_defines(*defines) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'ext/libv8/builder.rb', line 26 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' # 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
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'ext/libv8/builder.rb', line 36 def make_flags(*flags) # Fix Malformed archive issue caused by GYP creating thin archives by # default. flags << "standalone_static_library=1" # 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
21 22 23 24 |
# File 'ext/libv8/builder.rb', line 21 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.
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/libv8/builder.rb', line 101 def setup_build_deps! ENV['PATH'] = "#{File.('../../../vendor/depot_tools', __FILE__)}:#{ENV['PATH']}" Dir.chdir(File.('../../../vendor', __FILE__)) do system "fetch v8" or fail "unable to fetch v8 source" 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" end end end |
#setup_python! ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'ext/libv8/builder.rb', line 73 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 |