summaryrefslogtreecommitdiffstats
path: root/core/distdir.mk
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2013-03-01 16:45:35 -0800
committerYing Wang <wangying@google.com>2013-03-01 16:51:26 -0800
commit534fcd766ecec602d9437d155066fc5253f1185a (patch)
tree020157dfc371548a02bb637d1228dd7d4a01dcf0 /core/distdir.mk
parent3e3a3a2b794531c517064cc115f8f5e00da07b4a (diff)
downloadbuild-534fcd766ecec602d9437d155066fc5253f1185a.zip
build-534fcd766ecec602d9437d155066fc5253f1185a.tar.gz
build-534fcd766ecec602d9437d155066fc5253f1185a.tar.bz2
Allow to call dist-for-goals multiple times for the same file
You can dist the same file for multiple goals in multiple calls to dist-for-goals. The first call will establish the real copy rule, while the rest call just establishes the goals' dependency on the dest file. This enable uss to remove the bizarre $(if ..) enclosing the droid and sdk dist while avoiding make's multiple rules warning. Change-Id: I76475db76a9e6167e0e606dd582b54e80dfcdd22
Diffstat (limited to 'core/distdir.mk')
-rw-r--r--core/distdir.mk20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/distdir.mk b/core/distdir.mk
index e04938b..51ec46e 100644
--- a/core/distdir.mk
+++ b/core/distdir.mk
@@ -41,6 +41,11 @@ $(2): $(1)
$$(copy-file-to-new-target-with-cp)
endef
+# A global variable to remember all dist'ed src:dst pairs.
+# So if a src:dst is already dist'ed by another goal,
+# we should just establish the dependency and don't really call the
+# copy-one-dist-file to avoid multiple rules for the same target.
+_all_dist_src_dst_pairs :=
# Other parts of the system should use this function to associate
# certain files with certain goals. When those goals are built
# and "dist" is specified, the marked files will be copied to DIST_DIR.
@@ -56,14 +61,13 @@ $(foreach file,$(2), \
$(eval src := $(word 1,$(fw))) \
$(eval dst := $(word 2,$(fw))) \
$(eval dst := $(if $(dst),$(dst),$(notdir $(src)))) \
- $(eval \
- $(call copy-one-dist-file, \
- $(src), \
- $(DIST_DIR)/$(dst), \
- $(1) \
- ) \
- ) \
- )
+ $(if $(filter $(_all_dist_src_dst_pairs),$(src):$(dst)),\
+ $(eval $(call add-dependency,$(1),$(DIST_DIR)/$(dst))),\
+ $(eval $(call copy-one-dist-file,\
+ $(src),$(DIST_DIR)/$(dst),$(1)))\
+ $(eval _all_dist_src_dst_pairs += $(src):$(dst))\
+ )\
+)
endef
else # !dist_goal