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
228228 any-prereq = $(filter-out $(PHONY),$?)$(filter-out $(PHONY) $(wildcard $^),$^)
229229
230230 # Execute command if command has changed or prerequisite(s) are updated.
231−if_changed = $(if $(strip $(any-prereq) $(cmd-check)), \
231+if_changed = $(if $(any-prereq)$(cmd-check), \
232232 $(cmd); \
233233 printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
234234
235235 # Execute the command and also postprocess generated .d dependencies file.
236−if_changed_dep = $(if $(strip $(any-prereq) $(cmd-check)),$(cmd_and_fixdep),@:)
236+if_changed_dep = $(if $(any-prereq)$(cmd-check),$(cmd_and_fixdep),@:)
237237
238238 cmd_and_fixdep = \
239239 $(cmd); \
@@ -243,7 +243,7 @@ cmd_and_fixdep = \ · 3 unmodified lines
243243 # Usage: $(call if_changed_rule,foo)
244244 # Will check if $(cmd_foo) or any of the prerequisites changed,
245245 # and if so will execute $(rule_foo).
246−if_changed_rule = $(if $(strip $(any-prereq) $(cmd-check)),$(rule_$(1)),@:)
246+if_changed_rule = $(if $(any-prereq)$(cmd-check),$(rule_$(1)),@:)
247247
248248 ###
249249 # why - tell why a target got built