blob: a367a6bd20d6cb25d065d303914a69886d5861f1 [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#
18# Functions for including AndroidProducts.mk files
Ying Wang157a5e12012-09-27 13:26:25 -070019# PRODUCT_MAKEFILES is set up in AndroidProducts.mks.
20# Format of PRODUCT_MAKEFILES:
21# <product_name>:<path_to_the_product_makefile>
22# If the <product_name> is the same as the base file name (without dir
23# and the .mk suffix) of the product makefile, "<product_name>:" can be
24# omitted.
The Android Open Source Project88b60792009-03-03 19:28:42 -080025
26#
27# Returns the list of all AndroidProducts.mk files.
28# $(call ) isn't necessary.
29#
30define _find-android-products-files
Dan Willemsenb9d63512018-05-01 22:34:03 -070031$(file <$(OUT_DIR)/.module_paths/AndroidProducts.mk.list) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080032 $(SRC_TARGET_DIR)/product/AndroidProducts.mk
33endef
34
35#
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070036# For entries returned by get-product-makefiles, decode an entry to a short
37# product name. These either may be in the form of <name>:path/to/file.mk or
38# path/to/<name>.mk
39# $(1): The entry to decode
40#
41# Returns two words:
42# <name> <file>
43#
44define _decode-product-name
45$(strip \
46 $(eval _cpm_words := $(subst :,$(space),$(1))) \
47 $(if $(word 2,$(_cpm_words)), \
48 $(wordlist 1,2,$(_cpm_words)), \
49 $(basename $(notdir $(1))) $(1)))
50endef
51
52#
53# Validates the new common lunch choices -- ensures that they're in an
54# appropriate form, and are paired with definitions of their products.
55# $(1): The new list of COMMON_LUNCH_CHOICES
56# $(2): The new list of PRODUCT_MAKEFILES
57#
58define _validate-common-lunch-choices
59$(strip $(foreach choice,$(1),\
60 $(eval _parts := $(subst -,$(space),$(choice))) \
61 $(if $(call math_lt,$(words $(_parts)),2), \
62 $(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
63 $(if $(call math_gt_or_eq,$(words $(_parts)),4), \
64 $(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
65 $(if $(filter-out eng userdebug user,$(word 2,$(_parts))), \
66 $(error $(LOCAL_DIR): $(choice): Invalid variant: $(word 2,$(_parts)))) \
67 $(if $(filter-out $(foreach p,$(2),$(call _decode-product-name,$(p))),$(word 1,$(_parts))), \
68 $(error $(LOCAL_DIR): $(word 1,$(_parts)): Product not defined in this file)) \
69 ))
70endef
71
72#
Ying Wang1a031e42010-05-10 16:35:39 -070073# Returns the sorted concatenation of PRODUCT_MAKEFILES
74# variables set in the given AndroidProducts.mk files.
75# $(1): the list of AndroidProducts.mk files.
The Android Open Source Project88b60792009-03-03 19:28:42 -080076#
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070077# As a side-effect, COMMON_LUNCH_CHOICES will be set to a
78# union of all of the COMMON_LUNCH_CHOICES definitions within
79# each AndroidProducts.mk file.
80#
Ying Wang1a031e42010-05-10 16:35:39 -070081define get-product-makefiles
The Android Open Source Project88b60792009-03-03 19:28:42 -080082$(sort \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070083 $(eval _COMMON_LUNCH_CHOICES :=) \
Ying Wang1a031e42010-05-10 16:35:39 -070084 $(foreach f,$(1), \
The Android Open Source Project88b60792009-03-03 19:28:42 -080085 $(eval PRODUCT_MAKEFILES :=) \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070086 $(eval COMMON_LUNCH_CHOICES :=) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080087 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
88 $(eval include $(f)) \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070089 $(call _validate-common-lunch-choices,$(COMMON_LUNCH_CHOICES),$(PRODUCT_MAKEFILES)) \
90 $(eval _COMMON_LUNCH_CHOICES += $(COMMON_LUNCH_CHOICES)) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080091 $(PRODUCT_MAKEFILES) \
92 ) \
93 $(eval PRODUCT_MAKEFILES :=) \
94 $(eval LOCAL_DIR :=) \
Dan Willemsen5436c7e2019-02-11 21:31:47 -080095 $(eval COMMON_LUNCH_CHOICES := $(sort $(_COMMON_LUNCH_CHOICES))) \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070096 $(eval _COMMON_LUNCH_CHOICES :=) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080097 )
98endef
99
100#
Ying Wang1a031e42010-05-10 16:35:39 -0700101# Returns the sorted concatenation of all PRODUCT_MAKEFILES
102# variables set in all AndroidProducts.mk files.
103# $(call ) isn't necessary.
104#
105define get-all-product-makefiles
106$(call get-product-makefiles,$(_find-android-products-files))
107endef
108
109#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800110# Functions for including product makefiles
111#
112
113_product_var_list := \
114 PRODUCT_NAME \
115 PRODUCT_MODEL \
116 PRODUCT_LOCALES \
Ying Wang4f1ab922011-03-15 13:19:30 -0700117 PRODUCT_AAPT_CONFIG \
Dianne Hackborna0f464a2011-10-14 19:37:57 -0700118 PRODUCT_AAPT_PREF_CONFIG \
Ying Wang60686582014-12-10 12:40:09 -0800119 PRODUCT_AAPT_PREBUILT_DPI \
Dan Willemsen3d05a082019-02-22 23:06:03 +0000120 PRODUCT_HOST_PACKAGES \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800121 PRODUCT_PACKAGES \
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700122 PRODUCT_PACKAGES_DEBUG \
Zach Riggle9323b7f2018-03-26 16:17:03 -0500123 PRODUCT_PACKAGES_DEBUG_ASAN \
Joe Onoratod7d0afc2012-06-05 15:54:09 -0700124 PRODUCT_PACKAGES_ENG \
125 PRODUCT_PACKAGES_TESTS \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800126 PRODUCT_DEVICE \
127 PRODUCT_MANUFACTURER \
128 PRODUCT_BRAND \
129 PRODUCT_PROPERTY_OVERRIDES \
Mike Lockwood0d23fec2011-06-09 14:54:40 -0700130 PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900131 PRODUCT_PRODUCT_PROPERTIES \
Dario Freni5f681e12018-05-29 13:09:01 +0100132 PRODUCT_PRODUCT_SERVICES_PROPERTIES \
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800133 PRODUCT_ODM_PROPERTIES \
Joe Onorato700b88e2010-10-05 17:33:58 -0400134 PRODUCT_CHARACTERISTICS \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800135 PRODUCT_COPY_FILES \
136 PRODUCT_OTA_PUBLIC_KEYS \
Doug Zongker5d4808d2011-03-16 07:49:13 -0700137 PRODUCT_EXTRA_RECOVERY_KEYS \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800138 PRODUCT_PACKAGE_OVERLAYS \
139 DEVICE_PACKAGE_OVERLAYS \
Jaekyun Seokccee95e2017-09-01 17:23:25 +0900140 PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS \
Jaekyun Seok1b224282017-03-30 11:25:02 +0900141 PRODUCT_ENFORCE_RRO_TARGETS \
Ying Wang780128a2014-01-29 13:35:55 -0800142 PRODUCT_SDK_ATREE_FILES \
Joe Onorato214a42b2009-04-09 20:36:06 -0700143 PRODUCT_SDK_ADDON_NAME \
144 PRODUCT_SDK_ADDON_COPY_FILES \
145 PRODUCT_SDK_ADDON_COPY_MODULES \
Ying Wanga032d3d2011-11-11 10:52:12 -0800146 PRODUCT_SDK_ADDON_DOC_MODULES \
Raphael Moll0d7d09a2014-08-21 15:22:08 -0700147 PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
Jeff Gaston1fe28d32017-11-21 15:05:07 -0800148 PRODUCT_SOONG_NAMESPACES \
Ying Wang3c21fe52011-10-04 10:50:08 -0700149 PRODUCT_DEFAULT_WIFI_CHANNELS \
150 PRODUCT_DEFAULT_DEV_CERTIFICATE \
Ying Wangdbb31be2011-12-09 15:11:57 -0800151 PRODUCT_RESTRICT_VENDOR_FILES \
Dima Zavinf9269902012-03-16 09:57:11 -0700152 PRODUCT_VENDOR_KERNEL_HEADERS \
Geremy Condrafd6f7512013-06-16 17:26:08 -0700153 PRODUCT_BOOT_JARS \
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +0100154 PRODUCT_SUPPORTS_BOOT_SIGNER \
David Riley17be3d32015-03-03 08:54:11 -0800155 PRODUCT_SUPPORTS_VBOOT \
Geremy Condrafd6f7512013-06-16 17:26:08 -0700156 PRODUCT_SUPPORTS_VERITY \
Sami Tolvanenf99b5312015-05-20 07:30:57 +0100157 PRODUCT_SUPPORTS_VERITY_FEC \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700158 PRODUCT_OEM_PROPERTIES \
Jaekyun Seokb31b9ba2017-11-03 15:18:55 +0900159 PRODUCT_SYSTEM_DEFAULT_PROPERTIES \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700160 PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
Ivan Podogovd5726322018-03-29 15:22:33 +0100161 PRODUCT_VENDOR_PROPERTY_BLACKLIST \
Nicolas Geoffrayb08ada12017-03-22 12:36:05 +0000162 PRODUCT_SYSTEM_SERVER_APPS \
Narayan Kamath89ec4962014-08-05 14:51:08 +0100163 PRODUCT_SYSTEM_SERVER_JARS \
Mathieu Chartier55eabd52017-09-15 13:40:48 -0700164 PRODUCT_ALWAYS_PREOPT_EXTRACTED_APK \
Nicolas Geoffray4a0ad4a2017-06-12 15:19:16 +0100165 PRODUCT_DEXPREOPT_SPEED_APPS \
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +0100166 PRODUCT_LOADED_BY_PRIVILEGED_MODULES \
David Riley17be3d32015-03-03 08:54:11 -0800167 PRODUCT_VBOOT_SIGNING_KEY \
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700168 PRODUCT_VBOOT_SIGNING_SUBKEY \
Geremy Condra5b5f4952014-05-05 22:19:37 -0700169 PRODUCT_VERITY_SIGNING_KEY \
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -0700170 PRODUCT_SYSTEM_VERITY_PARTITION \
Ying Wang87557562014-10-09 19:29:53 -0700171 PRODUCT_VENDOR_VERITY_PARTITION \
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900172 PRODUCT_PRODUCT_VERITY_PARTITION \
Dario Freni5f681e12018-05-29 13:09:01 +0100173 PRODUCT_PRODUCT_SERVICES_VERITY_PARTITION \
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800174 PRODUCT_ODM_VERITY_PARTITION \
Mathieu Chartierf0db9082017-06-23 14:47:56 -0700175 PRODUCT_SYSTEM_SERVER_DEBUG_INFO \
Andreas Gampec3e15192018-03-19 14:28:15 -0700176 PRODUCT_OTHER_JAVA_DEBUG_INFO \
Ying Wang20ebd2e2014-10-07 18:07:23 -0700177 PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
Mathieu Chartiere8fb7cf2018-02-15 13:19:38 -0800178 PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER \
Ying Wang20ebd2e2014-10-07 18:07:23 -0700179 PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
180 PRODUCT_DEX_PREOPT_BOOT_FLAGS \
Mathieu Chartierfcc8d8b2017-05-05 17:22:37 -0700181 PRODUCT_DEX_PREOPT_PROFILE_DIR \
Mathieu Chartiera61acf62017-06-28 18:23:37 -0700182 PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION \
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800183 PRODUCT_DEX_PREOPT_GENERATE_DM_FILES \
Nicolas Geoffray98f5e862019-02-12 13:12:47 +0000184 PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING \
Mathieu Chartiera61acf62017-06-28 18:23:37 -0700185 PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE \
Mathieu Chartier6228ec22017-06-23 10:44:45 -0700186 PRODUCT_SYSTEM_SERVER_COMPILER_FILTER \
Andreas Gampe6b30d772016-06-27 15:15:31 -0700187 PRODUCT_SANITIZER_MODULE_CONFIGS \
Mohamad Ayyash1868a602016-04-22 17:22:07 -0700188 PRODUCT_SYSTEM_BASE_FS_PATH \
189 PRODUCT_VENDOR_BASE_FS_PATH \
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900190 PRODUCT_PRODUCT_BASE_FS_PATH \
Dario Freni5f681e12018-05-29 13:09:01 +0100191 PRODUCT_PRODUCT_SERVICES_BASE_FS_PATH \
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800192 PRODUCT_ODM_BASE_FS_PATH \
Gustav Sennton81ee1862016-05-27 14:07:54 +0100193 PRODUCT_SHIPPING_API_LEVEL \
Hung-ying Tyan3c054d82016-05-20 19:08:30 +0800194 VENDOR_PRODUCT_RESTRICT_VENDOR_FILES \
195 VENDOR_EXCEPTION_MODULES \
196 VENDOR_EXCEPTION_PATHS \
Andreas Gampe831fc712017-06-30 11:36:26 -0700197 PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD \
Hiroshi Yamauchi64594c42016-12-15 16:00:41 -0800198 PRODUCT_ART_USE_READ_BARRIER \
Alex Deymo8fe63c32017-03-02 22:08:41 -0800199 PRODUCT_IOT \
Julius D'souza001c6762017-05-03 13:43:27 -0700200 PRODUCT_SYSTEM_HEADROOM \
Przemyslaw Szczepaniak2e81b3c2017-06-30 14:51:12 +0100201 PRODUCT_MINIMIZE_JAVA_DEBUG_INFO \
Ivan Lozano9a82bfd2017-07-13 14:49:12 -0700202 PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS \
Dan Willemsen0bd79382017-11-03 15:53:52 -0700203 PRODUCT_ADB_KEYS \
Vishwath Mohan23b2d2e2017-10-31 02:25:16 -0700204 PRODUCT_CFI_INCLUDE_PATHS \
205 PRODUCT_CFI_EXCLUDE_PATHS \
Kostya Kortchinsky02732402019-02-01 09:06:42 -0800206 PRODUCT_DISABLE_SCUDO \
Jaekyun Seok0538ff72018-01-16 14:14:59 +0900207 PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE \
208 PRODUCT_ACTIONABLE_COMPATIBLE_PROPERTY_DISABLE \
Anton Hansson427d8552018-06-05 17:53:09 +0100209 PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS \
Jeongik Chab2c4bb72018-12-17 14:45:15 +0900210 PRODUCT_ENFORCE_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT \
211 PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_WHITELIST \
Anton Hansson83ba31c2018-10-12 16:15:49 +0100212 PRODUCT_ARTIFACT_PATH_REQUIREMENT_HINT \
Anton Hansson427d8552018-06-05 17:53:09 +0100213 PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST \
Yifan Hong2dae5722018-07-31 12:47:27 -0700214 PRODUCT_USE_DYNAMIC_PARTITION_SIZE \
215 PRODUCT_BUILD_SUPER_PARTITION \
Dario Frenif31bc452018-07-12 19:44:33 +0100216 PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION \
Yifan Hongc5c01242018-11-09 10:27:23 -0800217 PRODUCT_USE_DYNAMIC_PARTITIONS \
David Anderson619fe2d2018-10-30 18:47:59 -0700218 PRODUCT_RETROFIT_DYNAMIC_PARTITIONS \
Yifan Hong452d9262018-11-07 16:46:45 -0800219 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
Ivan Lozanofda9a6f2018-11-21 09:04:18 -0800220 PRODUCT_XOM_EXCLUDE_PATHS \
Jiyong Park185d41e2019-01-05 12:57:54 +0900221 PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES \
Jaewoong Jung7dfae502019-01-28 16:19:33 -0800222 PRODUCT_PACKAGE_NAME_OVERRIDES \
223 PRODUCT_CERTIFICATE_OVERRIDES \
Dan Willemsen67495202019-01-16 12:42:05 -0800224 PRODUCT_BUILD_SYSTEM_IMAGE \
225 PRODUCT_BUILD_SYSTEM_OTHER_IMAGE \
226 PRODUCT_BUILD_VENDOR_IMAGE \
227 PRODUCT_BUILD_PRODUCT_IMAGE \
228 PRODUCT_BUILD_PRODUCT_SERVICES_IMAGE \
229 PRODUCT_BUILD_ODM_IMAGE \
230 PRODUCT_BUILD_CACHE_IMAGE \
231 PRODUCT_BUILD_RAMDISK_IMAGE \
232 PRODUCT_BUILD_USERDATA_IMAGE \
Dongwon Kang167758a2019-01-18 08:26:30 -0800233 PRODUCT_UPDATABLE_BOOT_MODULES \
234 PRODUCT_UPDATABLE_BOOT_LOCATIONS \
Logan Chien0e53d882018-11-06 17:32:40 +0800235 PRODUCT_CHECK_ELF_FILES \
Ying Wang20ebd2e2014-10-07 18:07:23 -0700236
The Android Open Source Project88b60792009-03-03 19:28:42 -0800237define dump-product
Anton Hanssondce3f922019-02-11 21:19:54 +0000238$(warning ==== $(1) ====)\
The Android Open Source Project88b60792009-03-03 19:28:42 -0800239$(foreach v,$(_product_var_list),\
Anton Hanssondce3f922019-02-11 21:19:54 +0000240$(warning PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
241$(warning --------)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800242endef
243
244define dump-products
245$(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
246endef
247
248#
249# $(1): product to inherit
250#
Anton Hansson061cbcf2018-05-30 18:24:41 +0100251# To be called from product makefiles, and is later evaluated during the import-nodes
252# call below. It does three things:
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800253# 1. Inherits all of the variables from $1.
254# 2. Records the inheritance in the .INHERITS_FROM variable
Anton Hansson061cbcf2018-05-30 18:24:41 +0100255# 3. Records the calling makefile in PARENT_PRODUCT_FILES
256#
257# (2) and (3) can be used together to reconstruct the include hierarchy
258# See e.g. product-graph.mk for an example of this.
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800259#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800260define inherit-product
Ying Wanga1742612015-10-28 14:33:40 -0700261 $(if $(findstring ../,$(1)),\
262 $(eval np := $(call normalize-paths,$(1))),\
263 $(eval np := $(strip $(1))))\
The Android Open Source Project88b60792009-03-03 19:28:42 -0800264 $(foreach v,$(_product_var_list), \
Ying Wanga1742612015-10-28 14:33:40 -0700265 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
Anton Hansson061cbcf2018-05-30 18:24:41 +0100266 $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
267 $(eval inherit_var := PRODUCTS.$(current_mk).INHERITS_FROM) \
Ying Wanga1742612015-10-28 14:33:40 -0700268 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
Anton Hansson061cbcf2018-05-30 18:24:41 +0100269 $(eval PARENT_PRODUCT_FILES := $(sort $(PARENT_PRODUCT_FILES) $(current_mk)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800270endef
271
Anton Hansson837425b2018-06-01 14:18:14 +0100272# Specifies a number of path prefixes, relative to PRODUCT_OUT, where the
273# product makefile hierarchy rooted in the current node places its artifacts.
274# Creating artifacts outside the specified paths will cause a build-time error.
275define require-artifacts-in-path
276 $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
277 $(eval PRODUCTS.$(current_mk).ARTIFACT_PATH_REQUIREMENTS := $(strip $(1))) \
278 $(eval PRODUCTS.$(current_mk).ARTIFACT_PATH_WHITELIST := $(strip $(2))) \
279 $(eval ARTIFACT_PATH_REQUIREMENT_PRODUCTS := \
280 $(sort $(ARTIFACT_PATH_REQUIREMENT_PRODUCTS) $(current_mk)))
281endef
Joe Onorato28a846d2010-02-22 10:33:05 -0800282
Anton Hansson1ebcbd52018-07-04 17:17:23 +0100283# Makes including non-existant modules in PRODUCT_PACKAGES an error.
284# $(1): whitelist of non-existant modules to allow.
285define enforce-product-packages-exist
286 $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
287 $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST := true) \
288 $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_WHITELIST := $(1)) \
289 $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST) \
290 $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_WHITELIST)
291endef
292
Joe Onorato28a846d2010-02-22 10:33:05 -0800293#
294# Do inherit-product only if $(1) exists
295#
296define inherit-product-if-exists
297 $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
298endef
299
The Android Open Source Project88b60792009-03-03 19:28:42 -0800300#
301# $(1): product makefile list
302#
303#TODO: check to make sure that products have all the necessary vars defined
304define import-products
305$(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
306endef
307
308
309#
310# Does various consistency checks on all of the known products.
311# Takes no parameters, so $(call ) is not necessary.
312#
313define check-all-products
314$(if ,, \
315 $(eval _cap_names :=) \
316 $(foreach p,$(PRODUCTS), \
317 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
318 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
319 $(if $(filter $(pn),$(_cap_names)), \
320 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
321 $(foreach \
322 pp,$(PRODUCTS),
323 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
324 $(pp) \
325 ))) \
326 ) \
327 ) \
328 $(eval _cap_names += $(pn)) \
329 $(if $(call is-c-identifier,$(pn)),, \
330 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
331 ) \
332 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
333 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
334 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
Ying Wang4b0486b2012-09-20 16:35:36 -0700335 $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800336 $(error $(p): malformed COPY_FILE "$(cf)") \
337 ) \
338 ) \
339 ) \
340)
341endef
342
343
344#
345# Returns the product makefile path for the product with the provided name
346#
347# $(1): short product name like "generic"
348#
349define _resolve-short-product-name
350 $(eval pn := $(strip $(1)))
351 $(eval p := \
352 $(foreach p,$(PRODUCTS), \
353 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
354 $(p) \
355 )) \
356 )
357 $(eval p := $(sort $(p)))
358 $(if $(filter 1,$(words $(p))), \
359 $(p), \
360 $(if $(filter 0,$(words $(p))), \
361 $(error No matches for product "$(pn)"), \
362 $(error Product "$(pn)" ambiguous: matches $(p)) \
363 ) \
364 )
365endef
366define resolve-short-product-name
367$(strip $(call _resolve-short-product-name,$(1)))
368endef
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400369
Anton Hanssond488d2d2019-02-26 15:49:25 +0000370_product_stash_var_list := $(_product_var_list)
371# TODO: Move this to board_config.mk when no longer set in product makefiles
372_product_stash_var_list += WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY
373_product_strip_var_list :=
Yifan Honge5d879a2018-11-27 11:37:38 -0800374
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400375#
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700376# Mark the variables in _product_stash_var_list as readonly
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400377#
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700378define readonly-product-vars
Ying Wangf9953b42010-12-29 14:07:38 -0800379$(foreach v,$(_product_stash_var_list), \
Anton Hansson70222b22019-02-21 10:41:03 +0000380 $(eval $(v) ?=) \
381 $(eval .KATI_READONLY := $(v)) \
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400382 )
383endef
384
Yifan Honge5d879a2018-11-27 11:37:38 -0800385#
386# Strip the variables in _product_strip_var_list
387#
388define strip-product-vars
389$(foreach v,$(_product_strip_var_list),$(eval $(v) := $(strip $($(v)))))
390endef
391
Keun young Parkc41c5f42012-05-30 10:22:29 -0700392define add-to-product-copy-files-if-exists
393$(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
394endef
Ying Wang20ebd2e2014-10-07 18:07:23 -0700395
396# whitespace placeholder when we record module's dex-preopt config.
397_PDPMC_SP_PLACE_HOLDER := |@SP@|
398# Set up dex-preopt config for a module.
399# $(1) list of module names
400# $(2) the modules' dex-preopt config
401define add-product-dex-preopt-module-config
402$(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
403$(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
404 $(foreach m,$(1),$(m)=$(_c)))
405endef
Andreas Gampe6b30d772016-06-27 15:15:31 -0700406
407# whitespace placeholder when we record module's sanitizer config.
408_PSMC_SP_PLACE_HOLDER := |@SP@|
409# Set up sanitizer config for a module.
410# $(1) list of module names
411# $(2) the modules' sanitizer config
412define add-product-sanitizer-module-config
413$(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
414$(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
415 $(foreach m,$(1),$(m)=$(_c)))
416endef