@@ -1440,8 +1440,8 @@ def host_arch_win():
14401440 return matchup .get (arch , 'x64' )
14411441
14421442def set_configuration_variable (configs , name , release = None , debug = None ):
1443- configs ['Release' ][name ] = release
1444- configs ['Debug' ][name ] = debug
1443+ configs ['Release' ]['variables' ][ name ] = release
1444+ configs ['Debug' ]['variables' ][ name ] = debug
14451445
14461446def configure_arm (o ):
14471447 if options .arm_float_abi :
@@ -1522,6 +1522,7 @@ def configure_node(o):
15221522 o ['variables' ]['control_flow_guard' ] = b (options .enable_cfg )
15231523 o ['variables' ]['node_use_amaro' ] = b (not options .without_amaro )
15241524 o ['variables' ]['debug_node' ] = b (options .debug_node )
1525+ o ['variables' ]['build_type%' ] = 'Debug' if options .debug else 'Release'
15251526 o ['default_configuration' ] = 'Debug' if options .debug else 'Release'
15261527 if options .error_on_warn and options .suppress_all_error_on_warn :
15271528 raise Exception ('--error_on_warn is incompatible with --suppress_all_error_on_warn.' )
@@ -1772,6 +1773,11 @@ def configure_library(lib, output, pkgname=None):
17721773 output ['libraries' ] += pkg_libs .split ()
17731774
17741775
1776+ def configure_rust (o , configs ):
1777+ set_configuration_variable (configs , 'cargo_build_mode' , release = 'release' , debug = 'debug' )
1778+ set_configuration_variable (configs , 'cargo_build_flags' , release = ['--release' ], debug = [])
1779+
1780+
17751781def configure_v8 (o , configs ):
17761782 set_configuration_variable (configs , 'v8_enable_v8_checks' , release = 1 , debug = 0 )
17771783
@@ -2325,6 +2331,7 @@ def make_bin_override():
23252331 'libraries' : [],
23262332 'defines' : [],
23272333 'cflags' : [],
2334+ 'conditions' : [],
23282335}
23292336configurations = {
23302337 'Release' : { 'variables' : {} },
@@ -2365,6 +2372,7 @@ def make_bin_override():
23652372configure_static (output )
23662373configure_inspector (output )
23672374configure_section_file (output )
2375+ configure_rust (output , configurations )
23682376
23692377# remove builtins that have been disabled
23702378if options .without_amaro :
@@ -2387,6 +2395,17 @@ def make_bin_override():
23872395variables = output ['variables' ]
23882396del output ['variables' ]
23892397
2398+ # move configurations[*]['variables'] to conditions variables
2399+ config_release_vars = configurations ['Release' ]['variables' ]
2400+ del configurations ['Release' ]['variables' ]
2401+ config_debug_vars = configurations ['Debug' ]['variables' ]
2402+ del configurations ['Debug' ]['variables' ]
2403+ output ['conditions' ].append (['build_type=="Release"' , {
2404+ 'variables' : config_release_vars ,
2405+ }, {
2406+ 'variables' : config_debug_vars ,
2407+ }])
2408+
23902409# make_global_settings should be a root level element too
23912410if 'make_global_settings' in output :
23922411 make_global_settings = output ['make_global_settings' ]
@@ -2406,8 +2425,9 @@ def make_bin_override():
24062425
24072426print_verbose (output )
24082427
2428+ # Dump as JSON to allow js2c.cc read it as a simple json file.
24092429write ('config.gypi' , do_not_edit +
2410- pprint . pformat (output , indent = 2 , width = 128 ) + '\n ' )
2430+ json . dumps (output , indent = 2 ) + '\n ' )
24112431
24122432write ('config.status' , '#!/bin/sh\n set -x\n exec ./configure ' +
24132433 ' ' .join ([shlex .quote (arg ) for arg in original_argv ]) + '\n ' )
0 commit comments