Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-11-02 01:35:52 +0300
committerTaylor Blau <me@ttaylorr.com>2022-11-03 04:22:16 +0300
commit202086b85c6591e99ee18e31277786d43f2804a2 (patch)
tree9882e92e7ac4fec2c092a18ced82fbcbd4f165d3 /Makefile
parent316e3886e349293571b2b2796c32afd4b8ba6f22 (diff)
Makefile: copy contrib/coccinelle/*.cocci to build/
Change the "coccinelle" rule so that we first copy the *.cocci source in e.g. "contrib/coccinelle/strbuf.cocci" to ".build/contrib/coccinelle/strbuf.cocci" before operating on it. For now this serves as a rather pointless indirection, but prepares us for the subsequent commit where we'll be able to inject generated *.cocci files. Having the entire dependency tree live inside .build/* simplifies both the globbing we'd need to do, and any "clean" rules. It will also help for future targets which will want to act on the generated patches or the logs, e.g. targets to alert if we can't parse certain files (or, less so than usual) with "spatch", and e.g. a replacement for "ci/run-static-analysis.sh". Such a replacement won't care about placing the patches in the in-tree, only whether they're "OK" (and about the diff). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile27
1 files changed, 21 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 19d2d5d4cb..1e9c925f4a 100644
--- a/Makefile
+++ b/Makefile
@@ -3159,8 +3159,11 @@ check: $(GENERATED_H)
fi
COCCI_GLOB = $(wildcard contrib/coccinelle/*.cocci)
-COCCI_RULES = $(COCCI_GLOB)
-COCCI_NAMES = $(COCCI_RULES:contrib/coccinelle/%.cocci=%)
+COCCI_RULES_TRACKED = $(COCCI_GLOB:%=.build/%)
+COCCI_RULES =
+COCCI_RULES += $(COCCI_RULES_TRACKED)
+COCCI_NAMES =
+COCCI_NAMES += $(COCCI_RULES:.build/contrib/coccinelle/%.cocci=%)
COCCICHECK_PENDING = $(filter %.pending.cocci,$(COCCI_RULES))
COCCICHECK = $(filter-out $(COCCICHECK_PENDING),$(COCCI_RULES))
@@ -3168,6 +3171,9 @@ COCCICHECK = $(filter-out $(COCCICHECK_PENDING),$(COCCI_RULES))
COCCICHECK_PATCHES = $(COCCICHECK:%=%.patch)
COCCICHECK_PATCHES_PENDING = $(COCCICHECK_PENDING:%=%.patch)
+COCCICHECK_PATCHES_INTREE = $(COCCICHECK_PATCHES:.build/%=%)
+COCCICHECK_PATCHES_PENDING_INTREE = $(COCCICHECK_PATCHES_PENDING:.build/%=%)
+
# It's expensive to compute the many=many rules below, only eval them
# on $(MAKECMDGOALS) that match these $(COCCI_RULES)
COCCI_RULES_GLOB =
@@ -3175,10 +3181,16 @@ COCCI_RULES_GLOB += cocci%
COCCI_RULES_GLOB += .build/contrib/coccinelle/%
COCCI_RULES_GLOB += $(COCCICHECK_PATCHES)
COCCI_RULES_GLOB += $(COCCICHEC_PATCHES_PENDING)
+COCCI_RULES_GLOB += $(COCCICHECK_PATCHES_INTREE)
+COCCI_RULES_GLOB += $(COCCICHECK_PATCHES_PENDING_INTREE)
COCCI_GOALS = $(filter $(COCCI_RULES_GLOB),$(MAKECMDGOALS))
COCCI_TEST_RES = $(wildcard contrib/coccinelle/tests/*.res)
+$(COCCI_RULES_TRACKED): .build/% : %
+ $(call mkdir_p_parent_template)
+ $(QUIET_CP)cp $< $@
+
.build/contrib/coccinelle/FOUND_H_SOURCES: $(FOUND_H_SOURCES)
$(call mkdir_p_parent_template)
$(QUIET_GEN) >$@
@@ -3192,7 +3204,7 @@ define cocci-rule
# $(1) = e.g. "free.cocci"
# $(2) = e.g. "grep.c"
# $(3) = e.g. "grep.o"
-COCCI_$(1:contrib/coccinelle/%.cocci=%) += .build/$(1).patch/$(2)
+COCCI_$(1:.build/contrib/coccinelle/%.cocci=%) += .build/$(1).patch/$(2)
.build/$(1).patch/$(2): GIT-SPATCH-DEFINES
.build/$(1).patch/$(2): $(if $(and $(SPATCH_USE_O_DEPENDENCIES),$(wildcard $(3))),$(3),.build/contrib/coccinelle/FOUND_H_SOURCES)
.build/$(1).patch/$(2): $(1)
@@ -3220,12 +3232,15 @@ endif
define spatch-rule
-contrib/coccinelle/$(1).cocci.patch: $$(COCCI_$(1))
+.build/contrib/coccinelle/$(1).cocci.patch: $$(COCCI_$(1))
$$(QUIET_SPATCH_CAT)cat $$^ >$$@ && \
if test -s $$@; \
then \
echo ' ' SPATCH result: $$@; \
fi
+contrib/coccinelle/$(1).cocci.patch: .build/contrib/coccinelle/$(1).cocci.patch
+ $$(QUIET_CP)cp $$< $$@
+
endef
ifdef COCCI_GOALS
@@ -3249,11 +3264,11 @@ $(COCCI_TEST_RES_GEN): .build/contrib/coccinelle/tests/%.res : contrib/coccinell
coccicheck-test: $(COCCI_TEST_RES_GEN)
coccicheck: coccicheck-test
-coccicheck: $(COCCICHECK_PATCHES)
+coccicheck: $(COCCICHECK_PATCHES_INTREE)
# See contrib/coccinelle/README
coccicheck-pending: coccicheck-test
-coccicheck-pending: $(COCCICHECK_PATCHES_PENDING)
+coccicheck-pending: $(COCCICHECK_PATCHES_PENDING_INTREE)
.PHONY: coccicheck coccicheck-pending