Skip to content

Commit 202086b

Browse files
avarttaylorr
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 316e388 commit 202086b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

Makefile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,26 +3159,38 @@ check: $(GENERATED_H)
31593159
fi
31603160

31613161
COCCI_GLOB = $(wildcard contrib/coccinelle/*.cocci)
3162-
COCCI_RULES = $(COCCI_GLOB)
3163-
COCCI_NAMES = $(COCCI_RULES:contrib/coccinelle/%.cocci=%)
3162+
COCCI_RULES_TRACKED = $(COCCI_GLOB:%=.build/%)
3163+
COCCI_RULES =
3164+
COCCI_RULES += $(COCCI_RULES_TRACKED)
3165+
COCCI_NAMES =
3166+
COCCI_NAMES += $(COCCI_RULES:.build/contrib/coccinelle/%.cocci=%)
31643167

31653168
COCCICHECK_PENDING = $(filter %.pending.cocci,$(COCCI_RULES))
31663169
COCCICHECK = $(filter-out $(COCCICHECK_PENDING),$(COCCI_RULES))
31673170

31683171
COCCICHECK_PATCHES = $(COCCICHECK:%=%.patch)
31693172
COCCICHECK_PATCHES_PENDING = $(COCCICHECK_PENDING:%=%.patch)
31703173

3174+
COCCICHECK_PATCHES_INTREE = $(COCCICHECK_PATCHES:.build/%=%)
3175+
COCCICHECK_PATCHES_PENDING_INTREE = $(COCCICHECK_PATCHES_PENDING:.build/%=%)
3176+
31713177
# It's expensive to compute the many=many rules below, only eval them
31723178
# on $(MAKECMDGOALS) that match these $(COCCI_RULES)
31733179
COCCI_RULES_GLOB =
31743180
COCCI_RULES_GLOB += cocci%
31753181
COCCI_RULES_GLOB += .build/contrib/coccinelle/%
31763182
COCCI_RULES_GLOB += $(COCCICHECK_PATCHES)
31773183
COCCI_RULES_GLOB += $(COCCICHEC_PATCHES_PENDING)
3184+
COCCI_RULES_GLOB += $(COCCICHECK_PATCHES_INTREE)
3185+
COCCI_RULES_GLOB += $(COCCICHECK_PATCHES_PENDING_INTREE)
31783186
COCCI_GOALS = $(filter $(COCCI_RULES_GLOB),$(MAKECMDGOALS))
31793187

31803188
COCCI_TEST_RES = $(wildcard contrib/coccinelle/tests/*.res)
31813189

3190+
$(COCCI_RULES_TRACKED): .build/% : %
3191+
$(call mkdir_p_parent_template)
3192+
$(QUIET_CP)cp $< $@
3193+
31823194
.build/contrib/coccinelle/FOUND_H_SOURCES: $(FOUND_H_SOURCES)
31833195
$(call mkdir_p_parent_template)
31843196
$(QUIET_GEN) >$@
@@ -3192,7 +3204,7 @@ define cocci-rule
31923204
# $(1) = e.g. "free.cocci"
31933205
# $(2) = e.g. "grep.c"
31943206
# $(3) = e.g. "grep.o"
3195-
COCCI_$(1:contrib/coccinelle/%.cocci=%) += .build/$(1).patch/$(2)
3207+
COCCI_$(1:.build/contrib/coccinelle/%.cocci=%) += .build/$(1).patch/$(2)
31963208
.build/$(1).patch/$(2): GIT-SPATCH-DEFINES
31973209
.build/$(1).patch/$(2): $(if $(and $(SPATCH_USE_O_DEPENDENCIES),$(wildcard $(3))),$(3),.build/contrib/coccinelle/FOUND_H_SOURCES)
31983210
.build/$(1).patch/$(2): $(1)
@@ -3220,12 +3232,15 @@ endif
32203232

32213233
define spatch-rule
32223234

3223-
contrib/coccinelle/$(1).cocci.patch: $$(COCCI_$(1))
3235+
.build/contrib/coccinelle/$(1).cocci.patch: $$(COCCI_$(1))
32243236
$$(QUIET_SPATCH_CAT)cat $$^ >$$@ && \
32253237
if test -s $$@; \
32263238
then \
32273239
echo ' ' SPATCH result: $$@; \
32283240
fi
3241+
contrib/coccinelle/$(1).cocci.patch: .build/contrib/coccinelle/$(1).cocci.patch
3242+
$$(QUIET_CP)cp $$< $$@
3243+
32293244
endef
32303245

32313246
ifdef COCCI_GOALS
@@ -3249,11 +3264,11 @@ $(COCCI_TEST_RES_GEN): .build/contrib/coccinelle/tests/%.res : contrib/coccinell
32493264
coccicheck-test: $(COCCI_TEST_RES_GEN)
32503265

32513266
coccicheck: coccicheck-test
3252-
coccicheck: $(COCCICHECK_PATCHES)
3267+
coccicheck: $(COCCICHECK_PATCHES_INTREE)
32533268

32543269
# See contrib/coccinelle/README
32553270
coccicheck-pending: coccicheck-test
3256-
coccicheck-pending: $(COCCICHECK_PATCHES_PENDING)
3271+
coccicheck-pending: $(COCCICHECK_PATCHES_PENDING_INTREE)
32573272

32583273
.PHONY: coccicheck coccicheck-pending
32593274

shared.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ifndef V
6060
QUIET_AR = @echo ' ' AR $@;
6161
QUIET_LINK = @echo ' ' LINK $@;
6262
QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
63+
QUIET_CP = @echo ' ' CP $< $@;
6364
QUIET_LNCP = @echo ' ' LN/CP $@;
6465
QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
6566
QUIET_MSGINIT = @echo ' ' MSGINIT $@;

0 commit comments

Comments
 (0)