Deduplicate my_compat_dist entries globally.
Cherrypick of aosp/1413709
Merged-In: Ie47e355ded0ce0221988a405fc77546a4a752c38
Fixes: 164319611
Test: m TARGET_PRODUCT=aosp_x86_64 mts dist
Change-Id: Ie47e355ded0ce0221988a405fc77546a4a752c38
diff --git a/core/definitions.mk b/core/definitions.mk
index 89c2e27..7dc3e99 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -111,6 +111,9 @@
# All compatibility suites mentioned in LOCAL_COMPATIBILITY_SUITES
ALL_COMPATIBILITY_SUITES :=
+# All compatibility suite files to dist.
+ALL_COMPATIBILITY_DIST_FILES :=
+
# All LINK_TYPE entries
ALL_LINK_TYPES :=
@@ -2903,6 +2906,7 @@
# 2. Add all the files to each suite's dependent files list.
# 3. Do the dependency addition to my_all_targets.
# 4. Save the module name to COMPATIBILITY.$(suite).MODULES for each suite.
+# 5. Collect files to dist to ALL_COMPATIBILITY_DIST_FILES.
# Requires for each suite: use my_compat_dist_config_$(suite) to define the test config.
# and use my_compat_dist_$(suite) to define the others.
define create-suite-dependencies
@@ -2913,10 +2917,13 @@
$(eval COMPATIBILITY.$(suite).MODULES :=)) \
$(eval COMPATIBILITY.$(suite).FILES += \
$$(foreach f,$$(my_compat_dist_$(suite)),$$(call word-colon,2,$$(f))) \
- $$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f)))) \
+ $$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f))) \
+ $$(my_compat_dist_test_data_$(suite))) \
+ $(eval ALL_COMPATIBILITY_DIST_FILES += $$(my_compat_dist_$(suite))) \
$(eval COMPATIBILITY.$(suite).MODULES += $$(my_register_name))) \
-$(eval $(my_all_targets) : $(call copy-many-files, \
- $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_$(suite))))) \
+$(eval $(my_all_targets) : \
+ $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE), \
+ $(foreach f,$(my_compat_dist_$(suite)), $(call word-colon,2,$(f))))) \
$(call copy-many-xml-files-checked, \
$(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_config_$(suite))))))
endef
diff --git a/core/main.mk b/core/main.mk
index b6bc7c8..257ae29 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1276,6 +1276,10 @@
test_files :=
endif
+# Dedpulicate compatibility suite dist files across modules and packages before
+# copying them to their requested locations. Assign the eval result to an unused
+# var to prevent Make from trying to make a sense of it.
+_unused := $(call copy-many-files, $(sort $(ALL_COMPATIBILITY_DIST_FILES)))
# Don't include any GNU General Public License shared objects or static
# libraries in SDK images. GPL executables (not static/dynamic libraries)