mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Bug 917086 - Disallow DIRS, PARALLEL_DIRS and TEST_DIRS under TOOL_DIRS and TEST_TOOL_DIRS, and adapt moz.build files accordingly. r=gps
Also mark TOOL_DIRS/TEST_TOOL_DIRS directories in backend.mk and recurse them normally instead of forcing make -C dir libs for them.
This commit is contained in:
parent
a3202b67de
commit
18d895f774
@ -43,10 +43,7 @@ endef
|
||||
|
||||
$(foreach subtier,export compile libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
|
||||
|
||||
compile export:: $(SUBMAKEFILES)
|
||||
compile export tools:: $(SUBMAKEFILES)
|
||||
$(LOOP_OVER_TOOL_DIRS)
|
||||
|
||||
tools:: $(SUBMAKEFILES)
|
||||
$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
|
||||
|
||||
endif
|
||||
|
@ -737,6 +737,13 @@ compile:: $(OBJS) $(HOST_OBJS)
|
||||
|
||||
include $(topsrcdir)/config/makefiles/target_libs.mk
|
||||
|
||||
ifdef IS_TOOL_DIR
|
||||
# One would think "tools:: libs" would work, but it turns out that combined with
|
||||
# bug 907365, this makes make forget to run some rules sometimes.
|
||||
tools::
|
||||
@$(MAKE) libs
|
||||
endif
|
||||
|
||||
##############################################
|
||||
ifndef NO_PROFILE_GUIDED_OPTIMIZE
|
||||
ifdef MOZ_PROFILE_USE
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += [
|
||||
TEST_TOOL_DIRS += [
|
||||
'chrome',
|
||||
'csp',
|
||||
'websocket_hybi',
|
||||
|
@ -43,10 +43,7 @@ endef
|
||||
|
||||
$(foreach subtier,export compile libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
|
||||
|
||||
compile export:: $(SUBMAKEFILES)
|
||||
compile export tools:: $(SUBMAKEFILES)
|
||||
$(LOOP_OVER_TOOL_DIRS)
|
||||
|
||||
tools:: $(SUBMAKEFILES)
|
||||
$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
|
||||
|
||||
endif
|
||||
|
@ -737,6 +737,13 @@ compile:: $(OBJS) $(HOST_OBJS)
|
||||
|
||||
include $(topsrcdir)/config/makefiles/target_libs.mk
|
||||
|
||||
ifdef IS_TOOL_DIR
|
||||
# One would think "tools:: libs" would work, but it turns out that combined with
|
||||
# bug 907365, this makes make forget to run some rules sometimes.
|
||||
tools::
|
||||
@$(MAKE) libs
|
||||
endif
|
||||
|
||||
##############################################
|
||||
ifndef NO_PROFILE_GUIDED_OPTIMIZE
|
||||
ifdef MOZ_PROFILE_USE
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += [
|
||||
TEST_TOOL_DIRS += [
|
||||
'idl',
|
||||
'mochitest',
|
||||
'chrome',
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
TEST_DIRS += ['chrome']
|
||||
TEST_TOOL_DIRS += ['chrome']
|
||||
|
||||
MODULE = 'layout'
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += ['mochitest', 'chrome']
|
||||
TEST_TOOL_DIRS += ['mochitest', 'chrome']
|
||||
|
||||
MODULE = 'test_libjar'
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
TEST_DIRS += ['httpserver', 'browser', 'mochitests']
|
||||
TEST_TOOL_DIRS += ['httpserver', 'browser', 'mochitests']
|
||||
|
||||
MODULE = 'test_necko'
|
||||
|
||||
|
@ -4,4 +4,4 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
TEST_DIRS += ['scripted']
|
||||
TEST_TOOL_DIRS += ['scripted']
|
||||
|
@ -4,4 +4,4 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
TEST_DIRS += ['dir_bug534293', 'html5lib_tree_construction']
|
||||
TEST_TOOL_DIRS += ['dir_bug534293', 'html5lib_tree_construction']
|
||||
|
@ -4,4 +4,4 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
TEST_DIRS += ['mochitest']
|
||||
TEST_TOOL_DIRS += ['mochitest']
|
||||
|
@ -395,6 +395,9 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
fh.write('PARALLEL_DIRS += %s\n' %
|
||||
' '.join(obj.parallel_external_make_dirs))
|
||||
|
||||
if obj.is_tool_dir:
|
||||
fh.write('IS_TOOL_DIR := 1\n')
|
||||
|
||||
def _process_exports(self, obj, exports, backend_file, namespace=""):
|
||||
# This may not be needed, but is present for backwards compatibility
|
||||
# with the old make rules, just in case.
|
||||
|
@ -190,6 +190,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
o.test_tool_dirs = sandbox.get('TEST_TOOL_DIRS', [])
|
||||
o.external_make_dirs = sandbox.get('EXTERNAL_MAKE_DIRS', [])
|
||||
o.parallel_external_make_dirs = sandbox.get('PARALLEL_EXTERNAL_MAKE_DIRS', [])
|
||||
o.is_tool_dir = sandbox.get('IS_TOOL_DIR', False)
|
||||
|
||||
if 'TIERS' in sandbox:
|
||||
for tier in sandbox['TIERS']:
|
||||
|
@ -173,6 +173,10 @@ class MozbuildSandbox(Sandbox):
|
||||
d['CONFIG'] = ReadOnlyDefaultDict(self.config.substs_unicode,
|
||||
global_default=None)
|
||||
|
||||
var = metadata.get('var', None)
|
||||
if var and var in ['TOOL_DIRS', 'TEST_TOOL_DIRS']:
|
||||
d['IS_TOOL_DIR'] = True
|
||||
|
||||
# Register functions.
|
||||
for name, func in FUNCTIONS.items():
|
||||
d[name] = getattr(self, func[0])
|
||||
@ -332,7 +336,8 @@ class BuildReaderError(Exception):
|
||||
s.write('The error occurred when validating the result of ')
|
||||
s.write('the execution. The reported error is:\n')
|
||||
s.write('\n')
|
||||
s.write(' %s\n' % self.validation_error.message)
|
||||
s.write(''.join(' %s\n' % l
|
||||
for l in self.validation_error.message.splitlines()))
|
||||
s.write('\n')
|
||||
else:
|
||||
s.write('The error appears to be part of the %s ' % __name__)
|
||||
@ -634,6 +639,20 @@ class BuildReader(object):
|
||||
sandbox = MozbuildSandbox(self.config, path, metadata=metadata)
|
||||
sandbox.exec_file(path, filesystem_absolute=filesystem_absolute)
|
||||
sandbox.execution_time = time.time() - time_start
|
||||
var = metadata.get('var', None)
|
||||
forbidden = {
|
||||
'TOOL_DIRS': ['DIRS', 'PARALLEL_DIRS', 'TEST_DIRS'],
|
||||
'TEST_TOOL_DIRS': ['DIRS', 'PARALLEL_DIRS', 'TEST_DIRS', 'TOOL_DIRS'],
|
||||
}
|
||||
if var in forbidden:
|
||||
matches = [v for v in forbidden[var] if sandbox[v]]
|
||||
if matches:
|
||||
raise SandboxValidationError('%s is registered as %s in %s/moz.build.\n'
|
||||
'The %s variable%s not allowed in such directories.'
|
||||
% (sandbox['RELATIVEDIR'], var, metadata['parent'],
|
||||
' and '.join(', '.join(matches).rsplit(', ', 1)),
|
||||
's are' if len(matches) > 1 else ' is'))
|
||||
|
||||
yield sandbox
|
||||
|
||||
# Traverse into referenced files.
|
||||
@ -658,7 +677,9 @@ class BuildReader(object):
|
||||
'Directory (%s) registered multiple times in %s' % (
|
||||
d, var))
|
||||
|
||||
recurse_info[d] = {'tier': metadata.get('tier', None)}
|
||||
recurse_info[d] = {'tier': metadata.get('tier', None),
|
||||
'parent': sandbox['RELATIVEDIR'],
|
||||
'var': var}
|
||||
|
||||
# We also have tiers whose members are directories.
|
||||
if 'TIERS' in sandbox:
|
||||
@ -674,7 +695,9 @@ class BuildReader(object):
|
||||
raise SandboxValidationError(
|
||||
'Tier directory (%s) registered multiple '
|
||||
'times in %s' % (d, tier))
|
||||
recurse_info[d] = {'tier': tier}
|
||||
recurse_info[d] = {'tier': tier,
|
||||
'parent': sandbox['RELATIVEDIR'],
|
||||
'var': 'DIRS'}
|
||||
|
||||
curdir = os.path.dirname(path)
|
||||
for relpath, child_metadata in recurse_info.items():
|
||||
|
@ -0,0 +1,2 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
DIRS = ['biz']
|
@ -0,0 +1,5 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
TOOL_DIRS = ['foo']
|
@ -244,6 +244,14 @@ class TestBuildReader(unittest.TestCase):
|
||||
self.assertIn('A moz.build file called the error() function.', str(e))
|
||||
self.assertIn(' Some error.', str(e))
|
||||
|
||||
def test_error_traversal_tools(self):
|
||||
reader = self.reader('reader-error-traversal-tools')
|
||||
|
||||
with self.assertRaises(BuildReaderError) as bre:
|
||||
list(reader.read_topsrcdir())
|
||||
|
||||
e = bre.exception
|
||||
self.assertIn('The DIRS variable is not allowed in such directories.', str(e))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += ['rdfcat', 'rdfpoll', 'triplescat']
|
||||
TEST_TOOL_DIRS += ['rdfcat', 'rdfpoll', 'triplescat']
|
||||
|
||||
MODULE = 'test_rdf'
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
TEST_DIRS += ['mochitest']
|
||||
TEST_TOOL_DIRS += ['mochitest']
|
||||
|
||||
MODULE = 'test_url-classifier'
|
||||
|
||||
|
@ -4,7 +4,9 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += ['program']
|
||||
# If you're copying from this file, you'll likely need to replace
|
||||
# TEST_TOOL_DIRS with DIRS.
|
||||
TEST_TOOL_DIRS += ['program']
|
||||
|
||||
# XPIDL_SOURCES specifies IDL files. The build system runs the xpidl tool
|
||||
# on these files to generate C++ headers and .xpt typelib files.
|
||||
|
@ -4,7 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += [
|
||||
TEST_TOOL_DIRS += [
|
||||
'external',
|
||||
'component',
|
||||
'bug656331_component',
|
||||
@ -12,10 +12,10 @@ DIRS += [
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
DIRS += ['windows']
|
||||
TEST_TOOL_DIRS += ['windows']
|
||||
|
||||
if CONFIG['DEHYDRA_PATH']:
|
||||
DIRS += ['static-checker']
|
||||
TEST_TOOL_DIRS += ['static-checker']
|
||||
|
||||
EXPORTS.testing += [
|
||||
'TestHarness.h',
|
||||
|
Loading…
x
Reference in New Issue
Block a user