Uniq the system properties.
If multiple items with the same key appear in a config variable,
only the first item is taken.
Change-Id: Icf57befafb36ec35dd4d48c8c3ec595f353f68e7
diff --git a/core/Makefile b/core/Makefile
index 237245b..351dd15 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -16,17 +16,16 @@
# e.g., "system/etc/file.xml".
# The filter part means "only eval the copy-one-file rule if this
# src:dest pair is the first one to match the same dest"
-unique_product_copy_files_destinations := $(sort \
- $(foreach cf,$(PRODUCT_COPY_FILES), $(call word-colon,2,$(cf))))
+unique_product_copy_files_destinations :=
$(foreach cf,$(PRODUCT_COPY_FILES), \
$(eval _src := $(call word-colon,1,$(cf))) \
$(eval _dest := $(call word-colon,2,$(cf))) \
- $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
+ $(if $(filter $(unique_product_copy_files_destinations),$(_dest)),, \
$(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
$(eval $(call copy-one-file,$(_src),$(_fulldest))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
- $(eval unique_product_copy_files_destinations := $(filter-out $(_dest), \
- $(unique_product_copy_files_destinations)))))
+ $(eval unique_product_copy_files_destinations += $(_dest))))
+unique_product_copy_files_destinations :=
# -----------------------------------------------------------------
# docs/index.html
@@ -41,9 +40,11 @@
INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
ADDITIONAL_DEFAULT_PROPERTIES := \
- $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
+ $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
ADDITIONAL_DEFAULT_PROPERTIES += \
- $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+ $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(ADDITIONAL_DEFAULT_PROPERTIES),=)
$(INSTALLED_DEFAULT_PROP_TARGET):
@echo Target buildinfo: $@
@@ -60,7 +61,9 @@
INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
ADDITIONAL_BUILD_PROPERTIES := \
- $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+ $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+ $(ADDITIONAL_BUILD_PROPERTIES),=)
# A list of arbitrary tags describing the build configuration.
# Force ":=" so we can use +=
diff --git a/core/definitions.mk b/core/definitions.mk
index 9251017..4c499ad 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -600,6 +600,21 @@
endef
###########################################################
+## Given a list of pairs, if multiple pairs have the same
+## first components, keep only the first pair.
+##
+## $(1): list of pairs
+## $(2): the separator word, such as ":", "=", etc.
+define uniq-pairs-by-first-component
+$(eval _upbfc_fc_set :=)\
+$(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\
+ $(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\
+ $(eval _upbfc_fc_set += $(_first)))))\
+$(eval _upbfc_fc_set :=)\
+$(eval _first:=)
+endef
+
+###########################################################
## MODULE_TAG set operations
###########################################################