blob: 1a566f7d7dd8fe59adaea3fa4404843c0efcf2cf [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001#
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
Ying Wang157a5e12012-09-27 13:26:25 -070019# 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.
The Android Open Source Project88b60792009-03-03 19:28:42 -080025
26#
27# Returns the list of all AndroidProducts.mk files.
28# $(call ) isn't necessary.
29#
30define _find-android-products-files
Dan Willemsenb9d63512018-05-01 22:34:03 -070031$(file <$(OUT_DIR)/.module_paths/AndroidProducts.mk.list) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080032 $(SRC_TARGET_DIR)/product/AndroidProducts.mk
33endef
34
35#
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070036# For entries returned by get-product-makefiles, decode an entry to a short
37# product name. These either may be in the form of <name>:path/to/file.mk or
38# path/to/<name>.mk
39# $(1): The entry to decode
40#
41# Returns two words:
42# <name> <file>
43#
44define _decode-product-name
45$(strip \
46 $(eval _cpm_words := $(subst :,$(space),$(1))) \
47 $(if $(word 2,$(_cpm_words)), \
48 $(wordlist 1,2,$(_cpm_words)), \
49 $(basename $(notdir $(1))) $(1)))
50endef
51
52#
53# Validates the new common lunch choices -- ensures that they're in an
54# appropriate form, and are paired with definitions of their products.
55# $(1): The new list of COMMON_LUNCH_CHOICES
56# $(2): The new list of PRODUCT_MAKEFILES
57#
58define _validate-common-lunch-choices
59$(strip $(foreach choice,$(1),\
60 $(eval _parts := $(subst -,$(space),$(choice))) \
61 $(if $(call math_lt,$(words $(_parts)),2), \
62 $(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
63 $(if $(call math_gt_or_eq,$(words $(_parts)),4), \
64 $(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
65 $(if $(filter-out eng userdebug user,$(word 2,$(_parts))), \
66 $(error $(LOCAL_DIR): $(choice): Invalid variant: $(word 2,$(_parts)))) \
67 $(if $(filter-out $(foreach p,$(2),$(call _decode-product-name,$(p))),$(word 1,$(_parts))), \
68 $(error $(LOCAL_DIR): $(word 1,$(_parts)): Product not defined in this file)) \
69 ))
70endef
71
72#
Ying Wang1a031e42010-05-10 16:35:39 -070073# Returns the sorted concatenation of PRODUCT_MAKEFILES
74# variables set in the given AndroidProducts.mk files.
75# $(1): the list of AndroidProducts.mk files.
The Android Open Source Project88b60792009-03-03 19:28:42 -080076#
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070077# As a side-effect, COMMON_LUNCH_CHOICES will be set to a
78# union of all of the COMMON_LUNCH_CHOICES definitions within
79# each AndroidProducts.mk file.
80#
Ying Wang1a031e42010-05-10 16:35:39 -070081define get-product-makefiles
The Android Open Source Project88b60792009-03-03 19:28:42 -080082$(sort \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070083 $(eval _COMMON_LUNCH_CHOICES :=) \
Ying Wang1a031e42010-05-10 16:35:39 -070084 $(foreach f,$(1), \
The Android Open Source Project88b60792009-03-03 19:28:42 -080085 $(eval PRODUCT_MAKEFILES :=) \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070086 $(eval COMMON_LUNCH_CHOICES :=) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080087 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
88 $(eval include $(f)) \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070089 $(call _validate-common-lunch-choices,$(COMMON_LUNCH_CHOICES),$(PRODUCT_MAKEFILES)) \
90 $(eval _COMMON_LUNCH_CHOICES += $(COMMON_LUNCH_CHOICES)) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080091 $(PRODUCT_MAKEFILES) \
92 ) \
93 $(eval PRODUCT_MAKEFILES :=) \
94 $(eval LOCAL_DIR :=) \
Dan Willemsen5436c7e2019-02-11 21:31:47 -080095 $(eval COMMON_LUNCH_CHOICES := $(sort $(_COMMON_LUNCH_CHOICES))) \
Dan Willemsenaf2e1f82018-04-04 15:41:41 -070096 $(eval _COMMON_LUNCH_CHOICES :=) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080097 )
98endef
99
100#
Ying Wang1a031e42010-05-10 16:35:39 -0700101# Returns the sorted concatenation of all PRODUCT_MAKEFILES
102# variables set in all AndroidProducts.mk files.
103# $(call ) isn't necessary.
104#
105define get-all-product-makefiles
106$(call get-product-makefiles,$(_find-android-products-files))
107endef
108
Anton Hanssond26c6472019-05-06 14:40:57 +0100109# Variables that are meant to hold only a single value.
110# - The value set in the current makefile takes precedence over inherited values
111# - If multiple inherited makefiles set the var, the first-inherited value wins
112_product_single_value_vars :=
113
114# Variables that are lists of values.
115_product_list_vars :=
116
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100117_product_single_value_vars += PRODUCT_NAME
118_product_single_value_vars += PRODUCT_MODEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800119
Anton Hansson13ea2a62019-03-28 14:47:25 +0000120# The resoure configuration options to use for this product.
Anton Hanssond26c6472019-05-06 14:40:57 +0100121_product_list_vars += PRODUCT_LOCALES
122_product_list_vars += PRODUCT_AAPT_CONFIG
123_product_list_vars += PRODUCT_AAPT_PREF_CONFIG
124_product_list_vars += PRODUCT_AAPT_PREBUILT_DPI
125_product_list_vars += PRODUCT_HOST_PACKAGES
126_product_list_vars += PRODUCT_PACKAGES
127_product_list_vars += PRODUCT_PACKAGES_DEBUG
128_product_list_vars += PRODUCT_PACKAGES_DEBUG_ASAN
129_product_list_vars += PRODUCT_PACKAGES_ENG
130_product_list_vars += PRODUCT_PACKAGES_TESTS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000131
132# The device that this product maps to.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100133_product_single_value_vars += PRODUCT_DEVICE
134_product_single_value_vars += PRODUCT_MANUFACTURER
135_product_single_value_vars += PRODUCT_BRAND
Anton Hansson13ea2a62019-03-28 14:47:25 +0000136
137# These PRODUCT_SYSTEM_* flags, if defined, are used in place of the
138# corresponding PRODUCT_* flags for the sysprops on /system.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100139_product_single_value_vars += \
Anton Hanssonee4c9702018-12-21 15:36:00 +0000140 PRODUCT_SYSTEM_NAME \
141 PRODUCT_SYSTEM_MODEL \
142 PRODUCT_SYSTEM_DEVICE \
143 PRODUCT_SYSTEM_BRAND \
144 PRODUCT_SYSTEM_MANUFACTURER \
Anton Hansson13ea2a62019-03-28 14:47:25 +0000145
146# A list of property assignments, like "key = value", with zero or more
147# whitespace characters on either side of the '='.
Anton Hanssond26c6472019-05-06 14:40:57 +0100148_product_list_vars += PRODUCT_PROPERTY_OVERRIDES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000149
150# A list of property assignments, like "key = value", with zero or more
151# whitespace characters on either side of the '='.
152# used for adding properties to default.prop
Anton Hanssond26c6472019-05-06 14:40:57 +0100153_product_list_vars += PRODUCT_DEFAULT_PROPERTY_OVERRIDES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000154
155# A list of property assignments, like "key = value", with zero or more
156# whitespace characters on either side of the '='.
157# used for adding properties to build.prop of product partition
Anton Hanssond26c6472019-05-06 14:40:57 +0100158_product_list_vars += PRODUCT_PRODUCT_PROPERTIES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000159
160# A list of property assignments, like "key = value", with zero or more
161# whitespace characters on either side of the '='.
162# used for adding properties to build.prop of product partition
Anton Hanssond26c6472019-05-06 14:40:57 +0100163_product_list_vars += PRODUCT_PRODUCT_SERVICES_PROPERTIES
164_product_list_vars += PRODUCT_ODM_PROPERTIES
165_product_list_vars += PRODUCT_CHARACTERISTICS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000166
167# A list of words like <source path>:<destination path>[:<owner>].
168# The file at the source path should be copied to the destination path
169# when building this product. <destination path> is relative to
170# $(PRODUCT_OUT), so it should look like, e.g., "system/etc/file.xml".
171# The rules for these copy steps are defined in build/make/core/Makefile.
172# The optional :<owner> is used to indicate the owner of a vendor file.
Anton Hanssond26c6472019-05-06 14:40:57 +0100173_product_list_vars += PRODUCT_COPY_FILES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000174
175# The OTA key(s) specified by the product config, if any. The names
176# of these keys are stored in the target-files zip so that post-build
177# signing tools can substitute them for the test key embedded by
178# default.
Anton Hanssond26c6472019-05-06 14:40:57 +0100179_product_list_vars += PRODUCT_OTA_PUBLIC_KEYS
180_product_list_vars += PRODUCT_EXTRA_RECOVERY_KEYS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000181
182# Should we use the default resources or add any product specific overlays
Anton Hanssond26c6472019-05-06 14:40:57 +0100183_product_list_vars += PRODUCT_PACKAGE_OVERLAYS
184_product_list_vars += DEVICE_PACKAGE_OVERLAYS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000185
186# Resource overlay list which must be excluded from enforcing RRO.
Anton Hanssond26c6472019-05-06 14:40:57 +0100187_product_list_vars += PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000188
189# Package list to apply enforcing RRO.
Anton Hanssond26c6472019-05-06 14:40:57 +0100190_product_list_vars += PRODUCT_ENFORCE_RRO_TARGETS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000191
Anton Hanssond26c6472019-05-06 14:40:57 +0100192_product_list_vars += PRODUCT_SDK_ATREE_FILES
193_product_list_vars += PRODUCT_SDK_ADDON_NAME
194_product_list_vars += PRODUCT_SDK_ADDON_COPY_FILES
195_product_list_vars += PRODUCT_SDK_ADDON_COPY_MODULES
196_product_list_vars += PRODUCT_SDK_ADDON_DOC_MODULES
197_product_list_vars += PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP
Anton Hansson13ea2a62019-03-28 14:47:25 +0000198
199# which Soong namespaces to export to Make
Anton Hanssond26c6472019-05-06 14:40:57 +0100200_product_list_vars += PRODUCT_SOONG_NAMESPACES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000201
Anton Hanssond26c6472019-05-06 14:40:57 +0100202_product_list_vars += PRODUCT_DEFAULT_WIFI_CHANNELS
203_product_list_vars += PRODUCT_DEFAULT_DEV_CERTIFICATE
204_product_list_vars += PRODUCT_RESTRICT_VENDOR_FILES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000205
206# The list of product-specific kernel header dirs
Anton Hanssond26c6472019-05-06 14:40:57 +0100207_product_list_vars += PRODUCT_VENDOR_KERNEL_HEADERS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000208
209# A list of module names of BOOTCLASSPATH (jar files)
Anton Hanssond26c6472019-05-06 14:40:57 +0100210_product_list_vars += PRODUCT_BOOT_JARS
211_product_list_vars += PRODUCT_SUPPORTS_BOOT_SIGNER
212_product_list_vars += PRODUCT_SUPPORTS_VBOOT
213_product_list_vars += PRODUCT_SUPPORTS_VERITY
214_product_list_vars += PRODUCT_SUPPORTS_VERITY_FEC
215_product_list_vars += PRODUCT_OEM_PROPERTIES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000216
217# A list of property assignments, like "key = value", with zero or more
218# whitespace characters on either side of the '='.
219# used for adding properties to default.prop of system partition
Anton Hanssond26c6472019-05-06 14:40:57 +0100220_product_list_vars += PRODUCT_SYSTEM_DEFAULT_PROPERTIES
Anton Hansson13ea2a62019-03-28 14:47:25 +0000221
Anton Hanssond26c6472019-05-06 14:40:57 +0100222_product_list_vars += PRODUCT_SYSTEM_PROPERTY_BLACKLIST
223_product_list_vars += PRODUCT_VENDOR_PROPERTY_BLACKLIST
224_product_list_vars += PRODUCT_SYSTEM_SERVER_APPS
225_product_list_vars += PRODUCT_SYSTEM_SERVER_JARS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000226
227# All of the apps that we force preopt, this overrides WITH_DEXPREOPT.
Anton Hanssond26c6472019-05-06 14:40:57 +0100228_product_list_vars += PRODUCT_ALWAYS_PREOPT_EXTRACTED_APK
229_product_list_vars += PRODUCT_DEXPREOPT_SPEED_APPS
230_product_list_vars += PRODUCT_LOADED_BY_PRIVILEGED_MODULES
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100231_product_single_value_vars += PRODUCT_VBOOT_SIGNING_KEY
232_product_single_value_vars += PRODUCT_VBOOT_SIGNING_SUBKEY
233_product_single_value_vars += PRODUCT_VERITY_SIGNING_KEY
234_product_single_value_vars += PRODUCT_SYSTEM_VERITY_PARTITION
235_product_single_value_vars += PRODUCT_VENDOR_VERITY_PARTITION
236_product_single_value_vars += PRODUCT_PRODUCT_VERITY_PARTITION
237_product_single_value_vars += PRODUCT_PRODUCT_SERVICES_VERITY_PARTITION
238_product_single_value_vars += PRODUCT_ODM_VERITY_PARTITION
239_product_single_value_vars += PRODUCT_SYSTEM_SERVER_DEBUG_INFO
240_product_single_value_vars += PRODUCT_OTHER_JAVA_DEBUG_INFO
Anton Hansson13ea2a62019-03-28 14:47:25 +0000241
242# Per-module dex-preopt configs.
Anton Hanssond26c6472019-05-06 14:40:57 +0100243_product_list_vars += PRODUCT_DEX_PREOPT_MODULE_CONFIGS
244_product_list_vars += PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER
245_product_list_vars += PRODUCT_DEX_PREOPT_DEFAULT_FLAGS
246_product_list_vars += PRODUCT_DEX_PREOPT_BOOT_FLAGS
247_product_list_vars += PRODUCT_DEX_PREOPT_PROFILE_DIR
248_product_list_vars += PRODUCT_DEX_PREOPT_GENERATE_DM_FILES
249_product_list_vars += PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING
250_product_list_vars += PRODUCT_DEX_PREOPT_RESOLVE_STARTUP_STRINGS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000251
252# Boot image options.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100253_product_single_value_vars += \
Mathieu Chartiera61acf62017-06-28 18:23:37 -0700254 PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE \
Anton Hansson13ea2a62019-03-28 14:47:25 +0000255 PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION \
Calin Juravlecdff6b12019-05-01 15:34:47 -0700256 PRODUCT_USES_DEFAULT_ART_CONFIG \
Anton Hansson13ea2a62019-03-28 14:47:25 +0000257
Anton Hanssond26c6472019-05-06 14:40:57 +0100258_product_list_vars += PRODUCT_SYSTEM_SERVER_COMPILER_FILTER
Anton Hansson13ea2a62019-03-28 14:47:25 +0000259# Per-module sanitizer configs
Anton Hanssond26c6472019-05-06 14:40:57 +0100260_product_list_vars += PRODUCT_SANITIZER_MODULE_CONFIGS
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100261_product_single_value_vars += PRODUCT_SYSTEM_BASE_FS_PATH
262_product_single_value_vars += PRODUCT_VENDOR_BASE_FS_PATH
263_product_single_value_vars += PRODUCT_PRODUCT_BASE_FS_PATH
264_product_single_value_vars += PRODUCT_PRODUCT_SERVICES_BASE_FS_PATH
265_product_single_value_vars += PRODUCT_ODM_BASE_FS_PATH
266
267# The first API level this product shipped with
268_product_single_value_vars += PRODUCT_SHIPPING_API_LEVEL
269
Anton Hanssond26c6472019-05-06 14:40:57 +0100270_product_list_vars += VENDOR_PRODUCT_RESTRICT_VENDOR_FILES
271_product_list_vars += VENDOR_EXCEPTION_MODULES
272_product_list_vars += VENDOR_EXCEPTION_PATHS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000273# Whether the product wants to ship libartd. For rules and meaning, see art/Android.mk.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100274_product_single_value_vars += PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD
Anton Hansson13ea2a62019-03-28 14:47:25 +0000275
276# Make this art variable visible to soong_config.mk.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100277_product_single_value_vars += PRODUCT_ART_USE_READ_BARRIER
Anton Hansson13ea2a62019-03-28 14:47:25 +0000278
279# Whether the product is an Android Things variant.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100280_product_single_value_vars += PRODUCT_IOT
Anton Hansson13ea2a62019-03-28 14:47:25 +0000281
282# Add reserved headroom to a system image.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100283_product_single_value_vars += PRODUCT_SYSTEM_HEADROOM
Anton Hansson13ea2a62019-03-28 14:47:25 +0000284
285# Whether to save disk space by minimizing java debug info
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100286_product_single_value_vars += PRODUCT_MINIMIZE_JAVA_DEBUG_INFO
Anton Hansson13ea2a62019-03-28 14:47:25 +0000287
288# Whether any paths are excluded from sanitization when SANITIZE_TARGET=integer_overflow
Anton Hanssond26c6472019-05-06 14:40:57 +0100289_product_list_vars += PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000290
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100291_product_single_value_vars += PRODUCT_ADB_KEYS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000292
293# Whether any paths should have CFI enabled for components
Anton Hanssond26c6472019-05-06 14:40:57 +0100294_product_list_vars += PRODUCT_CFI_INCLUDE_PATHS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000295
296# Whether any paths are excluded from sanitization when SANITIZE_TARGET=cfi
Anton Hanssond26c6472019-05-06 14:40:57 +0100297_product_list_vars += PRODUCT_CFI_EXCLUDE_PATHS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000298
299# Whether the Scudo hardened allocator is disabled platform-wide
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100300_product_single_value_vars += PRODUCT_DISABLE_SCUDO
Anton Hansson13ea2a62019-03-28 14:47:25 +0000301
302# A flag to override PRODUCT_COMPATIBLE_PROPERTY
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100303_product_single_value_vars += PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE
Anton Hansson13ea2a62019-03-28 14:47:25 +0000304
Isaac Chene9723502019-05-06 16:55:48 +0800305# List of extra VNDK versions to be included
306_product_list_vars += PRODUCT_EXTRA_VNDK_VERSIONS
307
Anton Hansson13ea2a62019-03-28 14:47:25 +0000308# Whether the whitelist of actionable compatible properties should be disabled or not
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100309_product_single_value_vars += PRODUCT_ACTIONABLE_COMPATIBLE_PROPERTY_DISABLE
310
311_product_single_value_vars += PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS
312_product_single_value_vars += PRODUCT_ENFORCE_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT
Anton Hanssond26c6472019-05-06 14:40:57 +0100313_product_list_vars += PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_WHITELIST
314_product_list_vars += PRODUCT_ARTIFACT_PATH_REQUIREMENT_HINT
315_product_list_vars += PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST
Anton Hansson13ea2a62019-03-28 14:47:25 +0000316
317# List of modules that should be forcefully unmarked from being LOCAL_PRODUCT_MODULE, and hence
318# installed on /system directory by default.
Anton Hanssond26c6472019-05-06 14:40:57 +0100319_product_list_vars += PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION
Anton Hansson13ea2a62019-03-28 14:47:25 +0000320
321# When this is true, dynamic partitions is retrofitted on a device that has
322# already been launched without dynamic partitions. Otherwise, the device
323# is launched with dynamic partitions.
324# This flag implies PRODUCT_USE_DYNAMIC_PARTITIONS.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100325_product_single_value_vars += PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000326
327# Other dynamic partition feature flags.PRODUCT_USE_DYNAMIC_PARTITION_SIZE and
328# PRODUCT_BUILD_SUPER_PARTITION default to the value of PRODUCT_USE_DYNAMIC_PARTITIONS.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100329_product_single_value_vars += \
Anton Hansson13ea2a62019-03-28 14:47:25 +0000330 PRODUCT_USE_DYNAMIC_PARTITIONS \
Yifan Hong2dae5722018-07-31 12:47:27 -0700331 PRODUCT_USE_DYNAMIC_PARTITION_SIZE \
332 PRODUCT_BUILD_SUPER_PARTITION \
Anton Hansson13ea2a62019-03-28 14:47:25 +0000333
334# If set, kernel configuration requirements are present in OTA package (and will be enforced
335# during OTA). Otherwise, kernel configuration requirements are enforced in VTS.
336# Devices that checks the running kernel (instead of the kernel in OTA package) should not
337# set this variable to prevent OTA failures.
Anton Hanssond26c6472019-05-06 14:40:57 +0100338_product_list_vars += PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
Anton Hansson13ea2a62019-03-28 14:47:25 +0000339
Tao Bao9be20c72019-04-08 21:11:59 -0700340# If set to true, this product builds a generic OTA package, which installs generic system images
341# onto matching devices. The product may only build a subset of system images (e.g. only
342# system.img), so devices need to install the package in a system-only OTA manner.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100343_product_single_value_vars += PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Tao Bao9be20c72019-04-08 21:11:59 -0700344
Anton Hansson13ea2a62019-03-28 14:47:25 +0000345# Whether any paths are excluded from being set XOM when ENABLE_XOM=true
Anton Hanssond26c6472019-05-06 14:40:57 +0100346_product_list_vars += PRODUCT_XOM_EXCLUDE_PATHS
347_product_list_vars += PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
348_product_list_vars += PRODUCT_PACKAGE_NAME_OVERRIDES
349_product_list_vars += PRODUCT_CERTIFICATE_OVERRIDES
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100350
351# Controls for whether different partitions are built for the current product.
352_product_single_value_vars += PRODUCT_BUILD_SYSTEM_IMAGE
353_product_single_value_vars += PRODUCT_BUILD_SYSTEM_OTHER_IMAGE
354_product_single_value_vars += PRODUCT_BUILD_VENDOR_IMAGE
355_product_single_value_vars += PRODUCT_BUILD_PRODUCT_IMAGE
356_product_single_value_vars += PRODUCT_BUILD_PRODUCT_SERVICES_IMAGE
357_product_single_value_vars += PRODUCT_BUILD_ODM_IMAGE
358_product_single_value_vars += PRODUCT_BUILD_CACHE_IMAGE
359_product_single_value_vars += PRODUCT_BUILD_RAMDISK_IMAGE
360_product_single_value_vars += PRODUCT_BUILD_USERDATA_IMAGE
Chris Grossa784ef12019-04-22 11:09:57 -0700361_product_single_value_vars += PRODUCT_BUILD_RECOVERY_IMAGE
362_product_single_value_vars += PRODUCT_BUILD_BOOT_IMAGE
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100363
Anton Hanssond26c6472019-05-06 14:40:57 +0100364_product_list_vars += PRODUCT_UPDATABLE_BOOT_MODULES
365_product_list_vars += PRODUCT_UPDATABLE_BOOT_LOCATIONS
Chris Grossa784ef12019-04-22 11:09:57 -0700366
Anton Hansson13ea2a62019-03-28 14:47:25 +0000367# Whether the product would like to check prebuilt ELF files.
Anton Hanssonc1c4c0b2019-05-06 15:09:19 +0100368_product_single_value_vars += PRODUCT_CHECK_ELF_FILES
Anton Hanssond26c6472019-05-06 14:40:57 +0100369
370.KATI_READONLY := _product_single_value_vars _product_list_vars
371_product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars)
Ying Wang20ebd2e2014-10-07 18:07:23 -0700372
The Android Open Source Project88b60792009-03-03 19:28:42 -0800373define dump-product
Anton Hanssondce3f922019-02-11 21:19:54 +0000374$(warning ==== $(1) ====)\
The Android Open Source Project88b60792009-03-03 19:28:42 -0800375$(foreach v,$(_product_var_list),\
Anton Hanssondce3f922019-02-11 21:19:54 +0000376$(warning PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
377$(warning --------)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800378endef
379
380define dump-products
381$(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
382endef
383
384#
Anton Hansson13ea2a62019-03-28 14:47:25 +0000385# Functions for including product makefiles
386#
387
388#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800389# $(1): product to inherit
390#
Anton Hansson061cbcf2018-05-30 18:24:41 +0100391# To be called from product makefiles, and is later evaluated during the import-nodes
392# call below. It does three things:
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800393# 1. Inherits all of the variables from $1.
394# 2. Records the inheritance in the .INHERITS_FROM variable
Anton Hansson061cbcf2018-05-30 18:24:41 +0100395# 3. Records the calling makefile in PARENT_PRODUCT_FILES
396#
397# (2) and (3) can be used together to reconstruct the include hierarchy
398# See e.g. product-graph.mk for an example of this.
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800399#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800400define inherit-product
Ying Wanga1742612015-10-28 14:33:40 -0700401 $(if $(findstring ../,$(1)),\
402 $(eval np := $(call normalize-paths,$(1))),\
403 $(eval np := $(strip $(1))))\
The Android Open Source Project88b60792009-03-03 19:28:42 -0800404 $(foreach v,$(_product_var_list), \
Ying Wanga1742612015-10-28 14:33:40 -0700405 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
Anton Hansson061cbcf2018-05-30 18:24:41 +0100406 $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
407 $(eval inherit_var := PRODUCTS.$(current_mk).INHERITS_FROM) \
Ying Wanga1742612015-10-28 14:33:40 -0700408 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
Anton Hansson061cbcf2018-05-30 18:24:41 +0100409 $(eval PARENT_PRODUCT_FILES := $(sort $(PARENT_PRODUCT_FILES) $(current_mk)))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800410endef
411
Anton Hansson837425b2018-06-01 14:18:14 +0100412# Specifies a number of path prefixes, relative to PRODUCT_OUT, where the
413# product makefile hierarchy rooted in the current node places its artifacts.
414# Creating artifacts outside the specified paths will cause a build-time error.
415define require-artifacts-in-path
416 $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
417 $(eval PRODUCTS.$(current_mk).ARTIFACT_PATH_REQUIREMENTS := $(strip $(1))) \
418 $(eval PRODUCTS.$(current_mk).ARTIFACT_PATH_WHITELIST := $(strip $(2))) \
419 $(eval ARTIFACT_PATH_REQUIREMENT_PRODUCTS := \
420 $(sort $(ARTIFACT_PATH_REQUIREMENT_PRODUCTS) $(current_mk)))
421endef
Joe Onorato28a846d2010-02-22 10:33:05 -0800422
Anton Hansson1ebcbd52018-07-04 17:17:23 +0100423# Makes including non-existant modules in PRODUCT_PACKAGES an error.
424# $(1): whitelist of non-existant modules to allow.
425define enforce-product-packages-exist
426 $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
427 $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST := true) \
428 $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_WHITELIST := $(1)) \
429 $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST) \
430 $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_WHITELIST)
431endef
432
Joe Onorato28a846d2010-02-22 10:33:05 -0800433#
434# Do inherit-product only if $(1) exists
435#
436define inherit-product-if-exists
437 $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
438endef
439
The Android Open Source Project88b60792009-03-03 19:28:42 -0800440#
441# $(1): product makefile list
442#
443#TODO: check to make sure that products have all the necessary vars defined
444define import-products
Anton Hanssond26c6472019-05-06 14:40:57 +0100445$(call import-nodes,PRODUCTS,$(1),$(_product_var_list),$(_product_single_value_vars))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800446endef
447
448
449#
450# Does various consistency checks on all of the known products.
451# Takes no parameters, so $(call ) is not necessary.
452#
453define check-all-products
454$(if ,, \
455 $(eval _cap_names :=) \
456 $(foreach p,$(PRODUCTS), \
457 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
458 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
459 $(if $(filter $(pn),$(_cap_names)), \
460 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
461 $(foreach \
462 pp,$(PRODUCTS),
463 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
464 $(pp) \
465 ))) \
466 ) \
467 ) \
468 $(eval _cap_names += $(pn)) \
469 $(if $(call is-c-identifier,$(pn)),, \
470 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
471 ) \
472 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
473 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
474 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
Ying Wang4b0486b2012-09-20 16:35:36 -0700475 $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800476 $(error $(p): malformed COPY_FILE "$(cf)") \
477 ) \
478 ) \
479 ) \
480)
481endef
482
483
484#
485# Returns the product makefile path for the product with the provided name
486#
487# $(1): short product name like "generic"
488#
489define _resolve-short-product-name
490 $(eval pn := $(strip $(1)))
491 $(eval p := \
492 $(foreach p,$(PRODUCTS), \
493 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
494 $(p) \
495 )) \
496 )
497 $(eval p := $(sort $(p)))
498 $(if $(filter 1,$(words $(p))), \
499 $(p), \
500 $(if $(filter 0,$(words $(p))), \
501 $(error No matches for product "$(pn)"), \
502 $(error Product "$(pn)" ambiguous: matches $(p)) \
503 ) \
504 )
505endef
506define resolve-short-product-name
507$(strip $(call _resolve-short-product-name,$(1)))
508endef
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400509
Anton Hansson13ea2a62019-03-28 14:47:25 +0000510# BoardConfig variables that are also inherited in product mks. Should ideally
511# be cleaned up to not be product variables.
512_readonly_late_variables := \
513 DEVICE_PACKAGE_OVERLAYS \
514 WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY \
515
516# Modified internally in the build system
517_readonly_late_variables += \
518 PRODUCT_COPY_FILES \
519 PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING \
520 PRODUCT_DEX_PREOPT_BOOT_FLAGS \
521
522_readonly_early_variables := $(filter-out $(_readonly_late_variables),$(_product_var_list))
Yifan Honge5d879a2018-11-27 11:37:38 -0800523
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400524#
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700525# Mark the variables in _product_stash_var_list as readonly
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400526#
Anton Hansson13ea2a62019-03-28 14:47:25 +0000527define readonly-variables
528$(foreach v,$(1), \
Anton Hansson70222b22019-02-21 10:41:03 +0000529 $(eval $(v) ?=) \
530 $(eval .KATI_READONLY := $(v)) \
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400531 )
532endef
Anton Hansson13ea2a62019-03-28 14:47:25 +0000533define readonly-product-vars
534$(call readonly-variables,$(_readonly_early_variables))
535endef
536
537define readonly-final-product-vars
538$(call readonly-variables,$(_readonly_late_variables))
539endef
Joe Onorato8dc8faa2010-09-14 13:09:48 -0400540
Yifan Honge5d879a2018-11-27 11:37:38 -0800541#
542# Strip the variables in _product_strip_var_list
543#
544define strip-product-vars
Anton Hansson13ea2a62019-03-28 14:47:25 +0000545$(foreach v,$(_product_var_list), \
546 $(eval $(v) := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).$(v)))) \
547)
Yifan Honge5d879a2018-11-27 11:37:38 -0800548endef
549
Keun young Parkc41c5f42012-05-30 10:22:29 -0700550define add-to-product-copy-files-if-exists
551$(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
552endef
Ying Wang20ebd2e2014-10-07 18:07:23 -0700553
554# whitespace placeholder when we record module's dex-preopt config.
555_PDPMC_SP_PLACE_HOLDER := |@SP@|
556# Set up dex-preopt config for a module.
557# $(1) list of module names
558# $(2) the modules' dex-preopt config
559define add-product-dex-preopt-module-config
560$(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
561$(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
562 $(foreach m,$(1),$(m)=$(_c)))
563endef
Andreas Gampe6b30d772016-06-27 15:15:31 -0700564
565# whitespace placeholder when we record module's sanitizer config.
566_PSMC_SP_PLACE_HOLDER := |@SP@|
567# Set up sanitizer config for a module.
568# $(1) list of module names
569# $(2) the modules' sanitizer config
570define add-product-sanitizer-module-config
571$(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
572$(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
573 $(foreach m,$(1),$(m)=$(_c)))
574endef