product.mk revision 1868a601b766a2c6a7a35e232ab7e0d6f025744e
1# 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 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 24# omitted. 25 26# 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 35# 36# Returns the list of all AndroidProducts.mk files. 37# $(call ) isn't necessary. 38# 39define _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 42endef 43 44# 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. 48# 49define get-product-makefiles 50$(sort \ 51 $(foreach f,$(1), \ 52 $(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# 63# 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# 72# Functions for including product makefiles 73# 74 75_product_var_list := \ 76 PRODUCT_NAME \ 77 PRODUCT_MODEL \ 78 PRODUCT_LOCALES \ 79 PRODUCT_AAPT_CONFIG \ 80 PRODUCT_AAPT_PREF_CONFIG \ 81 PRODUCT_AAPT_PREBUILT_DPI \ 82 PRODUCT_PACKAGES \ 83 PRODUCT_PACKAGES_DEBUG \ 84 PRODUCT_PACKAGES_ENG \ 85 PRODUCT_PACKAGES_TESTS \ 86 PRODUCT_DEVICE \ 87 PRODUCT_MANUFACTURER \ 88 PRODUCT_BRAND \ 89 PRODUCT_PROPERTY_OVERRIDES \ 90 PRODUCT_DEFAULT_PROPERTY_OVERRIDES \ 91 PRODUCT_CHARACTERISTICS \ 92 PRODUCT_COPY_FILES \ 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 \ 107 PRODUCT_BOOT_JARS \ 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 126 127 128define dump-product 129$(info ==== $(1) ====)\ 130$(foreach v,$(_product_var_list),\ 131$(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\ 132$(info --------) 133endef 134 135define dump-products 136$(foreach p,$(PRODUCTS),$(call dump-product,$(p))) 137endef 138 139# 140# $(1): product to inherit 141# 142# Does three things: 143# 1. Inherits all of the variables from $1. 144# 2. Records the inheritance in the .INHERITS_FROM variable 145# 3. Records that we've visited this node, in ALL_PRODUCTS 146# 147define inherit-product 148 $(if $(findstring ../,$(1)),\ 149 $(eval np := $(call normalize-paths,$(1))),\ 150 $(eval np := $(strip $(1))))\ 151 $(foreach v,$(_product_var_list), \ 152 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \ 153 $(eval inherit_var := \ 154 PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \ 155 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \ 156 $(eval inherit_var:=) \ 157 $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack)))) 158endef 159 160 161# 162# Do inherit-product only if $(1) exists 163# 164define inherit-product-if-exists 165 $(if $(wildcard $(1)),$(call inherit-product,$(1)),) 166endef 167 168# 169# $(1): product makefile list 170# 171#TODO: check to make sure that products have all the necessary vars defined 172define import-products 173$(call import-nodes,PRODUCTS,$(1),$(_product_var_list)) 174endef 175 176 177# 178# Does various consistency checks on all of the known products. 179# Takes no parameters, so $(call ) is not necessary. 180# 181define check-all-products 182$(if ,, \ 183 $(eval _cap_names :=) \ 184 $(foreach p,$(PRODUCTS), \ 185 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \ 186 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \ 187 $(if $(filter $(pn),$(_cap_names)), \ 188 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \ 189 $(foreach \ 190 pp,$(PRODUCTS), 191 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \ 192 $(pp) \ 193 ))) \ 194 ) \ 195 ) \ 196 $(eval _cap_names += $(pn)) \ 197 $(if $(call is-c-identifier,$(pn)),, \ 198 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \ 199 ) \ 200 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \ 201 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \ 202 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \ 203 $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \ 204 $(error $(p): malformed COPY_FILE "$(cf)") \ 205 ) \ 206 ) \ 207 ) \ 208) 209endef 210 211 212# 213# Returns the product makefile path for the product with the provided name 214# 215# $(1): short product name like "generic" 216# 217define _resolve-short-product-name 218 $(eval pn := $(strip $(1))) 219 $(eval p := \ 220 $(foreach p,$(PRODUCTS), \ 221 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \ 222 $(p) \ 223 )) \ 224 ) 225 $(eval p := $(sort $(p))) 226 $(if $(filter 1,$(words $(p))), \ 227 $(p), \ 228 $(if $(filter 0,$(words $(p))), \ 229 $(error No matches for product "$(pn)"), \ 230 $(error Product "$(pn)" ambiguous: matches $(p)) \ 231 ) \ 232 ) 233endef 234define resolve-short-product-name 235$(strip $(call _resolve-short-product-name,$(1))) 236endef 237 238 239_product_stash_var_list := $(_product_var_list) \ 240 PRODUCT_BOOTCLASSPATH \ 241 PRODUCT_SYSTEM_SERVER_CLASSPATH \ 242 TARGET_ARCH \ 243 TARGET_ARCH_VARIANT \ 244 TARGET_CPU_VARIANT \ 245 TARGET_BOARD_PLATFORM \ 246 TARGET_BOARD_PLATFORM_GPU \ 247 TARGET_BOARD_KERNEL_HEADERS \ 248 TARGET_DEVICE_KERNEL_HEADERS \ 249 TARGET_PRODUCT_KERNEL_HEADERS \ 250 TARGET_BOOTLOADER_BOARD_NAME \ 251 TARGET_NO_BOOTLOADER \ 252 TARGET_NO_KERNEL \ 253 TARGET_NO_RECOVERY \ 254 TARGET_NO_RADIOIMAGE \ 255 TARGET_HARDWARE_3D \ 256 TARGET_CPU_ABI \ 257 TARGET_CPU_ABI2 \ 258 259 260_product_stash_var_list += \ 261 BOARD_WPA_SUPPLICANT_DRIVER \ 262 BOARD_WLAN_DEVICE \ 263 BOARD_USES_GENERIC_AUDIO \ 264 BOARD_KERNEL_CMDLINE \ 265 BOARD_KERNEL_BASE \ 266 BOARD_HAVE_BLUETOOTH \ 267 BOARD_VENDOR_USE_AKMD \ 268 BOARD_EGL_CFG \ 269 BOARD_BOOTIMAGE_PARTITION_SIZE \ 270 BOARD_RECOVERYIMAGE_PARTITION_SIZE \ 271 BOARD_SYSTEMIMAGE_PARTITION_SIZE \ 272 BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \ 273 BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \ 274 BOARD_USERDATAIMAGE_PARTITION_SIZE \ 275 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \ 276 BOARD_CACHEIMAGE_PARTITION_SIZE \ 277 BOARD_FLASH_BLOCK_SIZE \ 278 BOARD_VENDORIMAGE_PARTITION_SIZE \ 279 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \ 280 BOARD_INSTALLER_CMDLINE \ 281 282 283_product_stash_var_list += \ 284 DEFAULT_SYSTEM_DEV_CERTIFICATE \ 285 WITH_DEXPREOPT \ 286 WITH_DEXPREOPT_BOOT_IMG_ONLY 287 288_product_stash_var_list += \ 289 GLOBAL_CFLAGS_NO_OVERRIDE \ 290 GLOBAL_CPPFLAGS_NO_OVERRIDE \ 291 GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \ 292 293# 294# Stash values of the variables in _product_stash_var_list. 295# $(1): Renamed prefix 296# 297define stash-product-vars 298$(foreach v,$(_product_stash_var_list), \ 299 $(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \ 300 ) 301endef 302 303# 304# Assert that the the variable stashed by stash-product-vars remains untouched. 305# $(1): The prefix as supplied to stash-product-vars 306# 307define assert-product-vars 308$(strip \ 309 $(eval changed_variables:=) 310 $(foreach v,$(_product_stash_var_list), \ 311 $(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \ 312 $(eval $(warning $(v) has been modified: $($(v)))) \ 313 $(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \ 314 $(eval changed_variables := $(changed_variables) $(v))) \ 315 ) \ 316 $(if $(changed_variables),\ 317 $(eval $(error The following variables have been changed: $(changed_variables))),) 318) 319endef 320 321define add-to-product-copy-files-if-exists 322$(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1)) 323endef 324 325# whitespace placeholder when we record module's dex-preopt config. 326_PDPMC_SP_PLACE_HOLDER := |@SP@| 327# Set up dex-preopt config for a module. 328# $(1) list of module names 329# $(2) the modules' dex-preopt config 330define add-product-dex-preopt-module-config 331$(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\ 332$(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \ 333 $(foreach m,$(1),$(m)=$(_c))) 334endef 335