History

kbuild: print short log in addition to the whole command with V=1

"make V=1" prints the whole command instead of the short log, but I think it is nicer to print both so that you can easily spot the build rule of your interest. This commit changes V=1 to print the short log (the line starts with '#'), followed by the full log. In parallel builds, the short/full logs from the same build rule may be interspersed. If you want to avoid it, please add -Otarget option. Kbuild will never set it by default because Make would buffer the logs and lose the escape sequences. (Modern compilers print warnings and errors in color, but only when they write to a terminal.) This is also a preparation for supporting V=12 because V=2 appends the reason for rebuilding to the short log.

Masahiro Yamada committed 3 years ago

Commit 8962b6b1 parent fc5d57a2 files · +20 −24Browse files

Unified · Split

2 files
  1. Makefile +7 −11
  2. scripts/Kbuild.include +13 −13
Makefile+7−11
@@ -56,22 +56,18 @@ unexport GREP_OPTIONS · 55 unmodified lines
5656 # Beautify output
5757 # ---------------------------------------------------------------------------
5858 #
59−# Normally, we echo the whole command before executing it. By making
60−# that echo $($(quiet)$(cmd)), we now have the possibility to set
61−# $(quiet) to choose other forms of output instead, e.g.
59+# Most of build commands in Kbuild start with "cmd_". You can optionally define
60+# "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from
61+# that command is printed by default.
6262 #
63−# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
64−# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
65−#
66−# If $(quiet) is empty, the whole command will be printed.
67−# If it is set to "quiet_", only the short version will be printed.
68−# If it is set to "silent_", nothing will be printed at all, since
69−# the variable $(silent_cmd_cc_o_c) doesn't exist.
63+# e.g.)
64+# quiet_cmd_depmod = DEPMOD $(MODLIB)
65+# cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE)
7066 #
7167 # A simple variant is to prefix commands with $(Q) - that's useful
7268 # for commands that shall be hidden in non-verbose mode.
7369 #
74−# $(Q)ln $@ :<
70+# $(Q)$(MAKE) $(build)=scripts/basic
7571 #
7672 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
7773 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
scripts/Kbuild.include+13−13
@@ -125,15 +125,15 @@ dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj · 124 unmodified lines
125125 # $(Q)$(MAKE) $(clean)=dir
126126 clean := -f $(srctree)/scripts/Makefile.clean obj
127127
128−# echo command.
129−# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
130−echo-cmd = $(if $($(quiet)cmd_$(1)),\
131− echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
132−
133−# sink stdout for 'make -s'
134− redirect :=
135− quiet_redirect :=
136−silent_redirect := exec >/dev/null;
128+# pring log
129+#
130+# If quiet is "silent_", print nothing and sink stdout
131+# If quiet is "quiet_", print short log
132+# If quiet is empty, print short log and whole command
133+silent_log_print = exec >/dev/null;
134+ quiet_log_print = $(if $(quiet_cmd_$1), echo ' $(call escsq,$(quiet_cmd_$1)$(why))';)
135+ log_print = echo '$(pound) $(call escsq,$(or $(quiet_cmd_$1),cmd_$1 $@))'; \
136+ echo ' $(call escsq,$(cmd_$1))';
137137
138138 # Delete the target on interruption
139139 #
@@ -156,8 +156,8 @@ delete-on-interrupt = \ · 16 unmodified lines
156156 $(foreach sig, HUP INT QUIT TERM PIPE, \
157157 trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);))
158158
159−# printing commands
160−cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(delete-on-interrupt) $(cmd_$(1))
159+# print and execute commands
160+cmd = @$(if $(cmd_$(1)),set -e; $($(quiet)log_print) $(delete-on-interrupt) $(cmd_$(1)),:)
161161
162162 ###
163163 # if_changed - execute command if any prerequisite is newer than
@@ -234,7 +234,7 @@ if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:) · 70 unmodified lines
234234 # (6) No dir/.target.cmd file and target not listed in $(targets)
235235 # This is a good hint that there is a bug in the kbuild file
236236 ifeq ($(KBUILD_VERBOSE),2)
237−why = \
237+_why = \
238238 $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
239239 $(if $(wildcard $@), \
240240 $(if $(newer-prereqs),- due to: $(newer-prereqs), \
@@ -251,7 +251,7 @@ why = \ · 10 unmodified lines
251251 ) \
252252 )
253253
254−echo-why = $(call escsq, $(strip $(why)))
254+why = $(space)$(strip $(_why))
255255 endif
256256
257257 ###############################################################################

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t