mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
6bbfcbc2fa
Looking into the config.status path some more, the reason we always rebuild when it is not present is because of the way I implemented missing files in bug 1242663
. However, I think an alternate solution there would be to use $(wildcard) instead of creating dummy rules on every file. so if our dependency file contains:
config.status
foo
bar
The current rules do:
backend.TestManifestBackend: config.status foo bar
re-create backend
config.status foo bar:
Since config.status is missing, make runs the empty rule to try to create it (which does nothing), but that triggers the backend.TestManifestBackend rule. With wildcard this would look like:
backend.TestManifestBackend: $(wildcard config.status foo bar)
re-create backend
Which means make only checks dependencies on the files that actually exist (presumably foo and bar in this case, but not config.status). But when config.status is later created, we'll know to recreate the TestManifestBackend then.
MozReview-Commit-ID: 6NTTmsnxTeT
--HG--
extra : rebase_source : 737c3021cbc26074ec54eafeca203ae95c37d8b8
32 lines
1.3 KiB
Makefile
32 lines
1.3 KiB
Makefile
# 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))))
|