History

kbuild: save $(strip ...) for calling if_changed and friends

The string returned by $(filter-out ...) does not contain any leading or trailing spaces. With the previous commit, 'any-prereq' no longer contains any excessive spaces. Nor does 'cmd-check' since it expands to a $(filter-out ...) call. So, only the space that matters is the one between 'any-prereq' and 'cmd-check'. By removing it from the code, we can save $(strip ...) evaluation. This refactoring is possible because $(any-prereq)$(cmd-check) is only passed to the first argument of $(if ...), so we are only interested in whether or not it is empty.

Masahiro Yamada committed 7 years ago

Commit c2341e21 parent 93f31bb1 file · +3 −3Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/Kbuild.include+3−3
@@ -228,12 +228,12 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))) · 227 unmodified lines
228any-prereq = $(filter-out $(PHONY),$?)$(filter-out $(PHONY) $(wildcard $^),$^)228any-prereq = $(filter-out $(PHONY),$?)$(filter-out $(PHONY) $(wildcard $^),$^)
229 229
230# Execute command if command has changed or prerequisite(s) are updated.230# Execute command if command has changed or prerequisite(s) are updated.
231if_changed = $(if $(strip $(any-prereq) $(cmd-check)), \231if_changed = $(if $(any-prereq)$(cmd-check), \
232 $(cmd); \232 $(cmd); \
233 printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)233 printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
234 234
235# Execute the command and also postprocess generated .d dependencies file.235# Execute the command and also postprocess generated .d dependencies file.
236if_changed_dep = $(if $(strip $(any-prereq) $(cmd-check)),$(cmd_and_fixdep),@:)236if_changed_dep = $(if $(any-prereq)$(cmd-check),$(cmd_and_fixdep),@:)
237 237
238cmd_and_fixdep = \238cmd_and_fixdep = \
239 $(cmd); \239 $(cmd); \
@@ -243,7 +243,7 @@ cmd_and_fixdep = \ · 3 unmodified lines
243# Usage: $(call if_changed_rule,foo)243# Usage: $(call if_changed_rule,foo)
244# Will check if $(cmd_foo) or any of the prerequisites changed,244# Will check if $(cmd_foo) or any of the prerequisites changed,
245# and if so will execute $(rule_foo).245# and if so will execute $(rule_foo).
246if_changed_rule = $(if $(strip $(any-prereq) $(cmd-check)),$(rule_$(1)),@:)246if_changed_rule = $(if $(any-prereq)$(cmd-check),$(rule_$(1)),@:)
247 247
248###248###
249# why - tell why a target got built249# why - tell why a target got built