blob: cf622830a44e07b6a69c61f616375e2cca72261a [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
Ying Wang7dfdb842016-03-03 20:57:21 -080026# Search for AndroidProducts.mks in the given dir.
27# $(1): the path to the dir
28define _search-android-products-files-in-dir
29$(sort $(shell test -d $(1) && find -L $(1) \
30 -maxdepth 6 \
31 -name .git -prune \
32 -o -name AndroidProducts.mk -print))
33endef
34
The Android Open Source Project88b60792009-03-03 19:28:42 -080035#
36# Returns the list of all AndroidProducts.mk files.
37# $(call ) isn't necessary.
38#
39define _find-android-products-files
Ying Wang7dfdb842016-03-03 20:57:21 -080040$(foreach d, device vendor product,$(call _search-android-products-files-in-dir,$(d))) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080041 $(SRC_TARGET_DIR)/product/AndroidProducts.mk
42endef
43
44#
Ying Wang1a031e42010-05-10 16:35:39 -070045# Returns the sorted concatenation of PRODUCT_MAKEFILES
46# variables set in the given AndroidProducts.mk files.
47# $(1): the list of AndroidProducts.mk files.
The Android Open Source Project88b60792009-03-03 19:28:42 -080048#
Ying Wang1a031e42010-05-10 16:35:39 -070049define get-product-makefiles
The Android Open Source Project88b60792009-03-03 19:28:42 -080050$(sort \
Ying Wang1a031e42010-05-10 16:35:39 -070051 $(foreach f,$(1), \
The Android Open Source Project88b60792009-03-03 19:28:42 -080052 $(eval PRODUCT_MAKEFILES :=) \
53 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
54 $(eval include $(f)) \
55 $(PRODUCT_MAKEFILES) \
56 ) \
57 $(eval PRODUCT_MAKEFILES :=) \
58 $(eval LOCAL_DIR :=) \
59 )
60endef
61
62#
Ying Wang1a031e42010-05-10 16:35:39 -070063# Returns the sorted concatenation of all PRODUCT_MAKEFILES
64# variables set in all AndroidProducts.mk files.
65# $(call ) isn't necessary.
66#
67define get-all-product-makefiles
68$(call get-product-makefiles,$(_find-android-products-files))
69endef
70
71#
The Android Open Source Project88b60792009-03-03 19:28:42 -080072# Functions for including product makefiles
73#
74
75_product_var_list := \
76 PRODUCT_NAME \
77 PRODUCT_MODEL \
78 PRODUCT_LOCALES \
Ying Wang4f1ab922011-03-15 13:19:30 -070079 PRODUCT_AAPT_CONFIG \
Dianne Hackborna0f464a2011-10-14 19:37:57 -070080 PRODUCT_AAPT_PREF_CONFIG \
Ying Wang60686582014-12-10 12:40:09 -080081 PRODUCT_AAPT_PREBUILT_DPI \
The Android Open Source Project88b60792009-03-03 19:28:42 -080082 PRODUCT_PACKAGES \
Joe Onoratod7d0afc2012-06-05 15:54:09 -070083 PRODUCT_PACKAGES_DEBUG \
84 PRODUCT_PACKAGES_ENG \
85 PRODUCT_PACKAGES_TESTS \
The Android Open Source Project88b60792009-03-03 19:28:42 -080086 PRODUCT_DEVICE \
87 PRODUCT_MANUFACTURER \
88 PRODUCT_BRAND \
89 PRODUCT_PROPERTY_OVERRIDES \
Mike Lockwood0d23fec2011-06-09 14:54:40 -070090 PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
Joe Onorato700b88e2010-10-05 17:33:58 -040091 PRODUCT_CHARACTERISTICS \
The Android Open Source Project88b60792009-03-03 19:28:42 -080092 PRODUCT_COPY_FILES \
93 PRODUCT_OTA_PUBLIC_KEYS \
Doug Zongker5d4808d2011-03-16 07:49:13 -070094 PRODUCT_EXTRA_RECOVERY_KEYS \
The Android Open Source Project88b60792009-03-03 19:28:42 -080095 PRODUCT_PACKAGE_OVERLAYS \
96 DEVICE_PACKAGE_OVERLAYS \
Jaekyun Seokccee95e2017-09-01 17:23:25 +090097 PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS \
Jaekyun Seok1b224282017-03-30 11:25:02 +090098 PRODUCT_ENFORCE_RRO_TARGETS \
Ying Wang780128a2014-01-29 13:35:55 -080099 PRODUCT_SDK_ATREE_FILES \
Joe Onorato214a42b2009-04-09 20:36:06 -0700100 PRODUCT_SDK_ADDON_NAME \
101 PRODUCT_SDK_ADDON_COPY_FILES \
102 PRODUCT_SDK_ADDON_COPY_MODULES \
Ying Wanga032d3d2011-11-11 10:52:12 -0800103 PRODUCT_SDK_ADDON_DOC_MODULES \
Raphael Moll0d7d09a2014-08-21 15:22:08 -0700104 PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
Ying Wang3c21fe52011-10-04 10:50:08 -0700105 PRODUCT_DEFAULT_WIFI_CHANNELS \
106 PRODUCT_DEFAULT_DEV_CERTIFICATE \
Ying Wangdbb31be2011-12-09 15:11:57 -0800107 PRODUCT_RESTRICT_VENDOR_FILES \
Dima Zavinf9269902012-03-16 09:57:11 -0700108 PRODUCT_VENDOR_KERNEL_HEADERS \
Geremy Condrafd6f7512013-06-16 17:26:08 -0700109 PRODUCT_BOOT_JARS \
Sami Tolvanen8b3f08b2015-04-07 15:08:59 +0100110 PRODUCT_SUPPORTS_BOOT_SIGNER \
David Riley17be3d32015-03-03 08:54:11 -0800111 PRODUCT_SUPPORTS_VBOOT \
Geremy Condrafd6f7512013-06-16 17:26:08 -0700112 PRODUCT_SUPPORTS_VERITY \
Sami Tolvanenf99b5312015-05-20 07:30:57 +0100113 PRODUCT_SUPPORTS_VERITY_FEC \
Jeff Sharkey26d22f72014-03-18 17:20:10 -0700114 PRODUCT_OEM_PROPERTIES \
115 PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
Nicolas Geoffrayb08ada12017-03-22 12:36:05 +0000116 PRODUCT_SYSTEM_SERVER_APPS \
Narayan Kamath89ec4962014-08-05 14:51:08 +0100117 PRODUCT_SYSTEM_SERVER_JARS \
Nicolas Geoffray4a0ad4a2017-06-12 15:19:16 +0100118 PRODUCT_DEXPREOPT_SPEED_APPS \
David Riley17be3d32015-03-03 08:54:11 -0800119 PRODUCT_VBOOT_SIGNING_KEY \
Furquan Shaikhe8c21222015-08-07 11:58:05 -0700120 PRODUCT_VBOOT_SIGNING_SUBKEY \
Geremy Condra5b5f4952014-05-05 22:19:37 -0700121 PRODUCT_VERITY_SIGNING_KEY \
Daniel Rosenbergf4eabc32014-07-10 15:42:38 -0700122 PRODUCT_SYSTEM_VERITY_PARTITION \
Ying Wang87557562014-10-09 19:29:53 -0700123 PRODUCT_VENDOR_VERITY_PARTITION \
Mathieu Chartierf0db9082017-06-23 14:47:56 -0700124 PRODUCT_SYSTEM_SERVER_DEBUG_INFO \
Ying Wang20ebd2e2014-10-07 18:07:23 -0700125 PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
126 PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
127 PRODUCT_DEX_PREOPT_BOOT_FLAGS \
Mathieu Chartierfcc8d8b2017-05-05 17:22:37 -0700128 PRODUCT_DEX_PREOPT_PROFILE_DIR \
Mathieu Chartiera61acf62017-06-28 18:23:37 -0700129 PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION \
130 PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE \
Mathieu Chartier6228ec22017-06-23 10:44:45 -0700131 PRODUCT_SYSTEM_SERVER_COMPILER_FILTER \
Andreas Gampe6b30d772016-06-27 15:15:31 -0700132 PRODUCT_SANITIZER_MODULE_CONFIGS \
Mohamad Ayyash1868a602016-04-22 17:22:07 -0700133 PRODUCT_SYSTEM_BASE_FS_PATH \
134 PRODUCT_VENDOR_BASE_FS_PATH \
Gustav Sennton81ee1862016-05-27 14:07:54 +0100135 PRODUCT_SHIPPING_API_LEVEL \
Hung-ying Tyan3c054d82016-05-20 19:08:30 +0800136 VENDOR_PRODUCT_RESTRICT_VENDOR_FILES \
137 VENDOR_EXCEPTION_MODULES \
138 VENDOR_EXCEPTION_PATHS \
Andreas Gampe831fc712017-06-30 11:36:26 -0700139 PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD \
Hiroshi Yamauchi64594c42016-12-15 16:00:41 -0800140 PRODUCT_ART_USE_READ_BARRIER \
Alex Deymo8fe63c32017-03-02 22:08:41 -0800141 PRODUCT_IOT \
Julius D'souza001c6762017-05-03 13:43:27 -0700142 PRODUCT_SYSTEM_HEADROOM \
Przemyslaw Szczepaniak2e81b3c2017-06-30 14:51:12 +0100143 PRODUCT_MINIMIZE_JAVA_DEBUG_INFO \
Ivan Lozano9a82bfd2017-07-13 14:49:12 -0700144 PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS \
Hung-ying Tyan3c054d82016-05-20 19:08:30 +0800145
Mohamad Ayyash1868a602016-04-22 17:22:07 -0700146
Ying Wang20ebd2e2014-10-07 18:07:23 -0700147
The Android Open Source Project88b60792009-03-03 19:28:42 -0800148define dump-product
149$(info ==== $(1) ====)\
150$(foreach v,$(_product_var_list),\
151$(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
152$(info --------)
153endef
154
155define dump-products
156$(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
157endef
158
159#
160# $(1): product to inherit
161#
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800162# Does three things:
163# 1. Inherits all of the variables from $1.
164# 2. Records the inheritance in the .INHERITS_FROM variable
165# 3. Records that we've visited this node, in ALL_PRODUCTS
166#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800167define inherit-product
Ying Wanga1742612015-10-28 14:33:40 -0700168 $(if $(findstring ../,$(1)),\
169 $(eval np := $(call normalize-paths,$(1))),\
170 $(eval np := $(strip $(1))))\
The Android Open Source Project88b60792009-03-03 19:28:42 -0800171 $(foreach v,$(_product_var_list), \
Ying Wanga1742612015-10-28 14:33:40 -0700172 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800173 $(eval inherit_var := \
174 PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
Ying Wanga1742612015-10-28 14:33:40 -0700175 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800176 $(eval inherit_var:=) \
177 $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800178endef
179
Joe Onorato28a846d2010-02-22 10:33:05 -0800180
181#
182# Do inherit-product only if $(1) exists
183#
184define inherit-product-if-exists
185 $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
186endef
187
The Android Open Source Project88b60792009-03-03 19:28:42 -0800188#
189# $(1): product makefile list
190#
191#TODO: check to make sure that products have all the necessary vars defined
192define import-products
193$(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
194endef
195
196
197#
198# Does various consistency checks on all of the known products.
199# Takes no parameters, so $(call ) is not necessary.
200#
201define check-all-products
202$(if ,, \
203 $(eval _cap_names :=) \
204 $(foreach p,$(PRODUCTS), \
205 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
206 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
207 $(if $(filter $(pn),$(_cap_names)), \
208 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
209 $(foreach \
210 pp,$(PRODUCTS),
211 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
212 $(pp) \
213 ))) \
214 ) \
215 ) \
216 $(eval _cap_names += $(pn)) \
217 $(if $(call is-c-identifier,$(pn)),, \
218 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
219 ) \
220 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
221 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
222 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
Ying Wang4b0486b2012-09-20 16:35:36 -0700223 $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800224 $(error $(p): malformed COPY_FILE "$(cf)") \
225 ) \
226 ) \
227 ) \
228)
229endef
230
231
232#
233# Returns the product makefile path for the product with the provided name
234#
235# $(1): short product name like "generic"
236#
237define _resolve-short-product-name
238 $(eval pn := $(strip $(1)))
239 $(eval p := \
240 $(foreach p,$(PRODUCTS), \
241 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
242 $(p) \
243 )) \
244 )
245 $(eval p := $(sort $(p)))
246 $(if $(filter 1,$(words $(p))), \
247 $(p), \
248 $(if $(filter 0,$(words $(p))), \
249 $(error No matches for product "$(pn)"), \
250 $(error Product "$(pn)" ambiguous: matches $(p)) \
251 ) \
252 )
253endef
254define resolve-short-product-name
255$(strip $(call _resolve-short-product-name,$(1)))
256endef
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400257
258
Ying Wangf9953b42010-12-29 14:07:38 -0800259_product_stash_var_list := $(_product_var_list) \
Ying Wang0650d152013-07-23 17:57:38 -0700260 PRODUCT_BOOTCLASSPATH \
Narayan Kamath89ec4962014-08-05 14:51:08 +0100261 PRODUCT_SYSTEM_SERVER_CLASSPATH \
Ying Wangf9953b42010-12-29 14:07:38 -0800262 TARGET_ARCH \
263 TARGET_ARCH_VARIANT \
Ben Cheng7028f5e2013-01-15 14:36:42 -0800264 TARGET_CPU_VARIANT \
Ying Wangf9953b42010-12-29 14:07:38 -0800265 TARGET_BOARD_PLATFORM \
266 TARGET_BOARD_PLATFORM_GPU \
Dima Zavinf9269902012-03-16 09:57:11 -0700267 TARGET_BOARD_KERNEL_HEADERS \
268 TARGET_DEVICE_KERNEL_HEADERS \
269 TARGET_PRODUCT_KERNEL_HEADERS \
Ying Wangf9953b42010-12-29 14:07:38 -0800270 TARGET_BOOTLOADER_BOARD_NAME \
Ying Wangf9953b42010-12-29 14:07:38 -0800271 TARGET_NO_BOOTLOADER \
272 TARGET_NO_KERNEL \
273 TARGET_NO_RECOVERY \
274 TARGET_NO_RADIOIMAGE \
275 TARGET_HARDWARE_3D \
Ying Wangf9953b42010-12-29 14:07:38 -0800276 TARGET_CPU_ABI \
277 TARGET_CPU_ABI2 \
Ying Wangf9953b42010-12-29 14:07:38 -0800278
279
280_product_stash_var_list += \
281 BOARD_WPA_SUPPLICANT_DRIVER \
282 BOARD_WLAN_DEVICE \
283 BOARD_USES_GENERIC_AUDIO \
284 BOARD_KERNEL_CMDLINE \
285 BOARD_KERNEL_BASE \
286 BOARD_HAVE_BLUETOOTH \
Ying Wangf9953b42010-12-29 14:07:38 -0800287 BOARD_VENDOR_USE_AKMD \
288 BOARD_EGL_CFG \
289 BOARD_BOOTIMAGE_PARTITION_SIZE \
290 BOARD_RECOVERYIMAGE_PARTITION_SIZE \
291 BOARD_SYSTEMIMAGE_PARTITION_SIZE \
Mohamad Ayyash68946952015-03-03 12:30:37 -0800292 BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
JP Abgrall5bfed5a2014-06-16 14:17:40 -0700293 BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
Ying Wangf9953b42010-12-29 14:07:38 -0800294 BOARD_USERDATAIMAGE_PARTITION_SIZE \
Ying Wang9f8e8db2011-11-04 11:37:01 -0700295 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
296 BOARD_CACHEIMAGE_PARTITION_SIZE \
Ying Wangf9953b42010-12-29 14:07:38 -0800297 BOARD_FLASH_BLOCK_SIZE \
Daniel Rosenbergdde31842014-05-28 13:51:53 -0700298 BOARD_VENDORIMAGE_PARTITION_SIZE \
299 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
Ying Wangf9953b42010-12-29 14:07:38 -0800300 BOARD_INSTALLER_CMDLINE \
301
302
Ying Wang3c21fe52011-10-04 10:50:08 -0700303_product_stash_var_list += \
Ying Wang9c440212014-05-01 20:55:30 -0700304 DEFAULT_SYSTEM_DEV_CERTIFICATE \
Alex Light7326f7b2014-08-04 17:09:41 -0700305 WITH_DEXPREOPT \
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800306 WITH_DEXPREOPT_BOOT_IMG_ONLY \
307 WITH_DEXPREOPT_APP_IMAGE
Ying Wang3c21fe52011-10-04 10:50:08 -0700308
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400309#
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700310# Mark the variables in _product_stash_var_list as readonly
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400311#
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700312define readonly-product-vars
Ying Wangf9953b42010-12-29 14:07:38 -0800313$(foreach v,$(_product_stash_var_list), \
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700314 $(eval $(v) ?=) \
315 $(eval .KATI_READONLY := $(v)) \
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400316 )
317endef
318
Keun young Parkc41c5f42012-05-30 10:22:29 -0700319define add-to-product-copy-files-if-exists
320$(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
321endef
Ying Wang20ebd2e2014-10-07 18:07:23 -0700322
323# whitespace placeholder when we record module's dex-preopt config.
324_PDPMC_SP_PLACE_HOLDER := |@SP@|
325# Set up dex-preopt config for a module.
326# $(1) list of module names
327# $(2) the modules' dex-preopt config
328define add-product-dex-preopt-module-config
329$(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
330$(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
331 $(foreach m,$(1),$(m)=$(_c)))
332endef
Andreas Gampe6b30d772016-06-27 15:15:31 -0700333
334# whitespace placeholder when we record module's sanitizer config.
335_PSMC_SP_PLACE_HOLDER := |@SP@|
336# Set up sanitizer config for a module.
337# $(1) list of module names
338# $(2) the modules' sanitizer config
339define add-product-sanitizer-module-config
340$(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
341$(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
342 $(foreach m,$(1),$(m)=$(_c)))
343endef