Bug 1369433 - Fix gyp_reader to take mozilla_cflags in to account when CFLAGS et al are set via sandbox_vars. draft
authorChris Manchester <cmanchester@mozilla.com>
Fri, 02 Jun 2017 13:14:47 -0700
changeset 588450 e94ba15e95b023b0ecda69e8f2554db6ea20e9bf
parent 587839 0e9853e31da9848ab638bdd0df4eb734a5ebc232
child 631575 c29e09ed299eb966a36ef5c485bc485030509735
push id62040
push userbmo:cmanchester@mozilla.com
push dateFri, 02 Jun 2017 20:14:55 +0000
bugs1369433
milestone55.0a1
Bug 1369433 - Fix gyp_reader to take mozilla_cflags in to account when CFLAGS et al are set via sandbox_vars. Prior to this patch setting sandbox_vars['CFLAGS'] would cause those to override any variables set by gyp via cflags_mozilla. In general sanbox_vars are used to override values, and there's room for a clearer interaction between moz.build and gyp, but discarding cflags set in cflags_mozilla is almost certainly not the intended behavior here, and this solves the immediate issue. MozReview-Commit-ID: 1uCgXr5lagA
python/mozbuild/mozbuild/frontend/gyp_reader.py
--- a/python/mozbuild/mozbuild/frontend/gyp_reader.py
+++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py
@@ -321,17 +321,25 @@ def process_gyp_result(gyp_result, gyp_d
               '/ipc/glue',
           ]
           # These get set via VC project file settings for normal GYP builds.
           if config.substs['OS_TARGET'] == 'WINNT':
               context['DEFINES']['UNICODE'] = True
               context['DEFINES']['_UNICODE'] = True
         context['DISABLE_STL_WRAPPING'] = True
 
-        context.update(gyp_dir_attrs.sandbox_vars)
+        for key, value in gyp_dir_attrs.sandbox_vars.items():
+            if context.get(key) and isinstance(context[key], list):
+                # If we have a key from sanbox_vars that's also been
+                # populated here we use the value from sandbox_vars as our
+                # basis rather than overriding outright.
+                context[key] = value + context[key]
+            else:
+                context[key] = value
+
         yield context
 
 
 # A version of gyp.Load that doesn't return the generator (because module objects
 # aren't Pickle-able, and we don't use it anyway).
 def load_gyp(*args):
     _, flat_list, targets, data = gyp.Load(*args)
     return flat_list, targets, data