Bug 1412267 - Fix the inclusion of MOZ_DEBUG_FLAGS in the compile command line to depend on MOZ_DEBUG_SYMBOLS and MOZ_DEBUG.
MozReview-Commit-ID: 4MgzRQCX5iW
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -330,18 +330,17 @@ class CompileFlags(ContextDerivedValue,
('OS_COMPILE_CXXFLAGS', context.config.substs.get('OS_COMPILE_CXXFLAGS'),
('CXXFLAGS',)),
('OS_CPPFLAGS', context.config.substs.get('OS_CPPFLAGS'),
('CXXFLAGS', 'CFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('OS_CFLAGS', context.config.substs.get('OS_CFLAGS'),
('CFLAGS', 'C_LDFLAGS')),
('OS_CXXFLAGS', context.config.substs.get('OS_CXXFLAGS'),
('CXXFLAGS', 'CXX_LDFLAGS')),
- ('DEBUG', (context.config.substs['MOZ_DEBUG_FLAGS'].split() if
- 'MOZ_DEBUG_FLAGS' in context.config.substs else []),
+ ('DEBUG', self._debug_flags(),
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('CLANG_PLUGIN', context.config.substs.get('CLANG_PLUGIN_FLAGS'),
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('OPTIMIZE', self._optimize_flags(),
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('FRAMEPTR', context.config.substs.get('MOZ_FRAMEPTR_FLAGS'),
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('WARNINGS_AS_ERRORS', self._warnings_as_errors(),
@@ -355,16 +354,22 @@ class CompileFlags(ContextDerivedValue,
# a template were set and which were provided as defaults.
template_name = getattr(context, 'template', None)
if template_name in (None, 'Gyp'):
dict.__init__(self, ((k, v if v is None else TypedList(unicode)(v))
for k, v, _ in self.flag_variables))
else:
dict.__init__(self)
+ def _debug_flags(self):
+ if (self._context.config.substs.get('MOZ_DEBUG') or
+ self._context.config.substs.get('MOZ_DEBUG_SYMBOLS')):
+ return self._context.config.substs.get('MOZ_DEBUG_FLAGS', '').split()
+ return []
+
def _warnings_as_errors(self):
warnings_as_errors = self._context.config.substs.get('WARNINGS_AS_ERRORS')
if self._context.config.substs.get('MOZ_PGO'):
# Don't use warnings-as-errors in Windows PGO builds because it is suspected of
# causing problems in that situation. (See bug 437002.)
if self._context.config.substs['OS_ARCH'] == 'WINNT':
warnings_as_errors = None
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -209,16 +209,34 @@ class TestEmitterBasic(unittest.TestCase
'WARNINGS_AS_ERRORS': '-Werror',
})
sources, lib, flags = self.read_topsrcdir(reader)
self.assertIsInstance(flags, ComputedFlags)
self.assertEqual(flags.flags['STL'], reader.config.substs['STL_FLAGS'])
self.assertEqual(flags.flags['VISIBILITY'], reader.config.substs['VISIBILITY_FLAGS'])
self.assertEqual(flags.flags['WARNINGS_AS_ERRORS'], ['-Werror'])
+ def test_debug_flags(self):
+ reader = self.reader('compile-flags', extra_substs={
+ 'MOZ_DEBUG_FLAGS': '-g',
+ 'MOZ_DEBUG_SYMBOLS': '1',
+ })
+ sources, lib, flags = self.read_topsrcdir(reader)
+ self.assertIsInstance(flags, ComputedFlags)
+ self.assertEqual(flags.flags['DEBUG'], ['-g'])
+
+ def test_disable_debug_flags(self):
+ reader = self.reader('compile-flags', extra_substs={
+ 'MOZ_DEBUG_FLAGS': '-g',
+ 'MOZ_DEBUG_SYMBOLS': '',
+ })
+ sources, lib, flags = self.read_topsrcdir(reader)
+ self.assertIsInstance(flags, ComputedFlags)
+ self.assertEqual(flags.flags['DEBUG'], [])
+
def test_compile_flags_validation(self):
reader = self.reader('compile-flags-field-validation')
with self.assertRaisesRegexp(BuildReaderError, 'Invalid value.'):
self.read_topsrcdir(reader)
reader = self.reader('compile-flags-type-validation')
with self.assertRaisesRegexp(BuildReaderError,