Bug 1258618 - Serialize substs/configs and defines bools as '1' or '' in config.status draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 22 Mar 2016 14:03:26 +0900
changeset 343314 3b68ecbe4a329c916c5d570a769cf3c6b94d5e5a
parent 343296 eaa14a9edf6da986b5ea4891b831107358d1c470
child 343315 bb47ba6dcee7b21c643c2a5e39dcdd28540399ef
push id13583
push userbmo:mh+mozilla@glandium.org
push dateTue, 22 Mar 2016 07:55:21 +0000
bugs1258618
milestone48.0a1
Bug 1258618 - Serialize substs/configs and defines bools as '1' or '' in config.status This allows to use True and False as values given to set_config/set_define in moz.configure files, while postponing having to deal with the long tail of things depending on the values from substs and defines. Ideally, everything would handle the bools just fine, but there are too many things involved to deal with this right now: scripts using buildconfig.{substs,defines}, scripts using ConfigEnvironment (e.g. process_define_files.py), ConfigEnvironment itself, etc.
configure.py
--- a/configure.py
+++ b/configure.py
@@ -24,22 +24,34 @@ def main(argv):
     if sandbox._help:
         return 0
 
     return config_status(config)
 
 
 def config_status(config):
     # Sanitize config data to feed config.status
+    # Ideally, all the backend and frontend code would handle the booleans, but
+    # there are so many things involved, that it's easier to keep config.status
+    # untouched for now.
+    def sanitized_bool(v):
+        if v is True:
+            return '1'
+        if v is False:
+            return ''
+        return v
+
     sanitized_config = {}
     sanitized_config['substs'] = {
-        k: v for k, v in config.iteritems()
+        k: sanitized_bool(v) for k, v in config.iteritems()
         if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR')
     }
-    sanitized_config['defines'] = config['DEFINES']
+    sanitized_config['defines'] = {
+        k: sanitized_bool(v) for k, v in config['DEFINES'].iteritems()
+    }
     sanitized_config['non_global_defines'] = config['non_global_defines']
     sanitized_config['topsrcdir'] = config['TOPSRCDIR']
     sanitized_config['topobjdir'] = config['TOPOBJDIR']
 
     # Create config.status. Eventually, we'll want to just do the work it does
     # here, when we're able to skip configure tests/use cached results/not rely
     # on autoconf.
     print("Creating config.status", file=sys.stderr)