Skip to content

Commit

Permalink
Bug 973144 - Support DEFINES['FOO']=False in moz.build for -UFOO. r=gps
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Feb 25, 2014
1 parent 982c234 commit 4009b42
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions python/mozbuild/mozbuild/frontend/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ def __init__(self, sandbox, 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.
Expand Down
3 changes: 2 additions & 1 deletion python/mozbuild/mozbuild/test/backend/data/defines/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ DEFINES = {
DEFINES['BAZ'] = '"ab\'cd"'
DEFINES.update({
'BAR': 7,
'VALUE': value
'VALUE': value,
'QUX': False,
})
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def test_defines(self):
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ DEFINES = {
DEFINES['BAZ'] = '"abcd"'
DEFINES.update({
'BAR': 7,
'VALUE': value
'VALUE': value,
'QUX': False,
})
1 change: 1 addition & 0 deletions python/mozbuild/mozbuild/test/frontend/test_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ def test_defines(self):
'BAZ': '"abcd"',
'FOO': True,
'VALUE': 'xyz',
'QUX': False,
}

self.assertEqual(defines, expected)
Expand Down

0 comments on commit 4009b42

Please sign in to comment.