blob: 5f404075dfce80f58943b1eaae59797050cb2570 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001#
2# Copyright (C) 2007 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# When specifying "dist", the user has asked that we copy the important
18# files from this build into DIST_DIR.
19
Dan Willemsen78c40be2018-10-17 16:50:49 -070020# list of all goals that depend on any dist files
21_all_dist_goals :=
22# pairs of goal:distfile
23_all_dist_goal_output_pairs :=
24# pairs of srcfile:distfile
Ying Wang534fcd72013-03-01 16:45:35 -080025_all_dist_src_dst_pairs :=
Dan Willemsen78c40be2018-10-17 16:50:49 -070026
The Android Open Source Project88b60792009-03-03 19:28:42 -080027# Other parts of the system should use this function to associate
28# certain files with certain goals. When those goals are built
29# and "dist" is specified, the marked files will be copied to DIST_DIR.
30#
Dan Willemsen78c40be2018-10-17 16:50:49 -070031# $(1): a list of goals (e.g. droid, sdk, pdk, ndk). These must be PHONY
The Android Open Source Project88b60792009-03-03 19:28:42 -080032# $(2): the dist files to add to those goals. If the file contains ':',
33# the text following the colon is the name that the file is copied
34# to under the dist directory. Subdirs are ok, and will be created
35# at copy time if necessary.
36define dist-for-goals
Dan Willemsenc904e482018-10-20 16:59:41 -070037$(if $(strip $(2)), \
38 $(eval _all_dist_goals += $$(1))) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080039$(foreach file,$(2), \
Dan Willemsen78c40be2018-10-17 16:50:49 -070040 $(eval src := $(call word-colon,1,$(file))) \
41 $(eval dst := $(call word-colon,2,$(file))) \
42 $(if $(dst),,$(eval dst := $$(notdir $$(src)))) \
43 $(eval _all_dist_src_dst_pairs += $$(src):$$(dst)) \
44 $(foreach goal,$(1), \
45 $(eval _all_dist_goal_output_pairs += $$(goal):$$(dst))))
The Android Open Source Project88b60792009-03-03 19:28:42 -080046endef
47
Dan Willemsen78c40be2018-10-17 16:50:49 -070048#------------------------------------------------------------------
49# To be used at the end of the build to collect all the uses of
50# dist-for-goals, and write them into a file for the packaging step to use.
The Android Open Source Project88b60792009-03-03 19:28:42 -080051
Dan Willemsen78c40be2018-10-17 16:50:49 -070052# $(1): The file to write
53define dist-write-file
54$(strip \
55 $(KATI_obsolete_var dist-for-goals,Cannot be used after dist-write-file) \
56 $(foreach goal,$(sort $(_all_dist_goals)), \
57 $(eval $$(goal): _dist_$$(goal))) \
58 $(shell mkdir -p $(dir $(1))) \
59 $(file >$(1).tmp, \
60 DIST_GOAL_OUTPUT_PAIRS := $(sort $(_all_dist_goal_output_pairs)) \
61 $(newline)DIST_SRC_DST_PAIRS := $(sort $(_all_dist_src_dst_pairs))) \
62 $(shell if ! cmp -s $(1).tmp $(1); then \
63 mv $(1).tmp $(1); \
64 else \
65 rm $(1).tmp; \
66 fi))
The Android Open Source Project88b60792009-03-03 19:28:42 -080067endef
68
Dan Willemsen78c40be2018-10-17 16:50:49 -070069.KATI_READONLY := dist-for-goals dist-write-file