@@ -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 :
@@ -1772,6 +1772,11 @@ def configure_library(lib, output, pkgname=None):
17721772 output ['libraries' ] += pkg_libs .split ()
17731773
17741774
1775+ def configure_rust (o , configs ):
1776+ set_configuration_variable (configs , 'cargo_build_mode' , release = 'release' , debug = 'debug' )
1777+ set_configuration_variable (configs , 'cargo_build_flags' , release = ['--release' ], debug = [])
1778+
1779+
17751780def configure_v8 (o , configs ):
17761781 set_configuration_variable (configs , 'v8_enable_v8_checks' , release = 1 , debug = 0 )
17771782
@@ -2325,6 +2330,7 @@ def make_bin_override():
23252330 'libraries' : [],
23262331 'defines' : [],
23272332 'cflags' : [],
2333+ 'conditions' : [],
23282334}
23292335configurations = {
23302336 'Release' : { 'variables' : {} },
@@ -2365,6 +2371,7 @@ def make_bin_override():
23652371configure_static (output )
23662372configure_inspector (output )
23672373configure_section_file (output )
2374+ configure_rust (output , configurations )
23682375
23692376# remove builtins that have been disabled
23702377if options .without_amaro :
@@ -2387,6 +2394,17 @@ def make_bin_override():
23872394variables = output ['variables' ]
23882395del output ['variables' ]
23892396
2397+ # move configurations[*]['variables'] to conditions variables
2398+ config_release_vars = configurations ['Release' ]['variables' ]
2399+ del configurations ['Release' ]['variables' ]
2400+ config_debug_vars = configurations ['Debug' ]['variables' ]
2401+ del configurations ['Debug' ]['variables' ]
2402+ output ['conditions' ].append (['build_type=="Release"' , {
2403+ 'variables' : config_release_vars ,
2404+ }, {
2405+ 'variables' : config_debug_vars ,
2406+ }])
2407+
23902408# make_global_settings should be a root level element too
23912409if 'make_global_settings' in output :
23922410 make_global_settings = output ['make_global_settings' ]
@@ -2406,8 +2424,9 @@ def make_bin_override():
24062424
24072425print_verbose (output )
24082426
2427+ # Dump as JSON to allow js2c.cc read it as a simple json file.
24092428write ('config.gypi' , do_not_edit +
2410- pprint . pformat (output , indent = 2 , width = 128 ) + '\n ' )
2429+ json . dumps (output , indent = 2 ) + '\n ' )
24112430
24122431write ('config.status' , '#!/bin/sh\n set -x\n exec ./configure ' +
24132432 ' ' .join ([shlex .quote (arg ) for arg in original_argv ]) + '\n ' )
0 commit comments