Skip to content

Commit 0d12792

Browse files
avarttaylorr
authored andcommitted
Makefile: don't create a ".build/.build/" for cocci, fix output
Fix a couple of issues in the recently merged 0f3c55d (Merge branch 'ab/coccicheck-incremental' into next, 2022-11-08): In copying over the "contrib/coccinelle/" rules to ".build/contrib/coccinelle/" we inadvertently ended up with a ".build/.build/contrib/coccinelle/" as well. We'd generate the per-file patches in the former, and keep the rule and overall result in the latter. E.g. running: make contrib/coccinelle/free.cocci.patch COCCI_SOURCES="attr.c grep.c" Would, per "tree -a .build" yield the following result: .build ├── .build │   └── contrib │   └── coccinelle │   └── free.cocci.patch │   ├── attr.c │   ├── attr.c.log │   ├── grep.c │   └── grep.c.log └── contrib └── coccinelle ├── FOUND_H_SOURCES ├── free.cocci └── free.cocci.patch Now we'll instead generate all of our files in ".build/contrib/coccinelle/". Fixing this required renaming the directory where we keep our per-file patches, as we'd otherwise conflict with the result. Now the per-file patch directory is named e.g. "free.cocci.d". And the end result will now be: .build └── contrib └── coccinelle ├── FOUND_H_SOURCES ├── free.cocci ├── free.cocci.d │   ├── attr.c.patch │   ├── attr.c.patch.log │   ├── grep.c.patch │   └── grep.c.patch.log └── free.cocci.patch The per-file patches now have a ".patch" file suffix, which fixes another issue reported against 0f3c55d: The summary output was confusing. Before for the "make" command above we'd emit: [...] MKDIR -p .build/contrib/coccinelle CP contrib/coccinelle/free.cocci .build/contrib/coccinelle/free.cocci GEN .build/contrib/coccinelle/FOUND_H_SOURCES MKDIR -p .build/.build/contrib/coccinelle/free.cocci.patch SPATCH .build/.build/contrib/coccinelle/free.cocci.patch/grep.c SPATCH .build/.build/contrib/coccinelle/free.cocci.patch/attr.c SPATCH CAT $^ >.build/contrib/coccinelle/free.cocci.patch CP .build/contrib/coccinelle/free.cocci.patch contrib/coccinelle/free.cocci.patch But now we'll instead emit (identical output at the start omitted): [...] MKDIR -p .build/contrib/coccinelle/free.cocci.d SPATCH grep.c >.build/contrib/coccinelle/free.cocci.d/grep.c.patch SPATCH attr.c >.build/contrib/coccinelle/free.cocci.d/attr.c.patch SPATCH CAT .build/contrib/coccinelle/free.cocci.d/**.patch >.build/contrib/coccinelle/free.cocci.patch CP .build/contrib/coccinelle/free.cocci.patch contrib/coccinelle/free.cocci.patch I.e. we have an "SPATCH" line that makes it clear that we're running against the "{attr,grep}.c" file. The "SPATCH CAT" is then altered to correspond to it, showing that we're concatenating the "free.cocci.d/**.patch" files into one generated "free.cocci.patch" at the end. Reported-by: SZEDER Gábor <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 6fae3aa commit 0d12792

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,14 +3231,14 @@ endif
32313231
define cocci-rule
32323232

32333233
## Rule for .build/$(1).patch/$(2); Params:
3234-
# $(1) = e.g. "free.cocci"
3234+
# $(1) = e.g. ".build/contrib/coccinelle/free.cocci"
32353235
# $(2) = e.g. "grep.c"
32363236
# $(3) = e.g. "grep.o"
3237-
COCCI_$(1:.build/contrib/coccinelle/%.cocci=%) += .build/$(1).patch/$(2)
3238-
.build/$(1).patch/$(2): GIT-SPATCH-DEFINES
3239-
.build/$(1).patch/$(2): $(if $(and $(SPATCH_USE_O_DEPENDENCIES),$(wildcard $(3))),$(3),.build/contrib/coccinelle/FOUND_H_SOURCES)
3240-
.build/$(1).patch/$(2): $(1)
3241-
.build/$(1).patch/$(2): .build/$(1).patch/% : %
3237+
COCCI_$(1:.build/contrib/coccinelle/%.cocci=%) += $(1).d/$(2).patch
3238+
$(1).d/$(2).patch: GIT-SPATCH-DEFINES
3239+
$(1).d/$(2).patch: $(if $(and $(SPATCH_USE_O_DEPENDENCIES),$(wildcard $(3))),$(3),.build/contrib/coccinelle/FOUND_H_SOURCES)
3240+
$(1).d/$(2).patch: $(1)
3241+
$(1).d/$(2).patch: $(1).d/%.patch : %
32423242
$$(call mkdir_p_parent_template)
32433243
$$(QUIET_SPATCH)if ! $$(SPATCH) $$(SPATCH_FLAGS) \
32443244
$$(SPATCH_INCLUDE_FLAGS) \

shared.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ ifndef V
7272
QUIET_RC = @echo ' ' RC $@;
7373

7474
## Used in "Makefile": SPATCH
75-
QUIET_SPATCH = @echo ' ' SPATCH $@;
75+
QUIET_SPATCH = @echo ' ' SPATCH $< \>$@;
7676
QUIET_SPATCH_TEST = @echo ' ' SPATCH TEST $(@:.build/%=%);
77-
QUIET_SPATCH_CAT = @echo ' ' SPATCH CAT $$^ \>$@;
77+
QUIET_SPATCH_CAT = @echo ' ' SPATCH CAT $(@:%.patch=%.d/)\*\*.patch \>$@;
7878

7979
## Used in "Documentation/Makefile"
8080
QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;

0 commit comments

Comments
 (0)