Backed out changeset 95b3298fd2d4 (bug 1537574) for windows task timeouts a=backout

--HG--
rename : python/mozbuild/mozbuild/gen_test_backend.py => build/gen_test_backend.py
This commit is contained in:
Andreea Pavel 2019-04-08 22:23:03 +03:00
Родитель 7e99b88e20
Коммит a7f868ac25
6 изменённых файлов: 126 добавлений и 62 удалений

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

@ -65,6 +65,26 @@ CLOBBER: $(topsrcdir)/CLOBBER
@exit 1
endif
# Regenerate the build backend if it is out of date. We only have this rule in
# this main make file because having it in rules.mk and applied to partial tree
# builds resulted in a world of hurt. Gory details are in bug 877308.
#
# The mach build driver will ensure the backend is up to date for partial tree
# builds. This cleanly avoids most of the pain.
ifndef TEST_MOZBUILD
.PHONY: backend
backend: $(BUILD_BACKEND_FILES)
include $(topsrcdir)/build/rebuild-backend.mk
Makefile: $(BUILD_BACKEND_FILES)
@$(TOUCH) $@
default:: $(BUILD_BACKEND_FILES)
endif
install_manifests := \
$(addprefix dist/,branding include public private xpi-stage) \
_tests \

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

31
build/rebuild-backend.mk Normal file
Просмотреть файл

@ -0,0 +1,31 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
BACKEND_GENERATION_SCRIPT ?= config.status
# A traditional rule would look like this:
# backend.%:
# @echo do stuff
#
# But with -j<n>, and multiple items in BUILD_BACKEND_FILES, the command would
# run multiple times in parallel.
#
# "Fortunately", make has some weird semantics for pattern rules: if there are
# multiple targets in a pattern rule and each of them is matched at most once,
# the command will only run once. So:
# backend%RecursiveMakeBackend backend%FasterMakeBackend:
# @echo do stuff
# backend: backend.RecursiveMakeBackend backend.FasterMakeBackend
# would only execute the command once.
#
# Credit where due: http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file/3077254#3077254
$(subst .,%,$(BUILD_BACKEND_FILES)):
@echo 'Build configuration changed. Regenerating backend.'
$(PYTHON) $(BACKEND_GENERATION_SCRIPT)
define build_backend_rule
$(1): $$(wildcard $$(shell cat $(1).in))
endef
$(foreach file,$(BUILD_BACKEND_FILES),$(eval $(call build_backend_rule,$(file))))

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

@ -197,49 +197,6 @@ class MozbuildObject(ProcessExecutionMixin):
return mozpath.normsep(os.path.normpath(topobjdir))
def build_out_of_date(self, output, dep_file):
if not os.path.isfile(output):
print(" Output reference file not found: %s" % output)
return True
if not os.path.isfile(dep_file):
print(" Dependency file not found: %s" % dep_file)
return True
deps = []
with open(dep_file, 'r') as fh:
deps = fh.read().splitlines()
mtime = os.path.getmtime(output)
for f in deps:
try:
dep_mtime = os.path.getmtime(f)
except OSError as e:
if e.errno == errno.ENOENT:
print(" Input not found: %s" % f)
return True
raise
if dep_mtime > mtime:
print(" %s is out of date with respect to %s" % (output, f))
return True
return False
def backend_out_of_date(self, backend_file):
if not os.path.isfile(backend_file):
return True
# Check if any of our output files have been removed since
# we last built the backend, re-generate the backend if
# so.
outputs = []
with open(backend_file, 'r') as fh:
outputs = fh.read().splitlines()
for output in outputs:
if not os.path.isfile(mozpath.join(self.topobjdir, output)):
return True
dep_file = '%s.in' % backend_file
return self.build_out_of_date(backend_file, dep_file)
@property
def topobjdir(self):
if self._topobjdir is None:

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

