88# will be used to populate process.config.variables.
99
1010import argparse
11+ import json
1112import re
1213import os
1314import subprocess
1617sys .path .append (os .path .dirname (__file__ ))
1718import 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".
4021GN_RE = re .compile (r'(\w+)\s+=\s+(.*?)$' , re .MULTILINE )
4122
@@ -60,15 +41,11 @@ def get_gn_config(out_dir):
6041 return config
6142
6243def 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
7451def 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' ,
0 commit comments