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
56# Beautify output56# Beautify output
57# ---------------------------------------------------------------------------57# ---------------------------------------------------------------------------
58#58#
59# Normally, we echo the whole command before executing it. By making59# Most of build commands in Kbuild start with "cmd_". You can optionally define
60# that echo $($(quiet)$(cmd)), we now have the possibility to set60# "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from
61# $(quiet) to choose other forms of output instead, e.g.61# that command is printed by default.
62#62#
63# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@63# e.g.)
64# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<64# quiet_cmd_depmod = DEPMOD $(MODLIB)
65#65# cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE)
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.
70#66#
71# A simple variant is to prefix commands with $(Q) - that's useful67# A simple variant is to prefix commands with $(Q) - that's useful
72# for commands that shall be hidden in non-verbose mode.68# for commands that shall be hidden in non-verbose mode.
73#69#
74# $(Q)ln $@ :<70# $(Q)$(MAKE) $(build)=scripts/basic
75#71#
76# If KBUILD_VERBOSE equals 0 then the above command will be hidden.72# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
77# If KBUILD_VERBOSE equals 1 then the above command is displayed.73# 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
125# $(Q)$(MAKE) $(clean)=dir125# $(Q)$(MAKE) $(clean)=dir
126clean := -f $(srctree)/scripts/Makefile.clean obj126clean := -f $(srctree)/scripts/Makefile.clean obj
127 127
128# echo command.128# pring log
129# Short version is used, if $(quiet) equals `quiet_', otherwise full one.129#
130echo-cmd = $(if $($(quiet)cmd_$(1)),\130# If quiet is "silent_", print nothing and sink stdout
131 echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)131# If quiet is "quiet_", print short log
132 132# If quiet is empty, print short log and whole command
133# sink stdout for 'make -s'133silent_log_print = exec >/dev/null;
134 redirect :=134 quiet_log_print = $(if $(quiet_cmd_$1), echo ' $(call escsq,$(quiet_cmd_$1)$(why))';)
135 quiet_redirect :=135 log_print = echo '$(pound) $(call escsq,$(or $(quiet_cmd_$1),cmd_$1 $@))'; \
136silent_redirect := exec >/dev/null;136 echo ' $(call escsq,$(cmd_$1))';
137 137
138# Delete the target on interruption138# Delete the target on interruption
139#139#
@@ -156,8 +156,8 @@ delete-on-interrupt = \ · 16 unmodified lines
156 $(foreach sig, HUP INT QUIT TERM PIPE, \156 $(foreach sig, HUP INT QUIT TERM PIPE, \
157 trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);))157 trap 'rm -f $@; trap - $(sig); kill -s $(sig) $$$$' $(sig);))
158 158
159# printing commands159# print and execute commands
160cmd = @set -e; $(echo-cmd) $($(quiet)redirect) $(delete-on-interrupt) $(cmd_$(1))160cmd = @$(if $(cmd_$(1)),set -e; $($(quiet)log_print) $(delete-on-interrupt) $(cmd_$(1)),:)
161 161
162###162###
163# if_changed - execute command if any prerequisite is newer than163# 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
234# (6) No dir/.target.cmd file and target not listed in $(targets)234# (6) No dir/.target.cmd file and target not listed in $(targets)
235# This is a good hint that there is a bug in the kbuild file235# This is a good hint that there is a bug in the kbuild file
236ifeq ($(KBUILD_VERBOSE),2)236ifeq ($(KBUILD_VERBOSE),2)
237why = \237_why = \
238 $(if $(filter $@, $(PHONY)),- due to target is PHONY, \238 $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
239 $(if $(wildcard $@), \239 $(if $(wildcard $@), \
240 $(if $(newer-prereqs),- due to: $(newer-prereqs), \240 $(if $(newer-prereqs),- due to: $(newer-prereqs), \
@@ -251,7 +251,7 @@ why = \ · 10 unmodified lines
251 ) \251 ) \
252 )252 )
253 253
254echo-why = $(call escsq, $(strip $(why)))254why = $(space)$(strip $(_why))
255endif255endif
256 256
257###############################################################################257###############################################################################

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