Bug 1411787 - Convert MOZBUILD_CFLAGS from passthru variables to computed flags. r=mshal

MozReview-Commit-ID: HOMf4vfFE1n

--HG--
extra : rebase_source : fad33710a5f374f070b4c972c303a6b2ece25758
This commit is contained in:
Chris Manchester 2017-10-27 10:38:10 -07:00
parent 3d94d8e8e1
commit bd83adf337
9 changed files with 18 additions and 23 deletions

View File

@ -267,8 +267,8 @@ HOST_CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
endif # MOZ_OPTIMIZE
endif # CROSS_COMPILE
COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(PGO_CFLAGS) $(MOZBUILD_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(PGO_CFLAGS) $(MOZBUILD_CXXFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS)
COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS)
ASFLAGS += $(MOZBUILD_ASFLAGS)

View File

@ -71,8 +71,7 @@ class CompileDBBackend(CommonBackend):
obj.canonical_suffix)
elif isinstance(obj, VariablePassthru):
for var in ('MOZBUILD_CFLAGS', 'MOZBUILD_CXXFLAGS',
'MOZBUILD_CMFLAGS', 'MOZBUILD_CMMFLAGS'):
for var in ('MOZBUILD_CMFLAGS', 'MOZBUILD_CMMFLAGS'):
if var in obj.variables:
self._local_flags[obj.objdir][var] = obj.variables[var]
@ -187,7 +186,6 @@ class CompileDBBackend(CommonBackend):
db.extend(value)
db.append('$(COMPUTED_%s)' % self.CFLAGS[canonical_suffix])
db.append('$(MOZBUILD_%s)' % self.CFLAGS[canonical_suffix])
if canonical_suffix == '.m':
append_var('OS_COMPILE_CMFLAGS')
db.append('$(MOZBUILD_CMFLAGS)')

View File

@ -345,6 +345,8 @@ class CompileFlags(ContextDerivedValue, dict):
('CFLAGS', 'CXXFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('WARNINGS_AS_ERRORS', self._warnings_as_errors(),
('CXXFLAGS', 'CFLAGS', 'CXX_LDFLAGS', 'C_LDFLAGS')),
('MOZBUILD_CFLAGS', None, ('CFLAGS',)),
('MOZBUILD_CXXFLAGS', None, ('CXXFLAGS',)),
)
self._known_keys = set(k for k, v, _ in self.flag_variables)

View File

@ -917,6 +917,8 @@ class TreeMetadataEmitter(LoggingMixin):
for obj in self._process_xpidl(context):
yield obj
computed_flags = ComputedFlags(context, context['COMPILE_FLAGS'])
# Proxy some variables as-is until we have richer classes to represent
# them. We should aim to keep this set small because it violates the
# desired abstraction of the build definition away from makefiles.
@ -946,19 +948,21 @@ class TreeMetadataEmitter(LoggingMixin):
for dll in context['DELAYLOAD_DLLS']])
context['OS_LIBS'].append('delayimp')
for v in ['CFLAGS', 'CXXFLAGS', 'CMFLAGS', 'CMMFLAGS', 'ASFLAGS',
'LDFLAGS', 'HOST_CFLAGS', 'HOST_CXXFLAGS']:
for v in ['CMFLAGS', 'CMMFLAGS', 'ASFLAGS', 'LDFLAGS',
'HOST_CFLAGS', 'HOST_CXXFLAGS']:
if v in context and context[v]:
passthru.variables['MOZBUILD_' + v] = context[v]
for v in ['CXXFLAGS', 'CFLAGS']:
if v in context and context[v]:
computed_flags.resolve_flags('MOZBUILD_%s' % v, context[v])
dist_install = context['DIST_INSTALL']
if dist_install is True:
passthru.variables['DIST_INSTALL'] = True
elif dist_install is False:
passthru.variables['NO_DIST_INSTALL'] = True
computed_flags = ComputedFlags(context, context['COMPILE_FLAGS'])
# Ideally, this should be done in templates, but this is difficult at
# the moment because USE_STATIC_LIBS can be set after a template
# returns. Eventually, with context-based templates, it will be

View File

@ -9,8 +9,6 @@ RESFILE = 'bar.res'
RCINCLUDE = 'bar.rc'
DEFFILE = 'baz.def'
CFLAGS += ['-fno-exceptions', '-w']
CXXFLAGS += ['-fcxx-exceptions', '-option with spaces']
LDFLAGS += ['-ld flag with spaces', '-x']
HOST_CFLAGS += ['-funroll-loops', '-wall']
HOST_CXXFLAGS += ['-funroll-loops-harder', '-wall-day-everyday']

View File

@ -328,14 +328,6 @@ class TestRecursiveMakeBackend(BackendTester):
'DEFFILE': [
'DEFFILE := baz.def',
],
'MOZBUILD_CFLAGS': [
'MOZBUILD_CFLAGS += -fno-exceptions',
'MOZBUILD_CFLAGS += -w',
],
'MOZBUILD_CXXFLAGS': [
'MOZBUILD_CXXFLAGS += -fcxx-exceptions',
"MOZBUILD_CXXFLAGS += '-option with spaces'",
],
'MOZBUILD_LDFLAGS': [
"MOZBUILD_LDFLAGS += '-ld flag with spaces'",
'MOZBUILD_LDFLAGS += -x',

View File

@ -13,3 +13,6 @@ def DisableStlWrapping():
COMPILE_FLAGS['STL'] = []
UNIFIED_SOURCES += ['test1.c']
CXXFLAGS += ['-funroll-loops', '-Wall']
CFLAGS += ['-Wall', '-funroll-loops']

View File

@ -11,8 +11,6 @@ RESFILE = 'bar.res'
RCINCLUDE = 'bar.rc'
DEFFILE = 'baz.def'
CFLAGS += ['-fno-exceptions', '-w']
CXXFLAGS += ['-fcxx-exceptions', '-include foo.h']
LDFLAGS += ['-framework Foo', '-x']
HOST_CFLAGS += ['-funroll-loops', '-wall']
HOST_CXXFLAGS += ['-funroll-loops-harder', '-wall-day-everyday']

View File

@ -188,8 +188,6 @@ class TestEmitterBasic(unittest.TestCase):
'RESFILE': 'bar.res',
'RCINCLUDE': 'bar.rc',
'DEFFILE': 'baz.def',
'MOZBUILD_CFLAGS': ['-fno-exceptions', '-w'],
'MOZBUILD_CXXFLAGS': ['-fcxx-exceptions', '-include foo.h'],
'MOZBUILD_LDFLAGS': ['-framework Foo', '-x', '-DELAYLOAD:foo.dll',
'-DELAYLOAD:bar.dll'],
'MOZBUILD_HOST_CFLAGS': ['-funroll-loops', '-wall'],
@ -213,6 +211,8 @@ class TestEmitterBasic(unittest.TestCase):
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'])
self.assertEqual(flags.flags['MOZBUILD_CFLAGS'], ['-Wall', '-funroll-loops'])
self.assertEqual(flags.flags['MOZBUILD_CXXFLAGS'], ['-funroll-loops', '-Wall'])
def test_debug_flags(self):
reader = self.reader('compile-flags', extra_substs={