Android编译脚本中,PRODUCT_COPY_FILES保存的是一组src:dest的字符串列表,如果碰到里面有重复的dest怎么办?
# filter out the duplicate <source file>:<dest file> pairs.
unique_product_copy_files_pairs :=
$(foreach cf,$(PRODUCT_COPY_FILES), \
$(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
$(eval unique_product_copy_files_pairs += $(cf))))unique_product_copy_files_destinations :=
$(foreach cf,$(unique_product_copy_files_pairs), \
$(eval _src := $(call word-colon,1,$(cf))) \
$(eval _dest := $(call word-colon,2,$(cf))) \
$(call check-product-copy-files,$(cf)) \
$(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
$(info PRODUCT_COPY_FILES $(cf) ignored.), \
$(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
$(if $(filter %.xml,$(_dest)),\
$(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
$(eval $(call copy-one-file,$(_src),$(_fulldest)))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
$(eval unique_product_copy_files_destinations += $(_dest))))明显,第一部将src:dest的重复去除,第二步,将dest的重复去除。
从去除重复的算法来看,是从第一个字符串开始,如果目标中没有就添加,如果已经有就不做任何处理,因此只有最先描述的目标有效。
如果在两个地方定义system/etc/apns-conf.xml:
./device/lge/mako/full_mako.mk:28:PRODUCT_COPY_FILES := device/lge/mako/apns-full-conf.xml:system/etc/apns-conf.xml
./build/target/product/full_base_telephony.mk:PRODUCT_COPY_FILES := device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml
则先出现定义的有效,即device/lge/mako/apns-full-conf.xml会有效。
在Android编译过程中,面对PRODUCT_COPY_FILES列表中的src:dest重复项,首次出现的定义会被保留。当dest相同而src不同的情况下,如system/etc/apns-conf.xml在两个位置定义,device/lge/mako/apns-full-conf.xml会生效。解决重复的关键在于对列表进行去重操作。
6668

被折叠的 条评论
为什么被折叠?



