2 # Copyright (C) 2007 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # Functions for including AndroidProducts.mk files
19 # 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
26 # Search for AndroidProducts.mks in the given dir.
27 # $(1): the path to the dir
28 define _search-android-products-files-in-dir
29 $(sort $(shell test -d $(1) && find -L $(1) \
32 -o -name AndroidProducts.mk -print))
36 # Returns the list of all AndroidProducts.mk files.
37 # $(call ) isn't necessary.
39 define _find-android-products-files
40 $(foreach d, device vendor product,$(call _search-android-products-files-in-dir,$(d))) \
41 $(SRC_TARGET_DIR)/product/AndroidProducts.mk
45 # Returns the sorted concatenation of PRODUCT_MAKEFILES
46 # variables set in the given AndroidProducts.mk files.
47 # $(1): the list of AndroidProducts.mk files.
49 define get-product-makefiles
52 $(eval PRODUCT_MAKEFILES :=) \
53 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
54 $(eval include $(f)) \
55 $(PRODUCT_MAKEFILES) \
57 $(eval PRODUCT_MAKEFILES :=) \
58 $(eval LOCAL_DIR :=) \
63 # Returns the sorted concatenation of all PRODUCT_MAKEFILES
64 # variables set in all AndroidProducts.mk files.
65 # $(call ) isn't necessary.
67 define get-all-product-makefiles
68 $(call get-product-makefiles,$(_find-android-products-files))
72 # Functions for including product makefiles
75 _product_var_list := \
80 PRODUCT_AAPT_PREF_CONFIG \
81 PRODUCT_AAPT_PREBUILT_DPI \
83 PRODUCT_PACKAGES_DEBUG \
84 PRODUCT_PACKAGES_ENG \
85 PRODUCT_PACKAGES_TESTS \
87 PRODUCT_MANUFACTURER \
89 PRODUCT_PROPERTY_OVERRIDES \
90 PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
91 PRODUCT_CHARACTERISTICS \
93 PRODUCT_OTA_PUBLIC_KEYS \
94 PRODUCT_EXTRA_RECOVERY_KEYS \
95 PRODUCT_PACKAGE_OVERLAYS \
96 DEVICE_PACKAGE_OVERLAYS \
97 PRODUCT_ENFORCE_RRO_TARGETS \
98 PRODUCT_SDK_ATREE_FILES \
99 PRODUCT_SDK_ADDON_NAME \
100 PRODUCT_SDK_ADDON_COPY_FILES \
101 PRODUCT_SDK_ADDON_COPY_MODULES \
102 PRODUCT_SDK_ADDON_DOC_MODULES \
103 PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
104 PRODUCT_DEFAULT_WIFI_CHANNELS \
105 PRODUCT_DEFAULT_DEV_CERTIFICATE \
106 PRODUCT_RESTRICT_VENDOR_FILES \
107 PRODUCT_VENDOR_KERNEL_HEADERS \
109 PRODUCT_SUPPORTS_BOOT_SIGNER \
110 PRODUCT_SUPPORTS_VBOOT \
111 PRODUCT_SUPPORTS_VERITY \
112 PRODUCT_SUPPORTS_VERITY_FEC \
113 PRODUCT_OEM_PROPERTIES \
114 PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
115 PRODUCT_SYSTEM_SERVER_APPS \
116 PRODUCT_SYSTEM_SERVER_JARS \
117 PRODUCT_VBOOT_SIGNING_KEY \
118 PRODUCT_VBOOT_SIGNING_SUBKEY \
119 PRODUCT_VERITY_SIGNING_KEY \
120 PRODUCT_SYSTEM_VERITY_PARTITION \
121 PRODUCT_VENDOR_VERITY_PARTITION \
122 PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
123 PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
124 PRODUCT_DEX_PREOPT_BOOT_FLAGS \
125 PRODUCT_SANITIZER_MODULE_CONFIGS \
126 PRODUCT_SYSTEM_BASE_FS_PATH \
127 PRODUCT_VENDOR_BASE_FS_PATH \
128 PRODUCT_SHIPPING_API_LEVEL \
129 VENDOR_PRODUCT_RESTRICT_VENDOR_FILES \
130 VENDOR_EXCEPTION_MODULES \
131 VENDOR_EXCEPTION_PATHS \
132 PRODUCT_ART_USE_READ_BARRIER \
134 PRODUCT_SYSTEM_HEADROOM \
139 $(info ==== $(1) ====)\
140 $(foreach v,$(_product_var_list),\
141 $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
146 $(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
150 # $(1): product to inherit
153 # 1. Inherits all of the variables from $1.
154 # 2. Records the inheritance in the .INHERITS_FROM variable
155 # 3. Records that we've visited this node, in ALL_PRODUCTS
157 define inherit-product
158 $(if $(findstring ../,$(1)),\
159 $(eval np := $(call normalize-paths,$(1))),\
160 $(eval np := $(strip $(1))))\
161 $(foreach v,$(_product_var_list), \
162 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
163 $(eval inherit_var := \
164 PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
165 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
166 $(eval inherit_var:=) \
167 $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
172 # Do inherit-product only if $(1) exists
174 define inherit-product-if-exists
175 $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
179 # $(1): product makefile list
181 #TODO: check to make sure that products have all the necessary vars defined
182 define import-products
183 $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
188 # Does various consistency checks on all of the known products.
189 # Takes no parameters, so $(call ) is not necessary.
191 define check-all-products
193 $(eval _cap_names :=) \
194 $(foreach p,$(PRODUCTS), \
195 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
196 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
197 $(if $(filter $(pn),$(_cap_names)), \
198 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
201 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
206 $(eval _cap_names += $(pn)) \
207 $(if $(call is-c-identifier,$(pn)),, \
208 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
210 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
211 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
212 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
213 $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
214 $(error $(p): malformed COPY_FILE "$(cf)") \
223 # Returns the product makefile path for the product with the provided name
225 # $(1): short product name like "generic"
227 define _resolve-short-product-name
228 $(eval pn := $(strip $(1)))
230 $(foreach p,$(PRODUCTS), \
231 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
235 $(eval p := $(sort $(p)))
236 $(if $(filter 1,$(words $(p))), \
238 $(if $(filter 0,$(words $(p))), \
239 $(error No matches for product "$(pn)"), \
240 $(error Product "$(pn)" ambiguous: matches $(p)) \
244 define resolve-short-product-name
245 $(strip $(call _resolve-short-product-name,$(1)))
249 _product_stash_var_list := $(_product_var_list) \
250 PRODUCT_BOOTCLASSPATH \
251 PRODUCT_SYSTEM_SERVER_CLASSPATH \
253 TARGET_ARCH_VARIANT \
255 TARGET_BOARD_PLATFORM \
256 TARGET_BOARD_PLATFORM_GPU \
257 TARGET_BOARD_KERNEL_HEADERS \
258 TARGET_DEVICE_KERNEL_HEADERS \
259 TARGET_PRODUCT_KERNEL_HEADERS \
260 TARGET_BOOTLOADER_BOARD_NAME \
261 TARGET_NO_BOOTLOADER \
264 TARGET_NO_RADIOIMAGE \
270 _product_stash_var_list += \
271 BOARD_WPA_SUPPLICANT_DRIVER \
273 BOARD_USES_GENERIC_AUDIO \
274 BOARD_KERNEL_CMDLINE \
276 BOARD_HAVE_BLUETOOTH \
277 BOARD_VENDOR_USE_AKMD \
279 BOARD_BOOTIMAGE_PARTITION_SIZE \
280 BOARD_RECOVERYIMAGE_PARTITION_SIZE \
281 BOARD_SYSTEMIMAGE_PARTITION_SIZE \
282 BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
283 BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
284 BOARD_USERDATAIMAGE_PARTITION_SIZE \
285 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
286 BOARD_CACHEIMAGE_PARTITION_SIZE \
287 BOARD_FLASH_BLOCK_SIZE \
288 BOARD_VENDORIMAGE_PARTITION_SIZE \
289 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
290 BOARD_INSTALLER_CMDLINE \
293 _product_stash_var_list += \
294 DEFAULT_SYSTEM_DEV_CERTIFICATE \
296 WITH_DEXPREOPT_BOOT_IMG_ONLY \
297 WITH_DEXPREOPT_APP_IMAGE
300 # Mark the variables in _product_stash_var_list as readonly
302 define readonly-product-vars
303 $(foreach v,$(_product_stash_var_list), \
305 $(eval .KATI_READONLY := $(v)) \
309 define add-to-product-copy-files-if-exists
310 $(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
313 # whitespace placeholder when we record module's dex-preopt config.
314 _PDPMC_SP_PLACE_HOLDER := |@SP@|
315 # Set up dex-preopt config for a module.
316 # $(1) list of module names
317 # $(2) the modules' dex-preopt config
318 define add-product-dex-preopt-module-config
319 $(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
320 $(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
321 $(foreach m,$(1),$(m)=$(_c)))
324 # whitespace placeholder when we record module's sanitizer config.
325 _PSMC_SP_PLACE_HOLDER := |@SP@|
326 # Set up sanitizer config for a module.
327 # $(1) list of module names
328 # $(2) the modules' sanitizer config
329 define add-product-sanitizer-module-config
330 $(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
331 $(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
332 $(foreach m,$(1),$(m)=$(_c)))