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
27 # Returns the list of all AndroidProducts.mk files.
28 # $(call ) isn't necessary.
30 define _find-android-products-files
31 $(shell test -d device && find device -maxdepth 6 -name AndroidProducts.mk) \
32 $(shell test -d vendor && find vendor -maxdepth 6 -name AndroidProducts.mk) \
33 $(SRC_TARGET_DIR)/product/AndroidProducts.mk
37 # Returns the sorted concatenation of PRODUCT_MAKEFILES
38 # variables set in the given AndroidProducts.mk files.
39 # $(1): the list of AndroidProducts.mk files.
41 define get-product-makefiles
44 $(eval PRODUCT_MAKEFILES :=) \
45 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
46 $(eval include $(f)) \
47 $(PRODUCT_MAKEFILES) \
49 $(eval PRODUCT_MAKEFILES :=) \
50 $(eval LOCAL_DIR :=) \
55 # Returns the sorted concatenation of all PRODUCT_MAKEFILES
56 # variables set in all AndroidProducts.mk files.
57 # $(call ) isn't necessary.
59 define get-all-product-makefiles
60 $(call get-product-makefiles,$(_find-android-products-files))
64 # Functions for including product makefiles
67 _product_var_list := \
72 PRODUCT_AAPT_PREF_CONFIG \
75 PRODUCT_MANUFACTURER \
77 PRODUCT_PROPERTY_OVERRIDES \
78 PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
79 PRODUCT_CHARACTERISTICS \
81 PRODUCT_OTA_PUBLIC_KEYS \
82 PRODUCT_EXTRA_RECOVERY_KEYS \
83 PRODUCT_PACKAGE_OVERLAYS \
84 DEVICE_PACKAGE_OVERLAYS \
86 PRODUCT_SDK_ADDON_NAME \
87 PRODUCT_SDK_ADDON_COPY_FILES \
88 PRODUCT_SDK_ADDON_COPY_MODULES \
89 PRODUCT_SDK_ADDON_DOC_MODULES \
90 PRODUCT_DEFAULT_WIFI_CHANNELS \
91 PRODUCT_DEFAULT_DEV_CERTIFICATE \
92 PRODUCT_RESTRICT_VENDOR_FILES \
93 PRODUCT_FACTORY_RAMDISK_MODULES \
94 PRODUCT_VENDOR_KERNEL_HEADERS \
98 $(info ==== $(1) ====)\
99 $(foreach v,$(_product_var_list),\
100 $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
105 $(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
109 # $(1): product to inherit
112 # 1. Inherits all of the variables from $1.
113 # 2. Records the inheritance in the .INHERITS_FROM variable
114 # 3. Records that we've visited this node, in ALL_PRODUCTS
116 define inherit-product
117 $(foreach v,$(_product_var_list), \
118 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \
119 $(eval inherit_var := \
120 PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
121 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \
122 $(eval inherit_var:=) \
123 $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
128 # Do inherit-product only if $(1) exists
130 define inherit-product-if-exists
131 $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
135 # $(1): product makefile list
137 #TODO: check to make sure that products have all the necessary vars defined
138 define import-products
139 $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
144 # Does various consistency checks on all of the known products.
145 # Takes no parameters, so $(call ) is not necessary.
147 define check-all-products
149 $(eval _cap_names :=) \
150 $(foreach p,$(PRODUCTS), \
151 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
152 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
153 $(if $(filter $(pn),$(_cap_names)), \
154 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
157 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
162 $(eval _cap_names += $(pn)) \
163 $(if $(call is-c-identifier,$(pn)),, \
164 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
166 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
167 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
168 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
169 $(if $(filter 2,$(words $(subst :,$(space),$(cf)))),, \
170 $(error $(p): malformed COPY_FILE "$(cf)") \
179 # Returns the product makefile path for the product with the provided name
181 # $(1): short product name like "generic"
183 define _resolve-short-product-name
184 $(eval pn := $(strip $(1)))
186 $(foreach p,$(PRODUCTS), \
187 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
191 $(eval p := $(sort $(p)))
192 $(if $(filter 1,$(words $(p))), \
194 $(if $(filter 0,$(words $(p))), \
195 $(error No matches for product "$(pn)"), \
196 $(error Product "$(pn)" ambiguous: matches $(p)) \
200 define resolve-short-product-name
201 $(strip $(call _resolve-short-product-name,$(1)))
205 _product_stash_var_list := $(_product_var_list) \
207 TARGET_ARCH_VARIANT \
208 TARGET_BOARD_PLATFORM \
209 TARGET_BOARD_PLATFORM_GPU \
210 TARGET_BOARD_KERNEL_HEADERS \
211 TARGET_DEVICE_KERNEL_HEADERS \
212 TARGET_PRODUCT_KERNEL_HEADERS \
213 TARGET_BOOTLOADER_BOARD_NAME \
214 TARGET_COMPRESS_MODULE_SYMBOLS \
215 TARGET_NO_BOOTLOADER \
218 TARGET_NO_RADIOIMAGE \
220 TARGET_PROVIDES_INIT_RC \
226 _product_stash_var_list += \
227 BOARD_WPA_SUPPLICANT_DRIVER \
229 BOARD_USES_GENERIC_AUDIO \
230 BOARD_KERNEL_CMDLINE \
232 BOARD_HAVE_BLUETOOTH \
233 BOARD_HAVE_BLUETOOTH_BCM \
234 BOARD_VENDOR_QCOM_AMSS_VERSION \
235 BOARD_VENDOR_USE_AKMD \
237 BOARD_BOOTIMAGE_PARTITION_SIZE \
238 BOARD_RECOVERYIMAGE_PARTITION_SIZE \
239 BOARD_SYSTEMIMAGE_PARTITION_SIZE \
240 BOARD_USERDATAIMAGE_PARTITION_SIZE \
241 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
242 BOARD_CACHEIMAGE_PARTITION_SIZE \
243 BOARD_FLASH_BLOCK_SIZE \
244 BOARD_SYSTEMIMAGE_PARTITION_SIZE \
245 BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE \
246 BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION \
247 BOARD_INSTALLER_CMDLINE \
250 _product_stash_var_list += \
251 DEFAULT_SYSTEM_DEV_CERTIFICATE
254 # Stash vaues of the variables in _product_stash_var_list.
255 # $(1): Renamed prefix
257 define stash-product-vars
258 $(foreach v,$(_product_stash_var_list), \
259 $(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \
264 # Assert that the the variable stashed by stash-product-vars remains untouched.
265 # $(1): The prefix as supplied to stash-product-vars
267 define assert-product-vars
269 $(eval changed_variables:=)
270 $(foreach v,$(_product_stash_var_list), \
271 $(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \
272 $(eval $(warning $(v) has been modified: $($(v)))) \
273 $(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \
274 $(eval changed_variables := $(changed_variables) $(v))) \
276 $(if $(changed_variables),\
277 $(eval $(error The following variables have been changed: $(changed_variables))),)
281 define add-to-product-copy-files-if-exists
282 $(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))