OSDN Git Service

De-dupe PRODUCT_COPY_FILES
authorJean-Baptiste Queru <jbq@google.com>
Tue, 2 Mar 2010 00:18:59 +0000 (16:18 -0800)
committerJean-Baptiste Queru <jbq@google.com>
Tue, 2 Mar 2010 00:22:10 +0000 (16:22 -0800)
This allows to explicitly deal with situations where we
want to use PRODUCT_COPY_FILES to manage overrides.

Change-Id: I2f87862e19b973f090099f335e9bdeb0c9f3bfe9

core/Makefile

index a232e13..1ae7460 100644 (file)
@@ -14,12 +14,15 @@ endif
 # PRODUCT_COPY_FILES contains words like <source file>:<dest file>.
 # <dest file> is relative to $(PRODUCT_OUT), so it should look like,
 # 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 %:dest"
 $(foreach cf,$(PRODUCT_COPY_FILES), \
   $(eval _src := $(call word-colon,1,$(cf))) \
-  $(eval _dest := $(call \
-          append-path,$(PRODUCT_OUT),$(call word-colon,2,$(cf)))) \
-  $(eval $(call copy-one-file,$(_src),$(_dest))) \
-  $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_dest)) \
+  $(eval _dest := $(call word-colon,2,$(cf))) \
+  $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
+  $(if $(filter $(_src):$(_dest),$(firstword $(filter %:$(_dest),$(PRODUCT_COPY_FILES)))), \
+    $(eval $(call copy-one-file,$(_src),$(_fulldest))),) \
+  $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
  )
 
 # -----------------------------------------------------------------