Bug 973144 - Support DEFINES['FOO']=False in moz.build for -UFOO. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 25 Feb 2014 15:41:57 +0900
changeset 170680 eb02c9e3db0a961c57c689d1b84f0b5f1e703c27
parent 170679 dccc80373461374bc83e5e3595ec3e57a8c16023
child 170681 8cb85ffb2c15d3a37a059beab1aedaf8849c196c
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersgps
bugs973144
milestone30.0a1
Bug 973144 - Support DEFINES['FOO']=False in moz.build for -UFOO. r=gps
python/mozbuild/mozbuild/frontend/data.py
python/mozbuild/mozbuild/test/backend/data/defines/moz.build
python/mozbuild/mozbuild/test/backend/test_recursivemake.py
python/mozbuild/mozbuild/test/frontend/data/defines/moz.build
python/mozbuild/mozbuild/test/frontend/test_emitter.py
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -180,20 +180,21 @@ class Defines(SandboxDerived):
 
     def __init__(self, sandbox, defines):
         SandboxDerived.__init__(self, sandbox)
         self.defines = defines
 
     def get_defines(self):
         for define, value in self.defines.iteritems():
             if value is True:
-                defstr = define
+                yield('-D%s' % define)
+            elif value is False:
+                yield('-U%s' % define)
             else:
-                defstr = '%s=%s' % (define, shell_quote(value))
-            yield('-D%s' % defstr)
+                yield('-D%s=%s' % (define, shell_quote(value)))
 
 class Exports(SandboxDerived):
     """Sandbox container object for EXPORTS, which is a HierarchicalStringList.
 
     We need an object derived from SandboxDerived for use in the backend, so
     this object fills that role. It just has a reference to the underlying
     HierarchicalStringList, which is created when parsing EXPORTS.
     """
--- a/python/mozbuild/mozbuild/test/backend/data/defines/moz.build
+++ b/python/mozbuild/mozbuild/test/backend/data/defines/moz.build
@@ -4,10 +4,11 @@
 value = 'xyz'
 DEFINES = {
     'FOO': True,
 }
 
 DEFINES['BAZ'] = '"ab\'cd"'
 DEFINES.update({
     'BAR': 7,
-    'VALUE': value
+    'VALUE': value,
+    'QUX': False,
 })
--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
+++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
@@ -519,17 +519,17 @@ class TestRecursiveMakeBackend(BackendTe
         env = self._consume('defines', RecursiveMakeBackend)
 
         backend_path = mozpath.join(env.topobjdir, 'backend.mk')
         lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
 
         var = 'DEFINES'
         defines = [val for val in lines if val.startswith(var)]
 
-        expected = ['DEFINES += -DFOO -DBAZ=\'"ab\'\\\'\'cd"\' -DBAR=7 -DVALUE=\'xyz\'']
+        expected = ['DEFINES += -DFOO -DBAZ=\'"ab\'\\\'\'cd"\' -UQUX -DBAR=7 -DVALUE=\'xyz\'']
         self.assertEqual(defines, expected)
 
     def test_local_includes(self):
         """Test that LOCAL_INCLUDES are written to backend.mk correctly."""
         env = self._consume('local_includes', RecursiveMakeBackend)
 
         backend_path = mozpath.join(env.topobjdir, 'backend.mk')
         lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
--- a/python/mozbuild/mozbuild/test/frontend/data/defines/moz.build
+++ b/python/mozbuild/mozbuild/test/frontend/data/defines/moz.build
@@ -4,10 +4,11 @@
 value = 'xyz'
 DEFINES = {
     'FOO': True,
 }
 
 DEFINES['BAZ'] = '"abcd"'
 DEFINES.update({
     'BAR': 7,
-    'VALUE': value
+    'VALUE': value,
+    'QUX': False,
 })
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -527,16 +527,17 @@ class TestEmitterBasic(unittest.TestCase
             if isinstance(o, Defines):
                 defines = o.defines
 
         expected = {
             'BAR': 7,
             'BAZ': '"abcd"',
             'FOO': True,
             'VALUE': 'xyz',
+            'QUX': False,
         }
 
         self.assertEqual(defines, expected)
 
     def test_jar_manifests(self):
         reader = self.reader('jar-manifests')
         objs = self.read_topsrcdir(reader)