@ -1014,6 +1014,49 @@ class BuildDriver(MozbuildObject):
if directory.startswith('/'):
directory = directory[1:]
def build_out_of_date(output, dep_file):
if not os.path.isfile(output):
print(" Output reference file not found: %s" % output)
return True
if not os.path.isfile(dep_file):
print(" Configure dependency file not found: %s" % dep_file)
return True
deps = []
with open(dep_file, 'r') as fh:
deps = fh.read().splitlines()
mtime = os.path.getmtime(output)
for f in deps:
try:
dep_mtime = os.path.getmtime(f)
except OSError as e:
if e.errno == errno.ENOENT:
print(" Configure input not found: %s" % f)
return True
raise
if dep_mtime > mtime:
print(" %s is out of date with respect to %s" % (output, f))
return True
return False
def backend_out_of_date(backend_file):
if not os.path.isfile(backend_file):
return True
# Check if any of our output files have been removed since
# we last built the backend, re-generate the backend if
# so.
outputs = []
with open(backend_file, 'r') as fh:
outputs = fh.read().splitlines()
for output in outputs:
if not os.path.isfile(mozpath.join(self.topobjdir, output)):
return True
dep_file = '%s.in' % backend_file
return build_out_of_date(backend_file, dep_file)
monitor.start_resource_recording()
self.mach_context.command_attrs['clobber'] = False
@ -1041,10 +1084,10 @@ class BuildDriver(MozbuildObject):
config_rc = None
# Even if we have a config object, it may be out of date
# if something that influences its result has changed.
if config is None or self.build_out_of_date(mozpath.join(self.topobjdir,
'config.status'),
mozpath.join(self.topobjdir,
'config_status_deps.in')):
if config is None or build_out_of_date(mozpath.join(self.topobjdir,
'config.status'),
mozpath.join(self.topobjdir,
'config_status_deps.in')):
if previous_backend and 'Make' not in previous_backend:
clobber_requested = self._clobber_configure()
@ -1063,16 +1106,16 @@ class BuildDriver(MozbuildObject):
status = None
if (not config_rc and
self.backend_out_of_date(mozpath.join(self.topobjdir,
'backend.%sBackend' %
active_backend))):
print('Build configuration changed. Regenerating backend.')
args = [config.substs['PYTHON'],
mozpath.join(self.topobjdir, 'config.status')]
self.run_process(args, cwd=self.topobjdir, pass_thru=True)
if 'Make' not in active_backend:
if (not config_rc and
backend_out_of_date(mozpath.join(self.topobjdir,
'backend.%sBackend' %
active_backend))):
print('Build configuration changed. Regenerating backend.')
args = [config.substs['PYTHON'],
mozpath.join(self.topobjdir, 'config.status')]
self.run_process(args, cwd=self.topobjdir, pass_thru=True)
# client.mk has its own handling of MOZ_PARALLEL_BUILD so the
# make backend can determine when to run in single-threaded mode
# or parallel mode. For other backends, we can pass in the value
@ -1138,6 +1181,15 @@ class BuildDriver(MozbuildObject):
'instead of {target_pairs}.')
target_pairs = new_pairs
# Ensure build backend is up to date. The alternative is to
# have rules in the invoked Makefile to rebuild the build
# backend. But that involves make reinvoking itself and there
# are undesired side-effects of this. See bug 877308 for a
# comprehensive history lesson.
self._run_make(directory=self.topobjdir, target='backend',
line_handler=output.on_line, log=False,
print_directory=False, keep_going=keep_going)
# Build target pairs.
for make_dir, make_target in target_pairs:
# We don't display build status messages during partial

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

@ -544,12 +544,16 @@ class TestResolver(MozbuildObject):
# If installing tests is going to result in re-generating the build
# backend, we need to do this here, so that the updated contents of
# all-tests.pkl make it to the set of tests to run.
if self.backend_out_of_date(mozpath.join(self.topobjdir,
'backend.TestManifestBackend'
)):
print("Test configuration changed. Regenerating backend.")
from mozbuild.gen_test_backend import gen_test_backend
gen_test_backend()
self._run_make(
target='backend.TestManifestBackend', pass_thru=True, print_directory=False,
filename=mozpath.join(self.topsrcdir, 'build', 'rebuild-backend.mk'),
append_env={
b'PYTHON': self.virtualenv_manager.python_path,
b'BUILD_BACKEND_FILES': b'backend.TestManifestBackend',
b'BACKEND_GENERATION_SCRIPT': mozpath.join(
self.topsrcdir, 'build', 'gen_test_backend.py'),
},
)
self._tests = TestMetadata(os.path.join(self.topobjdir,
'all-tests.pkl'),