Bug 1398897 - Move os includes to computed flags. r=glandium

MozReview-Commit-ID: Ef1wu5fQo7M

--HG--
extra : rebase_source : b5f15b2da47e724790ffee0512b5477059ae1c3a
This commit is contained in:
Chris Manchester 2017-09-20 12:43:24 -07:00
Родитель 73a827ed43
Коммит 89a09e8d67
6 изменённых файлов: 23 добавлений и 38 удалений

Просмотреть файл

@ -253,18 +253,6 @@ INCLUDES = \
-I$(ABS_DIST)/include \
$(NULL)
ifndef IS_GYP_DIR
# NSPR_CFLAGS and NSS_CFLAGS must appear ahead of the other flags to avoid Linux
# builds wrongly picking up system NSPR/NSS header files.
OS_INCLUDES := \
$(NSPR_CFLAGS) $(NSS_CFLAGS) \
$(MOZ_JPEG_CFLAGS) \
$(MOZ_PNG_CFLAGS) \
$(MOZ_ZLIB_CFLAGS) \
$(MOZ_PIXMAN_CFLAGS) \
$(NULL)
endif
include $(MOZILLA_DIR)/config/static-checking-config.mk
CFLAGS = $(OS_CPPFLAGS) $(OS_CFLAGS)
@ -324,8 +312,8 @@ CXXFLAGS += $(WARNINGS_AS_ERRORS)
CFLAGS += $(WARNINGS_AS_ERRORS)
endif # ALLOW_COMPILER_WARNINGS
COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS) $(_DEPEND_CFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES)
COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(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)

Просмотреть файл

@ -46,7 +46,6 @@ class CompileDBBackend(CommonBackend):
self._envs = {}
self._local_flags = defaultdict(dict)
self._per_source_flags = defaultdict(list)
self._gyp_dirs = set()
def consume_object(self, obj):
# Those are difficult directories, that will be handled later.
@ -76,8 +75,6 @@ class CompileDBBackend(CommonBackend):
obj.canonical_suffix)
elif isinstance(obj, VariablePassthru):
if obj.variables.get('IS_GYP_DIR'):
self._gyp_dirs.add(obj.objdir)
for var in ('MOZBUILD_CFLAGS', 'MOZBUILD_CXXFLAGS',
'MOZBUILD_CMFLAGS', 'MOZBUILD_CMMFLAGS',
'RTL_FLAGS'):
@ -108,21 +105,7 @@ class CompileDBBackend(CommonBackend):
cmd.append(filename)
else:
cmd.append(unified)
os_includes = []
if directory not in self._gyp_dirs:
for var in (
'NSPR_CFLAGS',
'NSS_CFLAGS',
'MOZ_JPEG_CFLAGS',
'MOZ_PNG_CFLAGS',
'MOZ_ZLIB_CFLAGS',
'MOZ_PIXMAN_CFLAGS',
):
f = env.substs.get(var)
if f:
os_includes.extend(f)
variables = {
'OS_INCLUDES': os_includes,
'DIST': mozpath.join(env.topobjdir, 'dist'),
'DEPTH': env.topobjdir,
'MOZILLA_DIR': env.topsrcdir,
@ -213,9 +196,6 @@ class CompileDBBackend(CommonBackend):
db.append('$(COMPUTED_%s)' % self.CFLAGS[canonical_suffix])
db.extend((
'$(OS_INCLUDES)',
))
append_var('DSO_CFLAGS')
append_var('DSO_PIC_CFLAGS')
if canonical_suffix in ('.c', '.cpp'):

Просмотреть файл

@ -312,6 +312,10 @@ class CompileFlags(ContextDerivedValue, dict):
('LOCAL_INCLUDES', None, ('CXXFLAGS', 'CFLAGS')),
('EXTRA_INCLUDES', ['-I%s/dist/include' % context.config.topobjdir],
('CXXFLAGS', 'CFLAGS')),
('OS_INCLUDES', list(itertools.chain(*(context.config.substs.get(v, []) for v in (
'NSPR_CFLAGS', 'NSS_CFLAGS', 'MOZ_JPEG_CFLAGS', 'MOZ_PNG_CFLAGS',
'MOZ_ZLIB_CFLAGS', 'MOZ_PIXMAN_CFLAGS')))),
('CXXFLAGS', 'CFLAGS')),
)
self._known_keys = set(k for k, v, _ in self.flag_variables)

Просмотреть файл

@ -951,9 +951,6 @@ class TreeMetadataEmitter(LoggingMixin):
if v in context and context[v]:
passthru.variables['MOZBUILD_' + v] = context[v]
if isinstance(context, TemplateContext) and context.template == 'Gyp':
passthru.variables['IS_GYP_DIR'] = True
dist_install = context['DIST_INSTALL']
if dist_install is True:
passthru.variables['DIST_INSTALL'] = True

Просмотреть файл

@ -327,6 +327,7 @@ def process_gyp_result(gyp_result, gyp_dir_attrs, path, config, output,
context['DEFINES']['UNICODE'] = True
context['DEFINES']['_UNICODE'] = True
context['COMPILE_FLAGS']['STL'] = []
context['COMPILE_FLAGS']['OS_INCLUDES'] = []
for key, value in gyp_dir_attrs.sandbox_vars.items():
if context.get(key) and isinstance(context[key], list):

Просмотреть файл

@ -224,11 +224,26 @@ class TestEmitterBasic(unittest.TestCase):
self.read_topsrcdir(reader)
def test_compile_flags_templates(self):
reader = self.reader('compile-flags-templates')
reader = self.reader('compile-flags-templates', extra_substs={
'NSPR_CFLAGS': ['-I/nspr/path'],
'NSS_CFLAGS': ['-I/nss/path'],
'MOZ_JPEG_CFLAGS': ['-I/jpeg/path'],
'MOZ_PNG_CFLAGS': ['-I/png/path'],
'MOZ_ZLIB_CFLAGS': ['-I/zlib/path'],
'MOZ_PIXMAN_CFLAGS': ['-I/pixman/path'],
})
sources, lib, flags = self.read_topsrcdir(reader)
self.assertIsInstance(flags, ComputedFlags)
self.assertEqual(flags.flags['STL'], [])
self.assertEqual(flags.flags['VISIBILITY'], [])
self.assertEqual(flags.flags['OS_INCLUDES'], [
'-I/nspr/path',
'-I/nss/path',
'-I/jpeg/path',
'-I/png/path',
'-I/zlib/path',
'-I/pixman/path',
])
def test_disable_stl_wrapping(self):
reader = self.reader('disable-stl-wrapping')