Skip to contentSkip to conversation

Makefile: add QUIET_GEN to "tags" and "TAGS" targets

PATCH In review Ævar Arnfjörð Bjarmason 2 participants 3 messages Mar 28, 2021 – Mar 31, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: add QUIET_GEN to "tags" and "TAGS" targets

Don't show the very verbose $(FIND_SOURCE_FILES) command on every "make TAGS" invocation. Let's also use the "cmd >x+ && mv x+ x" pattern here so we don't momentarily clobber the file.

---
 Makefile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Makefile +7 -4
index 55c8035fa80..f317af1b602 100644
@@ -2690,12 +2690,15 @@ FIND_SOURCE_FILES = ( \
 	)
 
 $(ETAGS_TARGET): FORCE
-	$(RM) $(ETAGS_TARGET)
-	$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
+	echo $(ALL_SOURCE_FILES)
+	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
+	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
+	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
 
 tags: FORCE
-	$(RM) tags
-	$(FIND_SOURCE_FILES) | xargs ctags -a
+	$(QUIET_GEN)$(RM) tags+ && \
+	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
+	mv tags+ tags
 
 cscope:
 	$(RM) cscope*
Signature · 1 line
2.31.1.442.g6c06c9fe35c
#1 lore raw
Quoted 3 lines · Ævar Arnfjörð Bjarmason

Don't show the very verbose $(FIND_SOURCE_FILES) command on every "make TAGS" invocation. Let's also use the "cmd >x+ && mv x+ x" pattern here so we don't momentarily clobber the file.

We do not "redirect" ctags and etags output into x+.

Let's use "generate into temporary and rename to the final after seeing the command that generated the output finished successfully" pattern.

Please also correct the explanation of why it is a good idea to use the pattern in this case. It is not about avoiding momentarily clobbering the output. It is to avoid leaving an incorrect output generated by a failed command in the file with the filename that consumers expect.

Thanks for making our Makefile a bit less noisy. Anybody who makes "clean" and its friends quiet will get a gold star ;-)

Quoted 29 lines
---
 Makefile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Makefile +7 -4
index 55c8035fa80..f317af1b602 100644
@@ -2690,12 +2690,15 @@ FIND_SOURCE_FILES = ( \
 	)
 
 $(ETAGS_TARGET): FORCE
-	$(RM) $(ETAGS_TARGET)
-	$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
+	echo $(ALL_SOURCE_FILES)
+	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
+	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
+	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
 
 tags: FORCE
-	$(RM) tags
-	$(FIND_SOURCE_FILES) | xargs ctags -a
+	$(QUIET_GEN)$(RM) tags+ && \
+	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
+	mv tags+ tags
 
 cscope:
 	$(RM) cscope*
#2 lore raw
Quoted 33 lines · Junio C Hamano
Quoted 3 lines · Ævar Arnfjörð Bjarmason

Don't show the very verbose $(FIND_SOURCE_FILES) command on every "make TAGS" invocation. Let's also use the "cmd >x+ && mv x+ x" pattern here so we don't momentarily clobber the file.

We do not "redirect" ctags and etags output into x+.

Let's use "generate into temporary and rename to the final after seeing the command that generated the output finished successfully" pattern.

Please also correct the explanation of why it is a good idea to use the pattern in this case. It is not about avoiding momentarily clobbering the output. It is to avoid leaving an incorrect output generated by a failed command in the file with the filename that consumers expect.

Thanks for making our Makefile a bit less noisy. Anybody who makes "clean" and its friends quiet will get a gold star ;-)

Quoted 12 lines
---
 Makefile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Makefile +0 -0
index 55c8035fa80..f317af1b602 100644
@@ -2690,12 +2690,15 @@ FIND_SOURCE_FILES = ( \
 	)
 
Quoted 4 lines

Makefile FIND_SOURCE_FILES = ( \ · line 2693

Quoted 4 lines
Makefile +1 -2
 $(ETAGS_TARGET): FORCE
-	$(RM) $(ETAGS_TARGET)
-	$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
+	echo $(ALL_SOURCE_FILES)

This echo I presume is a debugging aid to be removed?

Quoted 13 lines
Quoted 13 lines
Makefile +6 -2
+	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
+	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
+	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
 
 tags: FORCE
-	$(RM) tags
-	$(FIND_SOURCE_FILES) | xargs ctags -a
+	$(QUIET_GEN)$(RM) tags+ && \
+	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
+	mv tags+ tags
 
 cscope:
 	$(RM) cscope*