build: add option to build v8 with GN

PR-URL: https://github.com/nodejs/node/pull/19201
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Yang Guo 2018-01-11 13:25:09 +01:00 committed by Myles Borins
parent dd49677096
commit 5c93b3b561
No known key found for this signature in database
GPG Key ID: 933B01F40B5CA946
3 changed files with 43 additions and 7 deletions

View File

@ -51,8 +51,8 @@
'obj_dir': '<(PRODUCT_DIR)/obj', 'obj_dir': '<(PRODUCT_DIR)/obj',
'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/libv8_base.a', 'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/libv8_base.a',
}, { }, {
'obj_dir%': '<(PRODUCT_DIR)/obj.target', 'obj_dir%': '<(PRODUCT_DIR)/obj.target',
'v8_base%': '<(PRODUCT_DIR)/obj.target/deps/v8/gypfiles/libv8_base.a', 'v8_base': '<(PRODUCT_DIR)/obj.target/deps/v8/gypfiles/libv8_base.a',
}], }],
['OS == "win"', { ['OS == "win"', {
'os_posix': 0, 'os_posix': 0,
@ -63,10 +63,19 @@
'os_posix': 1, 'os_posix': 1,
'v8_postmortem_support%': 'true', 'v8_postmortem_support%': 'true',
}], }],
['OS== "mac"', { ['OS == "mac"', {
'obj_dir%': '<(PRODUCT_DIR)/obj.target', 'obj_dir%': '<(PRODUCT_DIR)/obj.target',
'v8_base': '<(PRODUCT_DIR)/libv8_base.a', 'v8_base': '<(PRODUCT_DIR)/libv8_base.a',
}], }],
['build_v8_with_gn == "true"', {
'conditions': [
['GENERATOR == "ninja"', {
'v8_base': '<(PRODUCT_DIR)/obj/deps/v8/gypfiles/v8_monolith.gen/gn/obj/libv8_monolith.a',
}, {
'v8_base': '<(PRODUCT_DIR)/obji.target/v8_monolith/geni/gn/obj/libv8_monolith.a',
}],
],
}],
['openssl_fips != ""', { ['openssl_fips != ""', {
'openssl_product': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)', 'openssl_product': '<(STATIC_LIB_PREFIX)crypto<(STATIC_LIB_SUFFIX)',
}, { }, {

18
configure vendored
View File

@ -55,6 +55,10 @@ sys.path.insert(0, 'tools')
import getmoduleversion import getmoduleversion
from gyp_node import run_gyp from gyp_node import run_gyp
# imports in deps/v8/tools/node
sys.path.insert(0, os.path.join('deps', 'v8', 'tools', 'node'))
from fetch_deps import FetchDeps
# parse our options # parse our options
parser = optparse.OptionParser() parser = optparse.OptionParser()
@ -548,6 +552,12 @@ parser.add_option('--without-bundled-v8',
help='do not use V8 includes from the bundled deps folder. ' + help='do not use V8 includes from the bundled deps folder. ' +
'(This mode is not officially supported for regular applications)') '(This mode is not officially supported for regular applications)')
parser.add_option('--build-v8-with-gn',
action='store_true',
dest='build_v8_with_gn',
default=False,
help='build V8 using GN instead of gyp')
# Create compile_commands.json in out/Debug and out/Release. # Create compile_commands.json in out/Debug and out/Release.
parser.add_option('-C', parser.add_option('-C',
action='store_true', action='store_true',
@ -1060,6 +1070,14 @@ def configure_v8(o):
o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp. o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp.
if options.without_bundled_v8 and options.enable_d8: if options.without_bundled_v8 and options.enable_d8:
raise Exception('--enable-d8 is incompatible with --without-bundled-v8.') raise Exception('--enable-d8 is incompatible with --without-bundled-v8.')
if options.without_bundled_v8 and options.build_v8_with_gn:
raise Exception(
'--build-v8-with-gn is incompatible with --without-bundled-v8.')
if options.build_v8_with_gn:
v8_path = os.path.join('deps', 'v8')
print('Fetching dependencies to build V8 with GN')
options.build_v8_with_gn = FetchDeps(v8_path)
o['variables']['build_v8_with_gn'] = b(options.build_v8_with_gn)
def configure_openssl(o): def configure_openssl(o):

View File

@ -59,9 +59,15 @@
'dependencies': [ 'deps/v8/gypfiles/d8.gyp:d8' ], 'dependencies': [ 'deps/v8/gypfiles/d8.gyp:d8' ],
}], }],
[ 'node_use_bundled_v8=="true"', { [ 'node_use_bundled_v8=="true"', {
'dependencies': [ 'conditions': [
'deps/v8/gypfiles/v8.gyp:v8', [ 'build_v8_with_gn=="true"', {
'deps/v8/gypfiles/v8.gyp:v8_libplatform' 'dependencies': ['deps/v8/gypfiles/v8.gyp:v8_monolith'],
}, {
'dependencies': [
'deps/v8/gypfiles/v8.gyp:v8',
'deps/v8/gypfiles/v8.gyp:v8_libplatform',
],
}],
], ],
}], }],
[ 'node_use_v8_platform=="true"', { [ 'node_use_v8_platform=="true"', {
@ -111,7 +117,6 @@
'defines': [ 'NODE_NO_BROWSER_GLOBALS' ], 'defines': [ 'NODE_NO_BROWSER_GLOBALS' ],
} ], } ],
[ 'node_use_bundled_v8=="true" and v8_postmortem_support=="true"', { [ 'node_use_bundled_v8=="true" and v8_postmortem_support=="true"', {
'dependencies': [ 'deps/v8/gypfiles/v8.gyp:postmortem-metadata' ],
'conditions': [ 'conditions': [
# -force_load is not applicable for the static library # -force_load is not applicable for the static library
[ 'force_load=="true"', { [ 'force_load=="true"', {
@ -121,6 +126,10 @@
], ],
}, },
}], }],
# when building with GN, the v8_monolith target already includes postmortem metadata
[ 'build_v8_with_gn=="false"', {
'dependencies': [ 'deps/v8/gypfiles/v8.gyp:postmortem-metadata' ],
}],
], ],
}], }],
[ 'node_shared_zlib=="false"', { [ 'node_shared_zlib=="false"', {