Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 45996a9

Browse files
committed
Drop most of build process tuning
1 parent c714ddf commit 45996a9

2 files changed

Lines changed: 14 additions & 92 deletions

File tree

ext/libv8/builder.rb

Lines changed: 13 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,31 @@
1-
unless $:.include? File.expand_path("../../../lib", __FILE__)
2-
$:.unshift File.expand_path("../../../lib", __FILE__)
3-
end
41
require 'mkmf'
52
require 'rbconfig'
63
require 'shellwords'
74
require 'libv8/version'
8-
require File.expand_path '../compiler', __FILE__
9-
require File.expand_path '../arch', __FILE__
10-
require File.expand_path '../make', __FILE__
11-
require File.expand_path '../patcher', __FILE__
125

136
module Libv8
147
class Builder
15-
include Libv8::Arch
16-
include Libv8::Make
17-
include Libv8::Patcher
8+
def gn_args
9+
'is_debug=false is_component_build=false v8_monolithic=true v8_use_external_startup_data=false target_cpu="x64" v8_target_cpu="x64" treat_warnings_as_errors=false v8_enable_i18n_support=false'
10+
end
1811

19-
def initialize
20-
@compiler = choose_compiler
12+
def generate_gn_args
13+
system "gn gen out.gn/libv8 --args='#{gn_args}'"
2114
end
2215

2316
def make_target
2417
profile = enable_config('debug') ? 'debug' : 'release'
2518
"#{libv8_arch}.#{profile}"
2619
end
2720

28-
def gyp_defines(*defines)
29-
# Do not use an external snapshot as we don't really care for binary size
30-
defines << 'v8_use_external_startup_data=0'
31-
32-
# Do not use the embedded toolchain
33-
defines << 'use_sysroot=0'
34-
defines << 'linux_use_bundled_binutils=0'
35-
defines << 'linux_use_bundled_gold=0'
36-
defines << 'make_clang_dir=""'
37-
defines << 'clang_dir=""'
38-
39-
# Pass clang flag to GYP in order to work around GCC compilation failures
40-
defines << "clang=#{@compiler.is_a?(Compiler::Clang) ? '1' : '0'}"
41-
42-
# Add contents of the GYP_DEFINES environment variable if present
43-
defines << ENV['GYP_DEFINES'] unless ENV['GYP_DEFINES'].nil?
44-
45-
"GYP_DEFINES=\"#{defines.join ' '}\""
46-
end
47-
48-
def make_flags(*flags)
49-
# Disable i18n
50-
flags << 'i18nsupport=off'
51-
52-
# Solaris / Smart OS requires additional -G flag to use with -fPIC
53-
flags << "CFLAGS=-G" if @compiler.target =~ /solaris/
54-
55-
# Disable werror as this version of v8 is getting difficult to maintain
56-
# with it on
57-
flags << 'werror=no'
58-
59-
# Append GYP variable definitions
60-
flags << gyp_defines
61-
62-
# Append manually specified MAKEFLAGS
63-
flags << ENV['MAKEFLAGS'] if ENV['MAKEFLAGS']
64-
ENV['MAKEFLAGS'] = nil
65-
66-
"#{make_target} #{flags.join ' '}"
67-
end
68-
6921
def build_libv8!
7022
setup_python!
7123
setup_build_deps!
7224
Dir.chdir(File.expand_path('../../../vendor/v8', __FILE__)) do
73-
fail 'No compilers available' if @compiler.nil?
74-
patch!
75-
print_build_info
7625
puts 'Beginning compilation. This will take some time.'
26+
generate_gn_args
7727

78-
command = "env CXX=#{Shellwords.escape @compiler.to_s} #{make} #{make_flags}"
79-
puts "Building v8 with #{command}"
80-
system command
28+
system 'ninja -v -C out.gn/libv8 v8_monolith'
8129
end
8230
return $?.exitstatus
8331
end
@@ -112,56 +60,30 @@ def source_version
11260
#
11361
def setup_build_deps!
11462
ENV['PATH'] = "#{File.expand_path('../../../vendor/depot_tools', __FILE__)}:#{ENV['PATH']}"
63+
11564
Dir.chdir(File.expand_path('../../../vendor', __FILE__)) do
116-
unless Dir.exists? 'v8'
117-
system "env #{gyp_defines} fetch v8" or fail "unable to fetch v8 source"
118-
else
119-
system "env #{gyp_defines} gclient fetch" or fail "could not fetch v8 build dependencies commits"
65+
unless Dir.exists?('v8') || File.exists?('.gclient')
66+
system "fetch v8" or fail "unable to fetch v8 source"
12067
end
68+
12169
Dir.chdir('v8') do
70+
system 'git fetch origin'
12271
unless system "git checkout #{source_version}"
12372
fail "unable to checkout source for v8 #{source_version}"
12473
end
125-
system "env #{gyp_defines} gclient sync" or fail "could not sync v8 build dependencies"
126-
system "git checkout Makefile" # Work around a weird bug on FreeBSD
74+
system "gclient sync" or fail "could not sync v8 build dependencies"
12775
end
12876
end
12977
end
13078

13179
private
13280

133-
def choose_compiler
134-
compiler = if with_config('cxx') || ENV['CXX']
135-
with_config('cxx') || ENV['CXX']
136-
else
137-
begin
138-
MakeMakefile::CONFIG['CXX'] # stdlib > 2.0.0
139-
rescue NameError
140-
RbConfig::CONFIG['CXX'] # stdlib < 2.0.0
141-
end
142-
end
143-
144-
Libv8::Compiler.type_of(compiler).new compiler
145-
end
146-
14781
def python_version
14882
if system 'which python 2>&1 > /dev/null'
14983
`python -c 'import platform; print(platform.python_version())'`.chomp
15084
else
15185
"not available"
15286
end
15387
end
154-
155-
def print_build_info
156-
puts "Compiling v8 for #{libv8_arch}"
157-
158-
puts "Using python #{python_version}"
159-
160-
puts "Using compiler: #{@compiler} (#{@compiler.name} version #{@compiler.version})"
161-
unless @compiler.compatible?
162-
warn "Unable to find a compiler officially supported by v8."
163-
warn "It is recommended to use clang v3.5 or GCC v4.8 or higher"
164-
end
165-
end
16688
end
16789
end

vendor/depot_tools

Submodule depot_tools updated from 47d7464 to a28b14f

0 commit comments

Comments
 (0)