Skip to content

Commit 36a02d4

Browse files
hashseedjasnell
authored andcommitted
build: add option to build v8 with GN
PR-URL: #19201 Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 608557a commit 36a02d4

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

common.gypi

+12-3
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
'obj_dir': '<(PRODUCT_DIR)/obj',
5252
'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/libv8_base.a',
5353
}, {
54-
'obj_dir%': '<(PRODUCT_DIR)/obj.target',
55-
'v8_base%': '<(PRODUCT_DIR)/obj.target/deps/v8/gypfiles/libv8_base.a',
54+
'obj_dir%': '<(PRODUCT_DIR)/obj.target',
55+
'v8_base': '<(PRODUCT_DIR)/obj.target/deps/v8/gypfiles/libv8_base.a',
5656
}],
5757
['OS == "win"', {
5858
'os_posix': 0,
@@ -63,10 +63,19 @@
6363
'os_posix': 1,
6464
'v8_postmortem_support%': 'true',
6565
}],
66-
['OS== "mac"', {
66+
['OS == "mac"', {
6767
'obj_dir%': '<(PRODUCT_DIR)/obj.target',
6868
'v8_base': '<(PRODUCT_DIR)/libv8_base.a',
6969
}],
70+
['build_v8_with_gn == "true"', {
71+
'conditions': [
72+
['GENERATOR == "ninja"', {
73+
'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/v8_monolith.gen/gn/obj/libv8_monolith.a',
74+
}, {
75+
'v8_base': '<(PRODUCT_DIR)/obji.target/v8_monolith/geni/gn/obj/libv8_monolith.a',
76+
}],
77+
],
78+
}],
7079
['openssl_fips != ""', {
7180
'openssl_product': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)',
7281
}, {

configure

+18
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ sys.path.insert(0, 'tools')
5555
import getmoduleversion
5656
from gyp_node import run_gyp
5757

58+
# imports in deps/v8/tools/node
59+
sys.path.insert(0, os.path.join('deps', 'v8', 'tools', 'node'))
60+
from fetch_deps import FetchDeps
61+
5862
# parse our options
5963
parser = optparse.OptionParser()
6064

@@ -548,6 +552,12 @@ parser.add_option('--without-bundled-v8',
548552
help='do not use V8 includes from the bundled deps folder. ' +
549553
'(This mode is not officially supported for regular applications)')
550554

555+
parser.add_option('--build-v8-with-gn',
556+
action='store_true',
557+
dest='build_v8_with_gn',
558+
default=False,
559+
help='build V8 using GN instead of gyp')
560+
551561
# Create compile_commands.json in out/Debug and out/Release.
552562
parser.add_option('-C',
553563
action='store_true',
@@ -1060,6 +1070,14 @@ def configure_v8(o):
10601070
o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp.
10611071
if options.without_bundled_v8 and options.enable_d8:
10621072
raise Exception('--enable-d8 is incompatible with --without-bundled-v8.')
1073+
if options.without_bundled_v8 and options.build_v8_with_gn:
1074+
raise Exception(
1075+
'--build-v8-with-gn is incompatible with --without-bundled-v8.')
1076+
if options.build_v8_with_gn:
1077+
v8_path = os.path.join('deps', 'v8')
1078+
print('Fetching dependencies to build V8 with GN')
1079+
options.build_v8_with_gn = FetchDeps(v8_path)
1080+
o['variables']['build_v8_with_gn'] = b(options.build_v8_with_gn)
10631081

10641082

10651083
def configure_openssl(o):

node.gypi

+13-4
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@
5959
'dependencies': [ 'deps/v8/gypfiles/d8.gyp:d8' ],
6060
}],
6161
[ 'node_use_bundled_v8=="true"', {
62-
'dependencies': [
63-
'deps/v8/gypfiles/v8.gyp:v8',
64-
'deps/v8/gypfiles/v8.gyp:v8_libplatform'
62+
'conditions': [
63+
[ 'build_v8_with_gn=="true"', {
64+
'dependencies': ['deps/v8/gypfiles/v8.gyp:v8_monolith'],
65+
}, {
66+
'dependencies': [
67+
'deps/v8/gypfiles/v8.gyp:v8',
68+
'deps/v8/gypfiles/v8.gyp:v8_libplatform',
69+
],
70+
}],
6571
],
6672
}],
6773
[ 'node_use_v8_platform=="true"', {
@@ -111,7 +117,6 @@
111117
'defines': [ 'NODE_NO_BROWSER_GLOBALS' ],
112118
} ],
113119
[ 'node_use_bundled_v8=="true" and v8_postmortem_support=="true"', {
114-
'dependencies': [ 'deps/v8/gypfiles/v8.gyp:postmortem-metadata' ],
115120
'conditions': [
116121
# -force_load is not applicable for the static library
117122
[ 'force_load=="true"', {
@@ -121,6 +126,10 @@
121126
],
122127
},
123128
}],
129+
# when building with GN, the v8_monolith target already includes postmortem metadata
130+
[ 'build_v8_with_gn=="false"', {
131+
'dependencies': [ 'deps/v8/gypfiles/v8.gyp:postmortem-metadata' ],
132+
}],
124133
],
125134
}],
126135
[ 'node_shared_zlib=="false"', {

0 commit comments

Comments
 (0)