1# 2# Copyright (C) 2008 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# Generic functions 19# TODO: Move these to definitions.make once we're able to include 20# definitions.make before config.make. 21 22########################################################### 23## Return non-empty if $(1) is a C identifier; i.e., if it 24## matches /^[a-zA-Z_][a-zA-Z0-9_]*$/. We do this by first 25## making sure that it isn't empty and doesn't start with 26## a digit, then by removing each valid character. If the 27## final result is empty, then it was a valid C identifier. 28## 29## $(1): word to check 30########################################################### 31 32_ici_digits := 0 1 2 3 4 5 6 7 8 9 33_ici_alphaunderscore := \ 34 a b c d e f g h i j k l m n o p q r s t u v w x y z \ 35 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ 36define is-c-identifier 37$(strip \ 38 $(if $(1), \ 39 $(if $(filter $(addsuffix %,$(_ici_digits)),$(1)), \ 40 , \ 41 $(eval w := $(1)) \ 42 $(foreach c,$(_ici_digits) $(_ici_alphaunderscore), \ 43 $(eval w := $(subst $(c),,$(w))) \ 44 ) \ 45 $(if $(w),,TRUE) \ 46 $(eval w :=) \ 47 ) \ 48 ) \ 49 ) 50endef 51 52# TODO: push this into the combo files; unfortunately, we don't even 53# know HOST_OS at this point. 54trysed := $(shell echo a | sed -E -e 's/a/b/' 2>/dev/null) 55ifeq ($(trysed),b) 56 SED_EXTENDED := sed -E 57else 58 trysed := $(shell echo c | sed -r -e 's/c/d/' 2>/dev/null) 59 ifeq ($(trysed),d) 60 SED_EXTENDED := sed -r 61 else 62 $(error Unknown sed version) 63 endif 64endif 65 66########################################################### 67## List all of the files in a subdirectory in a format 68## suitable for PRODUCT_COPY_FILES and 69## PRODUCT_SDK_ADDON_COPY_FILES 70## 71## $(1): Glob to match file name 72## $(2): Source directory 73## $(3): Target base directory 74########################################################### 75 76define find-copy-subdir-files 77$(shell find $(2) -name "$(1)" -type f | $(SED_EXTENDED) "s:($(2)/?(.*)):\\1\\:$(3)/\\2:" | sed "s://:/:g" | sort) 78endef 79 80# 81# Convert file file to the PRODUCT_COPY_FILES/PRODUCT_SDK_ADDON_COPY_FILES 82# format: for each file F return $(F):$(PREFIX)/$(notdir $(F)) 83# $(1): files list 84# $(2): prefix 85 86define copy-files 87$(foreach f,$(1),$(f):$(2)/$(notdir $(f))) 88endef 89 90# 91# Convert the list of file names to the list of PRODUCT_COPY_FILES items 92# $(1): from pattern 93# $(2): to pattern 94# $(3): file names 95# E.g., calling product-copy-files-by-pattern with 96# (from/%, to/%, a b) 97# returns 98# from/a:to/a from/b:to/b 99define product-copy-files-by-pattern 100$(join $(patsubst %,$(1),$(3)),$(patsubst %,:$(2),$(3))) 101endef 102 103# Return empty unless the board matches 104define is-board-platform2 105$(filter $(1), $(TARGET_BOARD_PLATFORM)) 106endef 107 108# Return empty unless the board is in the list 109define is-board-platform-in-list2 110$(filter $(1),$(TARGET_BOARD_PLATFORM)) 111endef 112 113# Return empty unless the board is QCOM 114define is-vendor-board-qcom 115$(if $(strip $(TARGET_BOARD_PLATFORM) $(QCOM_BOARD_PLATFORMS)),$(filter $(TARGET_BOARD_PLATFORM),$(QCOM_BOARD_PLATFORMS)),\ 116 $(error both TARGET_BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM) and QCOM_BOARD_PLATFORMS=$(QCOM_BOARD_PLATFORMS))) 117endef 118 119# --------------------------------------------------------------- 120# Check for obsolete PRODUCT- and APP- goals 121ifeq ($(CALLED_FROM_SETUP),true) 122product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS))) 123ifdef product_goals 124 $(error The PRODUCT-* goal is no longer supported. Use `TARGET_PRODUCT=<product> m droid` instead) 125endif 126unbundled_goals := $(strip $(filter APP-%,$(MAKECMDGOALS))) 127ifdef unbundled_goals 128 $(error The APP-* goal is no longer supported. Use `TARGET_BUILD_APPS="<app>" m droid` instead) 129endif # unbundled_goals 130endif 131 132# Default to building dalvikvm on hosts that support it... 133ifeq ($(HOST_OS),linux) 134# ... or if the if the option is already set 135ifeq ($(WITH_HOST_DALVIK),) 136 WITH_HOST_DALVIK := true 137endif 138endif 139 140# --------------------------------------------------------------- 141# Include the product definitions. 142# We need to do this to translate TARGET_PRODUCT into its 143# underlying TARGET_DEVICE before we start defining any rules. 144# 145include $(BUILD_SYSTEM)/node_fns.mk 146include $(BUILD_SYSTEM)/product.mk 147 148# Read all product definitions. 149# 150# Products are defined in AndroidProducts.mk files: 151android_products_makefiles := $(file <$(OUT_DIR)/.module_paths/AndroidProducts.mk.list) \ 152 $(SRC_TARGET_DIR)/product/AndroidProducts.mk 153 154# An AndroidProduct.mk file sets the following variables: 155# PRODUCT_MAKEFILES specifies product makefiles. Each item in this list 156# is either a <product>:path/to/file.mk, or just path/to/<product.mk> 157# COMMON_LUNCH_CHOICES specifies <product>-<variant> values to be shown 158# in the `lunch` menu 159# STARLARK_OPT_IN_PRODUCTS specifies products to use Starlark-based 160# product configuration by default 161 162# Builds a list of first/second elements of each pair: 163# $(call _first,a:A b:B,:) returns 'a b' 164# $(call _second,a-A b-B,-) returns 'A B' 165_first=$(filter-out $(2)%,$(subst $(2),$(space)$(2),$(1))) 166_second=$(filter-out %$(2),$(subst $(2),$(2)$(space),$(1))) 167 168# Returns <product>:<path> pair from a PRODUCT_MAKEFILE item. 169# If an item is <product>:path/to/file.mk, return it as is, 170# otherwise assume that an item is path/to/<product>.mk and 171# return <product>:path/to/<product>.mk 172_product-spec=$(strip $(if $(findstring :,$(1)),$(1),$(basename $(notdir $(1))):$(1))) 173 174# Reads given AndroidProduct.mk file and sets the following variables: 175# ap_product_paths -- the list of <product>:<path> pairs 176# ap_common_lunch_choices -- the list of <product>-<build variant> items 177# ap_products_using_starlark_config -- the list of products using starlark config 178# In addition, validates COMMON_LUNCH_CHOICES and STARLARK_OPT_IN_PRODUCTS values 179define _read-ap-file 180 $(eval PRODUCT_MAKEFILES :=) \ 181 $(eval COMMON_LUNCH_CHOICES :=) \ 182 $(eval STARLARK_OPT_IN_PRODUCTS := ) \ 183 $(eval ap_product_paths :=) \ 184 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \ 185 $(eval include $(f)) \ 186 $(foreach p, $(PRODUCT_MAKEFILES),$(eval ap_product_paths += $(call _product-spec,$(p)))) \ 187 $(eval ap_common_lunch_choices := $(COMMON_LUNCH_CHOICES)) \ 188 $(eval ap_products_using_starlark_config := $(STARLARK_OPT_IN_PRODUCTS)) \ 189 $(eval _products := $(call _first,$(ap_product_paths),:)) \ 190 $(eval _bad := $(filter-out $(_products),$(call _first,$(ap_common_lunch_choices),-))) \ 191 $(if $(_bad),$(error COMMON_LUNCH_CHOICES contains products(s) not defined in this file: $(_bad))) \ 192 $(eval _bad := $(filter-out %-eng %-userdebug %-user,$(ap_common_lunch_choices))) \ 193 $(if $(_bad),$(error invalid variant in COMMON_LUNCH_CHOICES: $(_bad))) 194 $(eval _bad := $(filter-out $(_products),$(ap_products_using_starlark_config))) \ 195 $(if $(_bad),$(error STARLARK_OPT_IN_PRODUCTS contains product(s) not defined in this file: $(_bad))) 196endef 197 198# Build cumulative lists of all product specs/lunch choices/Starlark-based products. 199product_paths := 200common_lunch_choices := 201products_using_starlark_config := 202$(foreach f,$(android_products_makefiles), \ 203 $(call _read-ap-file,$(f)) \ 204 $(eval product_paths += $(ap_product_paths)) \ 205 $(eval common_lunch_choices += $(ap_common_lunch_choices)) \ 206 $(eval products_using_starlark_config += $(ap_products_using_starlark_config)) \ 207) 208 209# Dedup, extract product names, etc. 210product_paths := $(sort $(product_paths)) 211all_named_products := $(sort $(call _first,$(product_paths),:)) 212current_product_makefile := $(call _second,$(filter $(TARGET_PRODUCT):%,$(product_paths)),:) 213COMMON_LUNCH_CHOICES := $(sort $(common_lunch_choices)) 214 215# Check that there are no duplicate product names 216$(foreach p,$(all_named_products), \ 217 $(if $(filter 1,$(words $(filter $(p):%,$(product_paths)))),, \ 218 $(error Product name must be unique, "$(p)" used by $(call _second,$(filter $(p):%,$(product_paths)),:)))) 219 220ifneq ($(ALLOW_RULES_IN_PRODUCT_CONFIG),) 221_product_config_saved_KATI_ALLOW_RULES := $(.KATI_ALLOW_RULES) 222.KATI_ALLOW_RULES := $(ALLOW_RULES_IN_PRODUCT_CONFIG) 223endif 224 225ifeq (,$(current_product_makefile)) 226 $(error Can not locate config makefile for product "$(TARGET_PRODUCT)") 227endif 228 229ifneq (,$(filter $(TARGET_PRODUCT),$(products_using_starlark_config))) 230 RBC_PRODUCT_CONFIG := true 231endif 232 233ifndef RBC_PRODUCT_CONFIG 234$(call import-products, $(current_product_makefile)) 235else 236 $(shell mkdir -p $(OUT_DIR)/rbc) 237 $(call dump-variables-rbc, $(OUT_DIR)/rbc/make_vars_pre_product_config.mk) 238 239 $(shell build/soong/scripts/update_out \ 240 $(OUT_DIR)/rbc/rbc_product_config_results.mk \ 241 build/soong/scripts/rbc-run \ 242 $(current_product_makefile) \ 243 $(OUT_DIR)/rbc/make_vars_pre_product_config.mk) 244 ifneq ($(.SHELLSTATUS),0) 245 $(error product configuration converter failed: $(.SHELLSTATUS)) 246 endif 247 include $(OUT_DIR)/rbc/rbc_product_config_results.mk 248endif 249 250# This step was already handled in the RBC product configuration. 251ifeq ($(RBC_PRODUCT_CONFIG)$(SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK),) 252# Import all the products that have made artifact path requirements, so that we can verify 253# the artifacts they produce. They might be intermediate makefiles instead of real products. 254$(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\ 255 $(if $(filter-out $(makefile),$(PRODUCTS)),$(eval $(call import-products,$(makefile))))\ 256) 257endif 258 259INTERNAL_PRODUCT := $(current_product_makefile) 260# Strip and assign the PRODUCT_ variables. 261$(call strip-product-vars) 262 263# Quick check 264$(check-current-product) 265 266ifneq ($(ALLOW_RULES_IN_PRODUCT_CONFIG),) 267.KATI_ALLOW_RULES := $(_saved_KATI_ALLOW_RULES) 268_product_config_saved_KATI_ALLOW_RULES := 269endif 270 271############################################################################ 272 273current_product_makefile := 274 275############################################################################# 276# Check product include tag allowlist 277BLUEPRINT_INCLUDE_TAGS_ALLOWLIST := com.android.mainline_go com.android.mainline 278.KATI_READONLY := BLUEPRINT_INCLUDE_TAGS_ALLOWLIST 279$(foreach include_tag,$(PRODUCT_INCLUDE_TAGS), \ 280 $(if $(filter $(include_tag),$(BLUEPRINT_INCLUDE_TAGS_ALLOWLIST)),,\ 281 $(call pretty-error, $(include_tag) is not in BLUEPRINT_INCLUDE_TAGS_ALLOWLIST: $(BLUEPRINT_INCLUDE_TAGS_ALLOWLIST)))) 282# Create default PRODUCT_INCLUDE_TAGS 283ifeq (, $(PRODUCT_INCLUDE_TAGS)) 284# Soong analysis is global: even though a module might not be relevant to a specific product (e.g. build_tools for aosp_arm), 285# we still analyse it. 286# This means that in setups where we two have two prebuilts of module_sdk, we need a "default" to use in analysis 287# This should be a no-op in aosp and internal since no Android.bp file contains blueprint_package_includes 288PRODUCT_INCLUDE_TAGS += com.android.mainline # Use the big android one by default 289endif 290 291############################################################################# 292 293# Quick check and assign default values 294 295TARGET_DEVICE := $(PRODUCT_DEVICE) 296 297# TODO: also keep track of things like "port", "land" in product files. 298 299# Figure out which resoure configuration options to use for this 300# product. 301# If CUSTOM_LOCALES contains any locales not already included 302# in PRODUCT_LOCALES, add them to PRODUCT_LOCALES. 303extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES)) 304ifneq (,$(extra_locales)) 305 ifneq ($(CALLED_FROM_SETUP),true) 306 # Don't spam stdout, because envsetup.sh may be scraping values from it. 307 $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)]) 308 endif 309 PRODUCT_LOCALES += $(extra_locales) 310 extra_locales := 311endif 312 313# Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG 314PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) $(PRODUCT_AAPT_CONFIG) 315 316# Keep a copy of the space-separated config 317PRODUCT_AAPT_CONFIG_SP := $(PRODUCT_AAPT_CONFIG) 318PRODUCT_AAPT_CONFIG := $(subst $(space),$(comma),$(PRODUCT_AAPT_CONFIG)) 319 320########################################################### 321## Add 'platform:' prefix to jars not in <apex>:<module> format. 322## 323## This makes sure that a jar corresponds to ConfigureJarList format of <apex> and <module> pairs 324## where needed. 325## 326## $(1): a list of jars either in <module> or <apex>:<module> format 327########################################################### 328 329define qualify-platform-jars 330 $(foreach jar,$(1),$(if $(findstring :,$(jar)),,platform:)$(jar)) 331endef 332 333# Extra boot jars must be appended at the end after common boot jars. 334PRODUCT_BOOT_JARS += $(PRODUCT_BOOT_JARS_EXTRA) 335 336PRODUCT_BOOT_JARS := $(call qualify-platform-jars,$(PRODUCT_BOOT_JARS)) 337 338# b/191127295: force core-icu4j onto boot image. It comes from a non-updatable APEX jar, but has 339# historically been part of the boot image; even though APEX jars are not meant to be part of the 340# boot image. 341# TODO(b/191686720): remove PRODUCT_APEX_BOOT_JARS to avoid a special handling of core-icu4j 342# in make rules. 343PRODUCT_APEX_BOOT_JARS := $(filter-out com.android.i18n:core-icu4j,$(PRODUCT_APEX_BOOT_JARS)) 344# All APEX jars come after /system and /system_ext jars, so adding core-icu4j at the end of the list 345PRODUCT_BOOT_JARS += com.android.i18n:core-icu4j 346 347# The extra system server jars must be appended at the end after common system server jars. 348PRODUCT_SYSTEM_SERVER_JARS += $(PRODUCT_SYSTEM_SERVER_JARS_EXTRA) 349 350PRODUCT_SYSTEM_SERVER_JARS := $(call qualify-platform-jars,$(PRODUCT_SYSTEM_SERVER_JARS)) 351 352# Sort APEX boot and system server jars. We use deterministic alphabetical order 353# when constructing BOOTCLASSPATH and SYSTEMSERVERCLASSPATH definition on device 354# after an update. Enforce it in the build system as well to avoid recompiling 355# everything after an update due a change in the order. 356PRODUCT_APEX_BOOT_JARS := $(sort $(PRODUCT_APEX_BOOT_JARS)) 357PRODUCT_APEX_SYSTEM_SERVER_JARS := $(sort $(PRODUCT_APEX_SYSTEM_SERVER_JARS)) 358 359PRODUCT_STANDALONE_SYSTEM_SERVER_JARS := \ 360 $(call qualify-platform-jars,$(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS)) 361 362ifndef PRODUCT_SYSTEM_NAME 363 PRODUCT_SYSTEM_NAME := $(PRODUCT_NAME) 364endif 365ifndef PRODUCT_SYSTEM_DEVICE 366 PRODUCT_SYSTEM_DEVICE := $(PRODUCT_DEVICE) 367endif 368ifndef PRODUCT_SYSTEM_BRAND 369 PRODUCT_SYSTEM_BRAND := $(PRODUCT_BRAND) 370endif 371ifndef PRODUCT_MODEL 372 PRODUCT_MODEL := $(PRODUCT_NAME) 373endif 374ifndef PRODUCT_SYSTEM_MODEL 375 PRODUCT_SYSTEM_MODEL := $(PRODUCT_MODEL) 376endif 377 378ifndef PRODUCT_MANUFACTURER 379 PRODUCT_MANUFACTURER := unknown 380endif 381ifndef PRODUCT_SYSTEM_MANUFACTURER 382 PRODUCT_SYSTEM_MANUFACTURER := $(PRODUCT_MANUFACTURER) 383endif 384 385ifndef PRODUCT_CHARACTERISTICS 386 TARGET_AAPT_CHARACTERISTICS := default 387else 388 TARGET_AAPT_CHARACTERISTICS := $(PRODUCT_CHARACTERISTICS) 389endif 390 391ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE 392 ifneq (1,$(words $(PRODUCT_DEFAULT_DEV_CERTIFICATE))) 393 $(error PRODUCT_DEFAULT_DEV_CERTIFICATE='$(PRODUCT_DEFAULT_DEV_CERTIFICATE)', \ 394 only 1 certificate is allowed.) 395 endif 396endif 397 398$(foreach pair,$(PRODUCT_APEX_BOOT_JARS), \ 399 $(eval jar := $(call word-colon,2,$(pair))) \ 400 $(if $(findstring $(jar), $(PRODUCT_BOOT_JARS)), \ 401 $(error A jar in PRODUCT_APEX_BOOT_JARS must not be in PRODUCT_BOOT_JARS, but $(jar) is))) 402 403ENFORCE_SYSTEM_CERTIFICATE := $(PRODUCT_ENFORCE_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT) 404ENFORCE_SYSTEM_CERTIFICATE_ALLOW_LIST := $(PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_ALLOW_LIST) 405 406PRODUCT_OTA_PUBLIC_KEYS := $(sort $(PRODUCT_OTA_PUBLIC_KEYS)) 407PRODUCT_EXTRA_OTA_KEYS := $(sort $(PRODUCT_EXTRA_OTA_KEYS)) 408PRODUCT_EXTRA_RECOVERY_KEYS := $(sort $(PRODUCT_EXTRA_RECOVERY_KEYS)) 409 410# Resolve and setup per-module dex-preopt configs. 411DEXPREOPT_DISABLED_MODULES := 412# If a module has multiple setups, the first takes precedence. 413_pdpmc_modules := 414$(foreach c,$(PRODUCT_DEX_PREOPT_MODULE_CONFIGS),\ 415 $(eval m := $(firstword $(subst =,$(space),$(c))))\ 416 $(if $(filter $(_pdpmc_modules),$(m)),,\ 417 $(eval _pdpmc_modules += $(m))\ 418 $(eval cf := $(patsubst $(m)=%,%,$(c)))\ 419 $(eval cf := $(subst $(_PDPMC_SP_PLACE_HOLDER),$(space),$(cf)))\ 420 $(if $(filter disable,$(cf)),\ 421 $(eval DEXPREOPT_DISABLED_MODULES += $(m)),\ 422 $(eval DEXPREOPT.$(TARGET_PRODUCT).$(m).CONFIG := $(cf))))) 423_pdpmc_modules := 424 425 426# Resolve and setup per-module sanitizer configs. 427# If a module has multiple setups, the first takes precedence. 428_psmc_modules := 429$(foreach c,$(PRODUCT_SANITIZER_MODULE_CONFIGS),\ 430 $(eval m := $(firstword $(subst =,$(space),$(c))))\ 431 $(if $(filter $(_psmc_modules),$(m)),,\ 432 $(eval _psmc_modules += $(m))\ 433 $(eval cf := $(patsubst $(m)=%,%,$(c)))\ 434 $(eval cf := $(subst $(_PSMC_SP_PLACE_HOLDER),$(space),$(cf)))\ 435 $(eval SANITIZER.$(TARGET_PRODUCT).$(m).CONFIG := $(cf)))) 436_psmc_modules := 437 438# Reset ADB keys for non-debuggable builds 439ifeq (,$(filter eng userdebug,$(TARGET_BUILD_VARIANT))) 440 PRODUCT_ADB_KEYS := 441endif 442ifneq ($(filter-out 0 1,$(words $(PRODUCT_ADB_KEYS))),) 443 $(error Only one file may be in PRODUCT_ADB_KEYS: $(PRODUCT_ADB_KEYS)) 444endif 445 446# Show a warning wall of text if non-compliance-GSI products set this option. 447ifdef PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT 448 ifeq (,$(filter gsi_arm gsi_arm64 gsi_x86 gsi_x86_64 gsi_car_arm64 gsi_car_x86_64 gsi_tv_arm gsi_tv_arm64,$(PRODUCT_NAME))) 449 $(warning PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT is set but \ 450 PRODUCT_NAME ($(PRODUCT_NAME)) doesn't look like a GSI for compliance \ 451 testing. This is a special configuration for compliance GSI, so do make \ 452 sure you understand the security implications before setting this \ 453 option. If you don't know what this option does, then you probably \ 454 shouldn't set this.) 455 endif 456endif 457 458ifndef PRODUCT_USE_DYNAMIC_PARTITIONS 459 PRODUCT_USE_DYNAMIC_PARTITIONS := $(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS) 460endif 461 462# All requirements of PRODUCT_USE_DYNAMIC_PARTITIONS falls back to 463# PRODUCT_USE_DYNAMIC_PARTITIONS if not defined. 464ifndef PRODUCT_USE_DYNAMIC_PARTITION_SIZE 465 PRODUCT_USE_DYNAMIC_PARTITION_SIZE := $(PRODUCT_USE_DYNAMIC_PARTITIONS) 466endif 467 468ifndef PRODUCT_BUILD_SUPER_PARTITION 469 PRODUCT_BUILD_SUPER_PARTITION := $(PRODUCT_USE_DYNAMIC_PARTITIONS) 470endif 471 472ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),) 473 ifdef PRODUCT_SHIPPING_API_LEVEL 474 ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29)) 475 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := true 476 endif 477 endif 478endif 479 480ifeq ($(PRODUCT_SET_DEBUGFS_RESTRICTIONS),) 481 ifdef PRODUCT_SHIPPING_API_LEVEL 482 ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),31)) 483 PRODUCT_SET_DEBUGFS_RESTRICTIONS := true 484 endif 485 endif 486endif 487 488ifdef PRODUCT_SHIPPING_API_LEVEL 489 ifneq (,$(call math_gt_or_eq,29,$(PRODUCT_SHIPPING_API_LEVEL))) 490 PRODUCT_PACKAGES += $(PRODUCT_PACKAGES_SHIPPING_API_LEVEL_29) 491 endif 492 ifneq (,$(call math_gt_or_eq,33,$(PRODUCT_SHIPPING_API_LEVEL))) 493 PRODUCT_PACKAGES += $(PRODUCT_PACKAGES_SHIPPING_API_LEVEL_33) 494 endif 495endif 496 497# If build command defines OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS, 498# override PRODUCT_EXTRA_VNDK_VERSIONS with it. 499ifdef OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS 500 PRODUCT_EXTRA_VNDK_VERSIONS := $(OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS) 501endif 502 503########################################### 504# APEXes are by default not compressed 505# 506# APEX compression can be forcibly enabled (resp. disabled) by 507# setting OVERRIDE_PRODUCT_COMPRESSED_APEX to true (resp. false), e.g. by 508# setting the OVERRIDE_PRODUCT_COMPRESSED_APEX environment variable. 509ifdef OVERRIDE_PRODUCT_COMPRESSED_APEX 510 PRODUCT_COMPRESSED_APEX := $(OVERRIDE_PRODUCT_COMPRESSED_APEX) 511endif 512 513$(KATI_obsolete_var OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS \ 514 ,Use PRODUCT_EXTRA_VNDK_VERSIONS instead) 515 516# If build command defines OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE, 517# override PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE with it unless it is 518# defined as `false`. If the value is `false` clear 519# PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE 520# OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE can be used for 521# testing only. 522ifdef OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE 523 ifeq (false,$(OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE)) 524 PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := 525 else 526 PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := $(OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE) 527 endif 528else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),) 529 # No shipping level defined 530else ifeq ($(call math_gt,$(PRODUCT_SHIPPING_API_LEVEL),29),true) 531 # Enforce product interface if PRODUCT_SHIPPING_API_LEVEL is greater than 29. 532 PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := true 533endif 534 535$(KATI_obsolete_var OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE,Use PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE instead) 536 537# If build command defines PRODUCT_USE_PRODUCT_VNDK_OVERRIDE as `false`, 538# PRODUCT_PRODUCT_VNDK_VERSION will not be defined automatically. 539# PRODUCT_USE_PRODUCT_VNDK_OVERRIDE can be used for testing only. 540PRODUCT_USE_PRODUCT_VNDK := false 541ifneq ($(PRODUCT_USE_PRODUCT_VNDK_OVERRIDE),) 542 PRODUCT_USE_PRODUCT_VNDK := $(PRODUCT_USE_PRODUCT_VNDK_OVERRIDE) 543else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),) 544 # No shipping level defined 545else ifeq ($(call math_gt,$(PRODUCT_SHIPPING_API_LEVEL),29),true) 546 # Enforce product interface for VNDK if PRODUCT_SHIPPING_API_LEVEL is greater 547 # than 29. 548 PRODUCT_USE_PRODUCT_VNDK := true 549endif 550 551ifeq ($(PRODUCT_USE_PRODUCT_VNDK),true) 552 ifndef PRODUCT_PRODUCT_VNDK_VERSION 553 PRODUCT_PRODUCT_VNDK_VERSION := current 554 endif 555endif 556 557$(KATI_obsolete_var PRODUCT_USE_PRODUCT_VNDK,Use PRODUCT_PRODUCT_VNDK_VERSION instead) 558$(KATI_obsolete_var PRODUCT_USE_PRODUCT_VNDK_OVERRIDE,Use PRODUCT_PRODUCT_VNDK_VERSION instead) 559 560ifdef PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS 561 $(error PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS is deprecated, consider using RRO for \ 562 $(PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS)) 563endif 564 565define product-overrides-config 566$$(foreach rule,$$(PRODUCT_$(1)_OVERRIDES),\ 567 $$(if $$(filter 2,$$(words $$(subst :,$$(space),$$(rule)))),,\ 568 $$(error Rule "$$(rule)" in PRODUCT_$(1)_OVERRIDE is not <module_name>:<new_value>))) 569endef 570 571$(foreach var, \ 572 MANIFEST_PACKAGE_NAME \ 573 PACKAGE_NAME \ 574 CERTIFICATE, \ 575 $(eval $(call product-overrides-config,$(var)))) 576 577# Macro to use below. $(1) is the name of the partition 578define product-build-image-config 579ifneq ($$(filter-out true false,$$(PRODUCT_BUILD_$(1)_IMAGE)),) 580 $$(error Invalid PRODUCT_BUILD_$(1)_IMAGE: $$(PRODUCT_BUILD_$(1)_IMAGE) -- true false and empty are supported) 581endif 582endef 583 584# Copy and check the value of each PRODUCT_BUILD_*_IMAGE variable 585$(foreach image, \ 586 PVMFW \ 587 SYSTEM \ 588 SYSTEM_OTHER \ 589 VENDOR \ 590 PRODUCT \ 591 SYSTEM_EXT \ 592 ODM \ 593 VENDOR_DLKM \ 594 ODM_DLKM \ 595 SYSTEM_DLKM \ 596 CACHE \ 597 RAMDISK \ 598 USERDATA \ 599 BOOT \ 600 RECOVERY, \ 601 $(eval $(call product-build-image-config,$(image)))) 602 603product-build-image-config := 604 605$(call readonly-product-vars) 606