Skip to content

Commit 09d9a69

Browse files
avarttaylorr
authored andcommitted
Makefile: have "coccicheck" re-run if flags change
Fix an issue with the "coccicheck" family of rules that's been here since 63f0a75 (add coccicheck make target, 2016-09-15), unlike e.g. "make grep.o" we wouldn't re-run it when $(SPATCH) or $(SPATCH_FLAGS) changed. To test new flags we needed to first do a "make cocciclean". This now uses the same (copy/pasted) pattern as other "DEFINES" rules. As a result we'll re-run properly. This can be demonstrated e.g. on the issue noted in [1]: $ make contrib/coccinelle/xcalloc.cocci.patch COCCI_SOURCES=promisor-remote.c V=1 [...] SPATCH contrib/coccinelle/xcalloc.cocci $ make contrib/coccinelle/xcalloc.cocci.patch COCCI_SOURCES=promisor-remote.c SPATCH_FLAGS="--all-includes --recursive-includes" * new spatch flags SPATCH contrib/coccinelle/xcalloc.cocci SPATCH result: contrib/coccinelle/xcalloc.cocci.patch $ 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent e603a14 commit 09d9a69

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/GIT-PERL-HEADER
1111
/GIT-PYTHON-VARS
1212
/GIT-SCRIPT-DEFINES
13+
/GIT-SPATCH-DEFINES
1314
/GIT-USER-AGENT
1415
/GIT-VERSION-FILE
1516
/bin-wrappers/

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,18 @@ SANITIZE_ADDRESS =
13001300
SPATCH_FLAGS = --all-includes
13011301
SPATCH_BATCH_SIZE = 1
13021302

1303+
# Rebuild 'coccicheck' if $(SPATCH), its flags etc. change
1304+
TRACK_SPATCH_DEFINES =
1305+
TRACK_SPATCH_DEFINES += $(SPATCH)
1306+
TRACK_SPATCH_DEFINES += $(SPATCH_FLAGS)
1307+
TRACK_SPATCH_DEFINES += $(SPATCH_BATCH_SIZE)
1308+
GIT-SPATCH-DEFINES: FORCE
1309+
@FLAGS='$(TRACK_SPATCH_DEFINES)'; \
1310+
if test x"$$FLAGS" != x"`cat GIT-SPATCH-DEFINES 2>/dev/null`" ; then \
1311+
echo >&2 " * new spatch flags"; \
1312+
echo "$$FLAGS" >GIT-SPATCH-DEFINES; \
1313+
fi
1314+
13031315
include config.mak.uname
13041316
-include config.mak.autogen
13051317
-include config.mak
@@ -3151,6 +3163,7 @@ COCCICHECK_PATCHES_PENDING = $(COCCICHECK_PENDING:%=%.patch)
31513163
COCCI_TEST_RES = $(wildcard contrib/coccinelle/tests/*.res)
31523164

31533165
COCCI_PATCHES = $(COCCI_RULES:%=%.patch)
3166+
$(COCCI_PATCHES): GIT-SPATCH-DEFINES
31543167
$(COCCI_PATCHES): $(COCCI_SOURCES)
31553168
$(COCCI_PATCHES): %.patch: %
31563169
$(QUIET_SPATCH) \
@@ -3174,6 +3187,7 @@ $(COCCI_PATCHES): %.patch: %
31743187
fi
31753188

31763189
COCCI_TEST_RES_GEN = $(addprefix .build/,$(COCCI_TEST_RES))
3190+
$(COCCI_TEST_RES_GEN): GIT-SPATCH-DEFINES
31773191
$(COCCI_TEST_RES_GEN): .build/%.res : %.c
31783192
$(COCCI_TEST_RES_GEN): .build/%.res : %.res
31793193
$(COCCI_TEST_RES_GEN): .build/contrib/coccinelle/tests/%.res : contrib/coccinelle/%.cocci
@@ -3460,6 +3474,7 @@ profile-clean:
34603474
$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
34613475

34623476
cocciclean:
3477+
$(RM) GIT-SPATCH-DEFINES
34633478
$(RM) -r .build/contrib/coccinelle
34643479
$(RM) contrib/coccinelle/*.cocci.patch*
34653480

0 commit comments

Comments
 (0)