Skip to content

Commit 642d5c5

Browse files
zcbenzmarco-ippolito
authored andcommitted
tools: use v8_features.json to populate config.gypi
PR-URL: #53749 Reviewed-By: Luigi Pinca <[email protected]>
1 parent 2eea850 commit 642d5c5

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

tools/generate_config_gypi.py

+6-31
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# will be used to populate process.config.variables.
99

1010
import argparse
11+
import json
1112
import re
1213
import os
1314
import subprocess
@@ -16,26 +17,6 @@
1617
sys.path.append(os.path.dirname(__file__))
1718
import getnapibuildversion
1819

19-
# The defines bellow must include all things from the external_v8_defines list
20-
# in v8/BUILD.gn.
21-
# TODO(zcbenz): Import from v8_features.json once this change gets into Node:
22-
# https://chromium-review.googlesource.com/c/v8/v8/+/5040612
23-
V8_FEATURE_DEFINES = {
24-
'v8_enable_v8_checks': 'V8_ENABLE_CHECKS',
25-
'v8_enable_pointer_compression': 'V8_COMPRESS_POINTERS',
26-
'v8_enable_pointer_compression_shared_cage': 'V8_COMPRESS_POINTERS_IN_SHARED_CAGE',
27-
'v8_enable_31bit_smis_on_64bit_arch': 'V8_31BIT_SMIS_ON_64BIT_ARCH',
28-
'v8_enable_zone_compression': 'V8_COMPRESS_ZONES',
29-
'v8_enable_sandbox': 'V8_ENABLE_SANDBOX',
30-
'v8_deprecation_warnings': 'V8_DEPRECATION_WARNINGS',
31-
'v8_imminent_deprecation_warnings': 'V8_IMMINENT_DEPRECATION_WARNINGS',
32-
'v8_use_perfetto': 'V8_USE_PERFETTO',
33-
'v8_enable_map_packing': 'V8_MAP_PACKING',
34-
'tsan': 'V8_IS_TSAN',
35-
'v8_enable_conservative_stack_scanning': 'V8_ENABLE_CONSERVATIVE_STACK_SCANNING',
36-
'v8_enable_direct_local': 'V8_ENABLE_DIRECT_LOCAL',
37-
}
38-
3920
# Regex used for parsing results of "gn args".
4021
GN_RE = re.compile(r'(\w+)\s+=\s+(.*?)$', re.MULTILINE)
4122

@@ -60,15 +41,11 @@ def get_gn_config(out_dir):
6041
return config
6142

6243
def get_v8_config(out_dir, node_gn_path):
63-
# For args that have default values in V8's GN configurations, we can not rely
64-
# on the values printed by "gn args", because most of them would be empty
65-
# strings, and the actual value would depend on the logics in v8/BUILD.gn.
66-
# So we print out the defines and deduce the feature from them instead.
67-
node_defines = subprocess.check_output(
68-
[GN, 'desc', '-C', out_dir, node_gn_path + ":libnode", 'defines']).decode().split('\n')
69-
v8_config = {}
70-
for feature, define in V8_FEATURE_DEFINES.items():
71-
v8_config[feature] = bool_to_number(define in node_defines)
44+
with open(os.path.join(out_dir, 'v8_features.json')) as f:
45+
v8_config = json.load(f)
46+
for key, value in v8_config.items():
47+
if isinstance(value, bool):
48+
v8_config[key] = bool_to_number(value)
7249
return v8_config
7350

7451
def translate_config(out_dir, config, v8_config):
@@ -90,8 +67,6 @@ def translate_config(out_dir, config, v8_config):
9067
'node_use_openssl': config['node_use_openssl'],
9168
'node_use_node_code_cache': config['node_use_node_code_cache'],
9269
'node_use_node_snapshot': config['node_use_node_snapshot'],
93-
'v8_enable_i18n_support':
94-
bool_string_to_number(config['v8_enable_i18n_support']),
9570
'v8_enable_inspector': # this is actually a node misnomer
9671
bool_string_to_number(config['node_enable_inspector']),
9772
'shlib_suffix': 'dylib' if sys.platform == 'darwin' else 'so',

unofficial.gni

+1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ template("node_gn_build") {
261261
}
262262

263263
action("generate_config_gypi") {
264+
deps = [ "$node_v8_path:v8_generate_features_json" ]
264265
script = "tools/generate_config_gypi.py"
265266
outputs = [ "$target_gen_dir/config.gypi" ]
266267
depfile = "$target_gen_dir/$target_name.d"

0 commit comments

Comments
 (0)