Merge "Deduplicate multiple $(inherit-product) calls"

This commit is contained in:
Cole Faust 2022-06-27 17:01:04 +00:00 committed by Gerrit Code Review
commit 556a556883
2 changed files with 9 additions and 19 deletions

View file

@ -83,27 +83,17 @@ endef
# If needle appears multiple times, only the first occurrance # If needle appears multiple times, only the first occurrance
# will survive. # will survive.
# #
# How it works:
#
# - Stick everything in haystack into a single word,
# with "|||" separating the words.
# - Replace occurrances of "|||$(needle)|||" with "||| |||",
# breaking haystack back into multiple words, with spaces
# where needle appeared.
# - Add needle between the first and second words of haystack.
# - Replace "|||" with spaces, breaking haystack back into
# individual words.
#
define uniq-word define uniq-word
$(strip \ $(strip \
$(if $(filter-out 0 1,$(words $(filter $(2),$(1)))), \ $(if $(filter-out 0 1,$(words $(filter $(2),$(1)))), \
$(eval h := |||$(subst $(space),|||,$(strip $(1)))|||) \ $(eval _uniq_word_seen :=) \
$(eval h := $(subst |||$(strip $(2))|||,|||$(space)|||,$(h))) \ $(foreach w,$(1), \
$(eval h := $(word 1,$(h)) $(2) $(wordlist 2,9999,$(h))) \ $(if $(filter $(2),$(w)), \
$(subst |||,$(space),$(h)) \ $(if $(_uniq_word_seen),, \
, \ $(w) \
$(1) \ $(eval _uniq_word_seen := true)), \
)) $(w))), \
$(1)))
endef endef
INHERIT_TAG := @inherit: INHERIT_TAG := @inherit:

View file

@ -404,7 +404,7 @@ define inherit-product
$(eval current_mk := $(strip $(word 1,$(_include_stack)))) \ $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
$(eval inherit_var := PRODUCTS.$(current_mk).INHERITS_FROM) \ $(eval inherit_var := PRODUCTS.$(current_mk).INHERITS_FROM) \
$(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \ $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
$(call dump-inherit,$(strip $(word 1,$(_include_stack))),$(1)) \ $(call dump-inherit,$(current_mk),$(1)) \
$(call dump-config-vals,$(current_mk),inherit)) $(call dump-config-vals,$(current_mk),inherit))
endef endef