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 Cannot 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 $(OUT_DIR)/mk2rbc \ 240 --mode=write -r --outdir $(OUT_DIR)/rbc \ 241 --launcher=$(OUT_DIR)/rbc/launcher.rbc \ 242 --input_variables=$(OUT_DIR)/rbc/make_vars_pre_product_config.mk \ 243 --makefile_list=$(OUT_DIR)/.module_paths/configuration.list \ 244 $(current_product_makefile)) 245 ifneq ($(.SHELLSTATUS),0) 246 $(error product configuration converter failed: $(.SHELLSTATUS)) 247 endif 248 249 $(shell build/soong/scripts/update_out $(OUT_DIR)/rbc/rbc_product_config_results.mk \ 250 $(OUT_DIR)/rbcrun --mode=rbc $(OUT_DIR)/rbc/launcher.rbc) 251 ifneq ($(.SHELLSTATUS),0) 252 $(error product configuration runner failed: $(.SHELLSTATUS)) 253 endif 254 255 include $(OUT_DIR)/rbc/rbc_product_config_results.mk 256endif 257 258# This step was already handled in the RBC product configuration. 259ifeq ($(RBC_PRODUCT_CONFIG)$(SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK),) 260# Import all the products that have made artifact path requirements, so that we can verify 261# the artifacts they produce. They might be intermediate makefiles instead of real products. 262$(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\ 263 $(if $(filter-out $(makefile),$(PRODUCTS)),$(eval $(call import-products,$(makefile))))\ 264) 265endif 266 267INTERNAL_PRODUCT := $(current_product_makefile) 268# Strip and assign the PRODUCT_ variables. 269$(call strip-product-vars) 270 271# Quick check 272$(check-current-product) 273 274ifneq ($(ALLOW_RULES_IN_PRODUCT_CONFIG),) 275.KATI_ALLOW_RULES := $(_saved_KATI_ALLOW_RULES) 276_product_config_saved_KATI_ALLOW_RULES := 277endif 278 279############################################################################ 280 281current_product_makefile := 282 283# AOSP and Google products currently share the same `apex_contributions` in next. 284# This causes issues when building <aosp_product>-next-userdebug in main. 285# Create a temporary allowlist to ignore the google apexes listed in `contents` of apex_contributions of `next` 286# *for aosp products*. 287# TODO(b/308187268): Remove this denylist mechanism 288# Use PRODUCT_PACKAGES to determine if this is an aosp product. aosp products do not use google signed apexes. 289ignore_apex_contributions := 290ifeq (,$(findstring com.google.android.conscrypt,$(PRODUCT_PACKAGES))$(findstring com.google.android.go.conscrypt,$(PRODUCT_PACKAGES))) 291 ignore_apex_contributions := true 292endif 293ifeq (true,$(PRODUCT_MODULE_BUILD_FROM_SOURCE)) 294 ignore_apex_contributions := true 295endif 296ifneq ($(EMMA_INSTRUMENT)$(EMMA_INSTRUMENT_STATIC)$(EMMA_INSTRUMENT_FRAMEWORK)$(CLANG_COVERAGE)$(NATIVE_COVERAGE_PATHS),) 297# Coverage builds for TARGET_RELEASE=foo should always build from source, 298# even if TARGET_RELEASE=foo uses prebuilt mainline modules. 299# This is necessary because the checked-in prebuilts were generated with 300# instrumentation turned off. 301 ignore_apex_contributions := true 302endif 303 304ifeq (true, $(ignore_apex_contributions)) 305PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS := true 306endif 307 308############################################################################# 309 310# Quick check and assign default values 311 312TARGET_DEVICE := $(PRODUCT_DEVICE) 313 314# TODO: also keep track of things like "port", "land" in product files. 315 316# Figure out which resoure configuration options to use for this 317# product. 318# If CUSTOM_LOCALES contains any locales not already included 319# in PRODUCT_LOCALES, add them to PRODUCT_LOCALES. 320extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES)) 321ifneq (,$(extra_locales)) 322 ifneq ($(CALLED_FROM_SETUP),true) 323 # Don't spam stdout, because envsetup.sh may be scraping values from it. 324 $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)]) 325 endif 326 PRODUCT_LOCALES += $(extra_locales) 327 extra_locales := 328endif 329 330# Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG 331PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) $(PRODUCT_AAPT_CONFIG) 332 333# Keep a copy of the space-separated config 334PRODUCT_AAPT_CONFIG_SP := $(PRODUCT_AAPT_CONFIG) 335PRODUCT_AAPT_CONFIG := $(subst $(space),$(comma),$(PRODUCT_AAPT_CONFIG)) 336 337########################################################### 338## Add 'platform:' prefix to jars not in <apex>:<module> format. 339## 340## This makes sure that a jar corresponds to ConfigureJarList format of <apex> and <module> pairs 341## where needed. 342## 343## $(1): a list of jars either in <module> or <apex>:<module> format 344########################################################### 345 346define qualify-platform-jars 347 $(foreach jar,$(1),$(if $(findstring :,$(jar)),,platform:)$(jar)) 348endef 349 350# Extra boot jars must be appended at the end after common boot jars. 351PRODUCT_BOOT_JARS += $(PRODUCT_BOOT_JARS_EXTRA) 352 353PRODUCT_BOOT_JARS := $(call qualify-platform-jars,$(PRODUCT_BOOT_JARS)) 354 355# b/191127295: force core-icu4j onto boot image. It comes from a non-updatable APEX jar, but has 356# historically been part of the boot image; even though APEX jars are not meant to be part of the 357# boot image. 358# TODO(b/191686720): remove PRODUCT_APEX_BOOT_JARS to avoid a special handling of core-icu4j 359# in make rules. 360PRODUCT_APEX_BOOT_JARS := $(filter-out com.android.i18n:core-icu4j,$(PRODUCT_APEX_BOOT_JARS)) 361# All APEX jars come after /system and /system_ext jars, so adding core-icu4j at the end of the list 362PRODUCT_BOOT_JARS += com.android.i18n:core-icu4j 363 364# The extra system server jars must be appended at the end after common system server jars. 365PRODUCT_SYSTEM_SERVER_JARS += $(PRODUCT_SYSTEM_SERVER_JARS_EXTRA) 366 367PRODUCT_SYSTEM_SERVER_JARS := $(call qualify-platform-jars,$(PRODUCT_SYSTEM_SERVER_JARS)) 368 369# Sort APEX boot and system server jars. We use deterministic alphabetical order 370# when constructing BOOTCLASSPATH and SYSTEMSERVERCLASSPATH definition on device 371# after an update. Enforce it in the build system as well to avoid recompiling 372# everything after an update due a change in the order. 373PRODUCT_APEX_BOOT_JARS := $(sort $(PRODUCT_APEX_BOOT_JARS)) 374PRODUCT_APEX_SYSTEM_SERVER_JARS := $(sort $(PRODUCT_APEX_SYSTEM_SERVER_JARS)) 375 376PRODUCT_STANDALONE_SYSTEM_SERVER_JARS := \ 377 $(call qualify-platform-jars,$(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS)) 378 379ifndef PRODUCT_SYSTEM_NAME 380 PRODUCT_SYSTEM_NAME := $(PRODUCT_NAME) 381endif 382ifndef PRODUCT_SYSTEM_DEVICE 383 PRODUCT_SYSTEM_DEVICE := $(PRODUCT_DEVICE) 384endif 385ifndef PRODUCT_SYSTEM_BRAND 386 PRODUCT_SYSTEM_BRAND := $(PRODUCT_BRAND) 387endif 388ifndef PRODUCT_MODEL 389 PRODUCT_MODEL := $(PRODUCT_NAME) 390endif 391ifndef PRODUCT_SYSTEM_MODEL 392 PRODUCT_SYSTEM_MODEL := $(PRODUCT_MODEL) 393endif 394 395ifndef PRODUCT_MANUFACTURER 396 PRODUCT_MANUFACTURER := unknown 397endif 398ifndef PRODUCT_SYSTEM_MANUFACTURER 399 PRODUCT_SYSTEM_MANUFACTURER := $(PRODUCT_MANUFACTURER) 400endif 401 402ifndef PRODUCT_CHARACTERISTICS 403 TARGET_AAPT_CHARACTERISTICS := default 404else 405 TARGET_AAPT_CHARACTERISTICS := $(PRODUCT_CHARACTERISTICS) 406endif 407 408ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE 409 ifneq (1,$(words $(PRODUCT_DEFAULT_DEV_CERTIFICATE))) 410 $(error PRODUCT_DEFAULT_DEV_CERTIFICATE='$(PRODUCT_DEFAULT_DEV_CERTIFICATE)', \ 411 only 1 certificate is allowed.) 412 endif 413endif 414 415$(foreach pair,$(PRODUCT_APEX_BOOT_JARS), \ 416 $(eval jar := $(call word-colon,2,$(pair))) \ 417 $(if $(findstring $(jar), $(PRODUCT_BOOT_JARS)), \ 418 $(error A jar in PRODUCT_APEX_BOOT_JARS must not be in PRODUCT_BOOT_JARS, but $(jar) is))) 419 420ENFORCE_SYSTEM_CERTIFICATE := $(PRODUCT_ENFORCE_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT) 421ENFORCE_SYSTEM_CERTIFICATE_ALLOW_LIST := $(PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_ALLOW_LIST) 422 423PRODUCT_OTA_PUBLIC_KEYS := $(sort $(PRODUCT_OTA_PUBLIC_KEYS)) 424PRODUCT_EXTRA_OTA_KEYS := $(sort $(PRODUCT_EXTRA_OTA_KEYS)) 425PRODUCT_EXTRA_RECOVERY_KEYS := $(sort $(PRODUCT_EXTRA_RECOVERY_KEYS)) 426 427PRODUCT_VALIDATION_CHECKS := $(sort $(PRODUCT_VALIDATION_CHECKS)) 428 429# Resolve and setup per-module dex-preopt configs. 430DEXPREOPT_DISABLED_MODULES := 431# If a module has multiple setups, the first takes precedence. 432_pdpmc_modules := 433$(foreach c,$(PRODUCT_DEX_PREOPT_MODULE_CONFIGS),\ 434 $(eval m := $(firstword $(subst =,$(space),$(c))))\ 435 $(if $(filter $(_pdpmc_modules),$(m)),,\ 436 $(eval _pdpmc_modules += $(m))\ 437 $(eval cf := $(patsubst $(m)=%,%,$(c)))\ 438 $(eval cf := $(subst $(_PDPMC_SP_PLACE_HOLDER),$(space),$(cf)))\ 439 $(if $(filter disable,$(cf)),\ 440 $(eval DEXPREOPT_DISABLED_MODULES += $(m)),\ 441 $(eval DEXPREOPT.$(TARGET_PRODUCT).$(m).CONFIG := $(cf))))) 442_pdpmc_modules := 443 444 445# Resolve and setup per-module sanitizer configs. 446# If a module has multiple setups, the first takes precedence. 447_psmc_modules := 448$(foreach c,$(PRODUCT_SANITIZER_MODULE_CONFIGS),\ 449 $(eval m := $(firstword $(subst =,$(space),$(c))))\ 450 $(if $(filter $(_psmc_modules),$(m)),,\ 451 $(eval _psmc_modules += $(m))\ 452 $(eval cf := $(patsubst $(m)=%,%,$(c)))\ 453 $(eval cf := $(subst $(_PSMC_SP_PLACE_HOLDER),$(space),$(cf)))\ 454 $(eval SANITIZER.$(TARGET_PRODUCT).$(m).CONFIG := $(cf)))) 455_psmc_modules := 456 457# Reset ADB keys for non-debuggable builds 458ifeq (,$(filter eng userdebug,$(TARGET_BUILD_VARIANT))) 459 PRODUCT_ADB_KEYS := 460endif 461ifneq ($(filter-out 0 1,$(words $(PRODUCT_ADB_KEYS))),) 462 $(error Only one file may be in PRODUCT_ADB_KEYS: $(PRODUCT_ADB_KEYS)) 463endif 464 465# Show a warning wall of text if non-compliance-GSI products set this option. 466ifdef PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT 467 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))) 468 $(warning PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT is set but \ 469 PRODUCT_NAME ($(PRODUCT_NAME)) doesn't look like a GSI for compliance \ 470 testing. This is a special configuration for compliance GSI, so do make \ 471 sure you understand the security implications before setting this \ 472 option. If you don't know what this option does, then you probably \ 473 shouldn't set this.) 474 endif 475endif 476 477ifndef PRODUCT_USE_DYNAMIC_PARTITIONS 478 PRODUCT_USE_DYNAMIC_PARTITIONS := $(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS) 479endif 480 481# All requirements of PRODUCT_USE_DYNAMIC_PARTITIONS falls back to 482# PRODUCT_USE_DYNAMIC_PARTITIONS if not defined. 483ifndef PRODUCT_USE_DYNAMIC_PARTITION_SIZE 484 PRODUCT_USE_DYNAMIC_PARTITION_SIZE := $(PRODUCT_USE_DYNAMIC_PARTITIONS) 485endif 486 487ifndef PRODUCT_BUILD_SUPER_PARTITION 488 PRODUCT_BUILD_SUPER_PARTITION := $(PRODUCT_USE_DYNAMIC_PARTITIONS) 489endif 490 491ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),) 492 ifdef PRODUCT_SHIPPING_API_LEVEL 493 ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29)) 494 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := true 495 endif 496 endif 497endif 498 499ifeq ($(PRODUCT_SET_DEBUGFS_RESTRICTIONS),) 500 ifdef PRODUCT_SHIPPING_API_LEVEL 501 ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),31)) 502 PRODUCT_SET_DEBUGFS_RESTRICTIONS := true 503 endif 504 endif 505endif 506 507# If build command defines OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS, 508# override PRODUCT_EXTRA_VNDK_VERSIONS with it. 509ifdef OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS 510 PRODUCT_EXTRA_VNDK_VERSIONS := $(OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS) 511endif 512 513########################################### 514# APEXes are by default not compressed 515# 516# APEX compression can be forcibly enabled (resp. disabled) by 517# setting OVERRIDE_PRODUCT_COMPRESSED_APEX to true (resp. false), e.g. by 518# setting the OVERRIDE_PRODUCT_COMPRESSED_APEX environment variable. 519ifdef OVERRIDE_PRODUCT_COMPRESSED_APEX 520 PRODUCT_COMPRESSED_APEX := $(OVERRIDE_PRODUCT_COMPRESSED_APEX) 521endif 522 523$(KATI_obsolete_var OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS \ 524 ,Use PRODUCT_EXTRA_VNDK_VERSIONS instead) 525 526# If build command defines OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE, 527# override PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE with it unless it is 528# defined as `false`. If the value is `false` clear 529# PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE 530# OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE can be used for 531# testing only. 532ifdef OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE 533 ifeq (false,$(OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE)) 534 PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := 535 else 536 PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := $(OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE) 537 endif 538else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),) 539 # No shipping level defined. Enforce the product interface by default. 540 PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := true 541else ifeq ($(call math_gt,$(PRODUCT_SHIPPING_API_LEVEL),29),true) 542 # Enforce product interface if PRODUCT_SHIPPING_API_LEVEL is greater than 29. 543 PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := true 544endif 545 546$(KATI_obsolete_var OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE,Use PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE instead) 547 548# From Android V, Define PRODUCT_PRODUCT_VNDK_VERSION as current by default. 549# This is required to make all devices have product variants. 550ifndef PRODUCT_PRODUCT_VNDK_VERSION 551 PRODUCT_PRODUCT_VNDK_VERSION := current 552endif 553 554ifdef PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS 555 $(error PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS is deprecated, consider using RRO for \ 556 $(PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS)) 557endif 558 559# This table maps sdk version 35 to vendor api level 202404 and assumes yearly 560# release for the same month. 561define sdk-to-vendor-api-level 562 $(if $(call math_lt_or_eq,$(1),34),$(1),20$(call int_subtract,$(1),11)04) 563endef 564 565ifdef PRODUCT_SHIPPING_VENDOR_API_LEVEL 566# Follow the version that is set manually. 567 VSR_VENDOR_API_LEVEL := $(PRODUCT_SHIPPING_VENDOR_API_LEVEL) 568else 569 # VSR API level is the vendor api level of the product shipping API level. 570 VSR_VENDOR_API_LEVEL := $(call sdk-to-vendor-api-level,$(PLATFORM_SDK_VERSION)) 571 ifdef PRODUCT_SHIPPING_API_LEVEL 572 VSR_VENDOR_API_LEVEL := $(call sdk-to-vendor-api-level,$(PRODUCT_SHIPPING_API_LEVEL)) 573 endif 574 ifdef BOARD_SHIPPING_API_LEVEL 575 # Vendors with GRF must define BOARD_SHIPPING_API_LEVEL for the vendor API level. 576 # In this case, the VSR API level is the minimum of the PRODUCT_SHIPPING_API_LEVEL 577 # and RELEASE_BOARD_API_LEVEL 578 VSR_VENDOR_API_LEVEL := $(call math_min,$(VSR_VENDOR_API_LEVEL),$(RELEASE_BOARD_API_LEVEL)) 579 endif 580endif 581.KATI_READONLY := VSR_VENDOR_API_LEVEL 582 583# Boolean variable determining if vendor seapp contexts is enforced 584CHECK_VENDOR_SEAPP_VIOLATIONS := false 585ifneq ($(call math_gt,$(VSR_VENDOR_API_LEVEL),34),) 586 CHECK_VENDOR_SEAPP_VIOLATIONS := true 587else ifneq ($(PRODUCT_CHECK_VENDOR_SEAPP_VIOLATIONS),) 588 CHECK_VENDOR_SEAPP_VIOLATIONS := $(PRODUCT_CHECK_VENDOR_SEAPP_VIOLATIONS) 589endif 590.KATI_READONLY := CHECK_VENDOR_SEAPP_VIOLATIONS 591 592# Boolean variable determining if selinux labels of /dev are enforced 593CHECK_DEV_TYPE_VIOLATIONS := false 594ifneq ($(call math_gt,$(VSR_VENDOR_API_LEVEL),202404),) 595 CHECK_DEV_TYPE_VIOLATIONS := true 596else ifneq ($(PRODUCT_CHECK_DEV_TYPE_VIOLATIONS),) 597 CHECK_DEV_TYPE_VIOLATIONS := $(PRODUCT_CHECK_DEV_TYPE_VIOLATIONS) 598endif 599.KATI_READONLY := CHECK_DEV_TYPE_VIOLATIONS 600 601define product-overrides-config 602$$(foreach rule,$$(PRODUCT_$(1)_OVERRIDES),\ 603 $$(if $$(filter 2,$$(words $$(subst :,$$(space),$$(rule)))),,\ 604 $$(error Rule "$$(rule)" in PRODUCT_$(1)_OVERRIDE is not <module_name>:<new_value>))) 605endef 606 607$(foreach var, \ 608 MANIFEST_PACKAGE_NAME \ 609 PACKAGE_NAME \ 610 CERTIFICATE, \ 611 $(eval $(call product-overrides-config,$(var)))) 612 613# Macro to use below. $(1) is the name of the partition 614define product-build-image-config 615ifneq ($$(filter-out true false,$$(PRODUCT_BUILD_$(1)_IMAGE)),) 616 $$(error Invalid PRODUCT_BUILD_$(1)_IMAGE: $$(PRODUCT_BUILD_$(1)_IMAGE) -- true false and empty are supported) 617endif 618endef 619 620ifndef PRODUCT_VIRTUAL_AB_COW_VERSION 621 PRODUCT_VIRTUAL_AB_COW_VERSION := 2 622 ifdef PRODUCT_SHIPPING_API_LEVEL 623 ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),34)) 624 PRODUCT_VIRTUAL_AB_COW_VERSION := 3 625 endif 626 endif 627endif 628 629# Copy and check the value of each PRODUCT_BUILD_*_IMAGE variable 630$(foreach image, \ 631 PVMFW \ 632 SYSTEM \ 633 SYSTEM_OTHER \ 634 VENDOR \ 635 PRODUCT \ 636 SYSTEM_EXT \ 637 ODM \ 638 VENDOR_DLKM \ 639 ODM_DLKM \ 640 SYSTEM_DLKM \ 641 CACHE \ 642 RAMDISK \ 643 USERDATA \ 644 BOOT \ 645 RECOVERY, \ 646 $(eval $(call product-build-image-config,$(image)))) 647 648product-build-image-config := 649 650$(call readonly-product-vars) 651