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_SDK_ATREE_FILES \
98 PRODUCT_SDK_ADDON_NAME \
99 PRODUCT_SDK_ADDON_COPY_FILES \
100 PRODUCT_SDK_ADDON_COPY_MODULES \
101 PRODUCT_SDK_ADDON_DOC_MODULES \
102 PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
103 PRODUCT_DEFAULT_WIFI_CHANNELS \
104 PRODUCT_DEFAULT_DEV_CERTIFICATE \
105 PRODUCT_RESTRICT_VENDOR_FILES \
106 PRODUCT_VENDOR_KERNEL_HEADERS \
108 PRODUCT_SUPPORTS_BOOT_SIGNER \
109 PRODUCT_SUPPORTS_VBOOT \
110 PRODUCT_SUPPORTS_VERITY \
111 PRODUCT_SUPPORTS_VERITY_FEC \
112 PRODUCT_OEM_PROPERTIES \
113 PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
114 PRODUCT_SYSTEM_SERVER_JARS \
115 PRODUCT_VBOOT_SIGNING_KEY \
116 PRODUCT_VBOOT_SIGNING_SUBKEY \
117 PRODUCT_VERITY_SIGNING_KEY \
118 PRODUCT_SYSTEM_VERITY_PARTITION \
119 PRODUCT_VENDOR_VERITY_PARTITION \
120 PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
121 PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
122 PRODUCT_DEX_PREOPT_BOOT_FLAGS \
123 PRODUCT_SYSTEM_BASE_FS_PATH \
124 PRODUCT_VENDOR_BASE_FS_PATH \
125 PRODUCT_SHIPPING_API_LEVEL \
130 $(info ==== $(1) ====)\
131 $(foreach v,$(_product_var_list),\
132 $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
137 $(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
141 # $(1): product to inherit
144 # 1. Inherits all of the variables from $1.
145 # 2. Records the inheritance in the .INHERITS_FROM variable
146 # 3. Records that we've visited this node, in ALL_PRODUCTS
148 define inherit-product
149 $(if $(findstring ../,$(1)),\
150 $(eval np := $(call normalize-paths,$(1))),\
151 $(eval np := $(strip $(1))))\
152 $(foreach v,$(_product_var_list), \
153 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
154 $(eval inherit_var := \
155 PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
156 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
157 $(eval inherit_var:=) \
158 $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
163 # Do inherit-product only if $(1) exists
165 define inherit-product-if-exists
166 $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
170 # $(1): product makefile list
172 #TODO: check to make sure that products have all the necessary vars defined
173 define import-products
174 $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
179 # Does various consistency checks on all of the known products.
180 # Takes no parameters, so $(call ) is not necessary.
182 define check-all-products
184 $(eval _cap_names :=) \
185 $(foreach p,$(PRODUCTS), \
186 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
187 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
188 $(if $(filter $(pn),$(_cap_names)), \
189 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
192 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
197 $(eval _cap_names += $(pn)) \
198 $(if $(call is-c-identifier,$(pn)),, \
199 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
201 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
202 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
203 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
204 $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
205 $(error $(p): malformed COPY_FILE "$(cf)") \
214 # Returns the product makefile path for the product with the provided name
216 # $(1): short product name like "generic"
218 define _resolve-short-product-name
219 $(eval pn := $(strip $(1)))
221 $(foreach p,$(PRODUCTS), \
222 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
226 $(eval p := $(sort $(p)))
227 $(if $(filter 1,$(words $(p))), \
229 $(if $(filter 0,$(words $(p))), \
230 $(error No matches for product "$(pn)"), \
231 $(error Product "$(pn)" ambiguous: matches $(p)) \
235 define resolve-short-product-name
236 $(strip $(call _resolve-short-product-name,$(1)))
240 _product_stash_var_list := $(_product_var_list) \
241 PRODUCT_BOOTCLASSPATH \
242 PRODUCT_SYSTEM_SERVER_CLASSPATH \
244 TARGET_ARCH_VARIANT \
246 TARGET_BOARD_PLATFORM \
247 TARGET_BOARD_PLATFORM_GPU \
248 TARGET_BOARD_KERNEL_HEADERS \
249 TARGET_DEVICE_KERNEL_HEADERS \
250 TARGET_PRODUCT_KERNEL_HEADERS \
251 TARGET_BOOTLOADER_BOARD_NAME \
252 TARGET_NO_BOOTLOADER \
255 TARGET_NO_RADIOIMAGE \
261 _product_stash_var_list += \
262 BOARD_WPA_SUPPLICANT_DRIVER \
264 BOARD_USES_GENERIC_AUDIO \
265 BOARD_KERNEL_CMDLINE \
267 BOARD_HAVE_BLUETOOTH \
268 BOARD_VENDOR_USE_AKMD \
270 BOARD_BOOTIMAGE_PARTITION_SIZE \
271 BOARD_RECOVERYIMAGE_PARTITION_SIZE \
272 BOARD_SYSTEMIMAGE_PARTITION_SIZE \
273 BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
274 BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
275 BOARD_USERDATAIMAGE_PARTITION_SIZE \
276 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
277 BOARD_CACHEIMAGE_PARTITION_SIZE \
278 BOARD_FLASH_BLOCK_SIZE \
279 BOARD_VENDORIMAGE_PARTITION_SIZE \
280 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
281 BOARD_INSTALLER_CMDLINE \
284 _product_stash_var_list += \
285 DEFAULT_SYSTEM_DEV_CERTIFICATE \
287 WITH_DEXPREOPT_BOOT_IMG_ONLY
289 _product_stash_var_list += \
290 GLOBAL_CFLAGS_NO_OVERRIDE \
291 GLOBAL_CPPFLAGS_NO_OVERRIDE \
292 GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \
295 # Stash values of the variables in _product_stash_var_list.
296 # $(1): Renamed prefix
298 define stash-product-vars
299 $(foreach v,$(_product_stash_var_list), \
300 $(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \
305 # Assert that the the variable stashed by stash-product-vars remains untouched.
306 # $(1): The prefix as supplied to stash-product-vars
308 define assert-product-vars
310 $(eval changed_variables:=)
311 $(foreach v,$(_product_stash_var_list), \
312 $(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \
313 $(eval $(warning $(v) has been modified: $($(v)))) \
314 $(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \
315 $(eval changed_variables := $(changed_variables) $(v))) \
317 $(if $(changed_variables),\
318 $(eval $(error The following variables have been changed: $(changed_variables))),)
322 define add-to-product-copy-files-if-exists
323 $(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
326 # whitespace placeholder when we record module's dex-preopt config.
327 _PDPMC_SP_PLACE_HOLDER := |@SP@|
328 # Set up dex-preopt config for a module.
329 # $(1) list of module names
330 # $(2) the modules' dex-preopt config
331 define add-product-dex-preopt-module-config
332 $(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
333 $(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
334 $(foreach m,$(1),$(m)=$(_c)))