mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1386876
- Move visibility flag handling to computed compile flags with templates. r=glandium
MozReview-Commit-ID: 9hwiCQv8WKU --HG-- extra : rebase_source : cc7593fd06949a432dd056194ff19c1ac0daf4e4
This commit is contained in:
parent
c0a229d4c3
commit
26d4e4810c
@ -150,6 +150,10 @@ def HostRustLibrary(name, features=None):
|
||||
def DisableStlWrapping():
|
||||
COMPILE_FLAGS['STL'] = []
|
||||
|
||||
@template
|
||||
def NoVisibilityFlags():
|
||||
COMPILE_FLAGS['VISIBILITY'] = []
|
||||
|
||||
|
||||
include('gecko_templates.mozbuild')
|
||||
include('test_templates.mozbuild')
|
||||
|
@ -328,8 +328,8 @@ CXXFLAGS += $(WARNINGS_AS_ERRORS)
|
||||
CFLAGS += $(WARNINGS_AS_ERRORS)
|
||||
endif # ALLOW_COMPILER_WARNINGS
|
||||
|
||||
COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES)
|
||||
COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS) $(_DEPEND_CFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(MK_COMPILE_DEFINES)
|
||||
COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES)
|
||||
COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS) $(_DEPEND_CFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(MK_COMPILE_DEFINES)
|
||||
COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS)
|
||||
COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS)
|
||||
ASFLAGS += $(MOZBUILD_ASFLAGS)
|
||||
|
@ -71,7 +71,7 @@ class CompileDBBackend(CommonBackend):
|
||||
|
||||
if isinstance(obj, DirectoryTraversal):
|
||||
self._envs[obj.objdir] = obj.config
|
||||
for var in ('VISIBILITY_FLAGS', 'WARNINGS_AS_ERRORS'):
|
||||
for var in ('WARNINGS_AS_ERRORS',):
|
||||
value = obj.config.substs.get(var)
|
||||
if value:
|
||||
self._local_flags[obj.objdir][var] = value
|
||||
@ -103,7 +103,7 @@ class CompileDBBackend(CommonBackend):
|
||||
self._gyp_dirs.add(obj.objdir)
|
||||
for var in ('MOZBUILD_CFLAGS', 'MOZBUILD_CXXFLAGS',
|
||||
'MOZBUILD_CMFLAGS', 'MOZBUILD_CMMFLAGS',
|
||||
'RTL_FLAGS', 'VISIBILITY_FLAGS'):
|
||||
'RTL_FLAGS'):
|
||||
if var in obj.variables:
|
||||
self._local_flags[obj.objdir][var] = obj.variables[var]
|
||||
if (obj.variables.get('ALLOW_COMPILER_WARNINGS') and
|
||||
@ -236,11 +236,9 @@ class CompileDBBackend(CommonBackend):
|
||||
value = value.split()
|
||||
db.extend(value)
|
||||
|
||||
if canonical_suffix in ('.mm', '.cpp'):
|
||||
db.append('$(COMPUTED_CXXFLAGS)')
|
||||
db.append('$(COMPUTED_%s)' % self.CFLAGS[canonical_suffix])
|
||||
|
||||
db.extend((
|
||||
'$(VISIBILITY_FLAGS)',
|
||||
'$(DEFINES)',
|
||||
'-I%s' % mozpath.join(cenv.topsrcdir, reldir),
|
||||
'-I%s' % objdir,
|
||||
|
@ -301,6 +301,8 @@ class CompileFlags(ContextDerivedValue, dict):
|
||||
def __init__(self, context):
|
||||
self.flag_variables = (
|
||||
('STL', context.config.substs.get('STL_FLAGS'), ('CXXFLAGS',)),
|
||||
('VISIBILITY', context.config.substs.get('VISIBILITY_FLAGS'),
|
||||
('CXXFLAGS', 'CFLAGS')),
|
||||
)
|
||||
self._known_keys = set(k for k, v, _ in self.flag_variables)
|
||||
|
||||
|
@ -935,10 +935,6 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
if v in context and context[v]:
|
||||
passthru.variables['MOZBUILD_' + v] = context[v]
|
||||
|
||||
# NO_VISIBILITY_FLAGS is slightly different
|
||||
if context['NO_VISIBILITY_FLAGS']:
|
||||
passthru.variables['VISIBILITY_FLAGS'] = ''
|
||||
|
||||
if isinstance(context, TemplateContext) and context.template == 'Gyp':
|
||||
passthru.variables['IS_GYP_DIR'] = True
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
NO_VISIBILITY_FLAGS = True
|
||||
|
||||
DELAYLOAD_DLLS = ['foo.dll', 'bar.dll']
|
||||
|
||||
RCFILE = 'foo.rc'
|
||||
|
@ -319,9 +319,6 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
'ALLOW_COMPILER_WARNINGS': [
|
||||
'ALLOW_COMPILER_WARNINGS := 1',
|
||||
],
|
||||
'VISIBILITY_FLAGS': [
|
||||
'VISIBILITY_FLAGS :=',
|
||||
],
|
||||
'RCFILE': [
|
||||
'RCFILE := foo.rc',
|
||||
],
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
DIST_INSTALL = False
|
||||
|
||||
NO_VISIBILITY_FLAGS = True
|
||||
|
||||
DELAYLOAD_DLLS = ['foo.dll', 'bar.dll']
|
||||
|
||||
RCFILE = 'foo.rc'
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
@template
|
||||
def Library(name):
|
||||
'''Template for libraries.'''
|
||||
LIBRARY_NAME = name
|
||||
|
||||
Library('dummy')
|
||||
|
||||
@template
|
||||
def NoVisibilityFlags():
|
||||
COMPILE_FLAGS['VISIBILITY'] = []
|
||||
|
||||
UNIFIED_SOURCES += ['test1.c']
|
||||
|
||||
NoVisibilityFlags()
|
@ -77,6 +77,9 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
BIN_SUFFIX='.prog',
|
||||
OS_TARGET='WINNT',
|
||||
COMPILE_ENVIRONMENT='1',
|
||||
STL_FLAGS=['-I/path/to/topobjdir/dist/stl_wrappers'],
|
||||
VISIBILITY_FLAGS=['-include',
|
||||
'$(topsrcdir)/config/gcc_hidden.h'],
|
||||
)
|
||||
if extra_substs:
|
||||
substs.update(extra_substs)
|
||||
@ -182,7 +185,6 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
wanted = {
|
||||
'ALLOW_COMPILER_WARNINGS': True,
|
||||
'NO_DIST_INSTALL': True,
|
||||
'VISIBILITY_FLAGS': '',
|
||||
'RCFILE': 'foo.rc',
|
||||
'RESFILE': 'bar.res',
|
||||
'RCINCLUDE': 'bar.rc',
|
||||
@ -204,11 +206,11 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
self.maxDiff = maxDiff
|
||||
|
||||
def test_compile_flags(self):
|
||||
reader = self.reader('compile-flags',
|
||||
extra_substs={'STL_FLAGS': ['-I/path/to/objdir/dist/stl_wrappers']})
|
||||
reader = self.reader('compile-flags')
|
||||
sources, flags, lib = 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'])
|
||||
|
||||
def test_compile_flags_validation(self):
|
||||
reader = self.reader('compile-flags-field-validation')
|
||||
@ -221,14 +223,18 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
'A list of strings must be provided'):
|
||||
self.read_topsrcdir(reader)
|
||||
|
||||
|
||||
def test_disable_stl_wrapping(self):
|
||||
reader = self.reader('disable-stl-wrapping',
|
||||
extra_substs={'STL_FLAGS': ['-I/path/to/objdir/dist/stl_wrappers']})
|
||||
reader = self.reader('disable-stl-wrapping')
|
||||
sources, flags, lib = self.read_topsrcdir(reader)
|
||||
self.assertIsInstance(flags, ComputedFlags)
|
||||
self.assertEqual(flags.flags['STL'], [])
|
||||
|
||||
def test_visibility_flags(self):
|
||||
reader = self.reader('visibility-flags')
|
||||
sources, flags, lib = self.read_topsrcdir(reader)
|
||||
self.assertIsInstance(flags, ComputedFlags)
|
||||
self.assertEqual(flags.flags['VISIBILITY'], [])
|
||||
|
||||
def test_use_yasm(self):
|
||||
# When yasm is not available, this should raise.
|
||||
reader = self.reader('use-yasm')
|
||||
|
Loading…
Reference in New Issue
Block a user