• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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# Variables that are meant to hold only a single value.
18# - The value set in the current makefile takes precedence over inherited values
19# - If multiple inherited makefiles set the var, the first-inherited value wins
20_product_single_value_vars :=
21
22# Variables that are lists of values.
23_product_list_vars :=
24
25_product_single_value_vars += PRODUCT_NAME
26_product_single_value_vars += PRODUCT_MODEL
27
28# The resoure configuration options to use for this product.
29_product_list_vars += PRODUCT_LOCALES
30_product_list_vars += PRODUCT_AAPT_CONFIG
31_product_single_value_vars += PRODUCT_AAPT_PREF_CONFIG
32_product_list_vars += PRODUCT_AAPT_PREBUILT_DPI
33_product_list_vars += PRODUCT_HOST_PACKAGES
34_product_list_vars += PRODUCT_PACKAGES
35_product_list_vars += PRODUCT_PACKAGES_DEBUG
36_product_list_vars += PRODUCT_PACKAGES_DEBUG_ASAN
37# Packages included only for eng/userdebug builds, when building with EMMA_INSTRUMENT=true
38_product_list_vars += PRODUCT_PACKAGES_DEBUG_JAVA_COVERAGE
39_product_list_vars += PRODUCT_PACKAGES_ENG
40_product_list_vars += PRODUCT_PACKAGES_TESTS
41
42# The device that this product maps to.
43_product_single_value_vars += PRODUCT_DEVICE
44_product_single_value_vars += PRODUCT_MANUFACTURER
45_product_single_value_vars += PRODUCT_BRAND
46
47# These PRODUCT_SYSTEM_* flags, if defined, are used in place of the
48# corresponding PRODUCT_* flags for the sysprops on /system.
49_product_single_value_vars += \
50    PRODUCT_SYSTEM_NAME \
51    PRODUCT_SYSTEM_MODEL \
52    PRODUCT_SYSTEM_DEVICE \
53    PRODUCT_SYSTEM_BRAND \
54    PRODUCT_SYSTEM_MANUFACTURER \
55
56# PRODUCT_<PARTITION>_PROPERTIES are lists of property assignments
57# that go to <partition>/build.prop. Each property assignment is
58# "key = value" with zero or more whitespace characters on either
59# side of the '='.
60_product_list_vars += \
61    PRODUCT_SYSTEM_PROPERTIES \
62    PRODUCT_SYSTEM_EXT_PROPERTIES \
63    PRODUCT_VENDOR_PROPERTIES \
64    PRODUCT_ODM_PROPERTIES \
65    PRODUCT_PRODUCT_PROPERTIES
66
67# TODO(b/117892318) deprecate these:
68# ... in favor or PRODUCT_SYSTEM_PROPERTIES
69_product_list_vars += PRODUCT_SYSTEM_DEFAULT_PROPERTIES
70# ... in favor of PRODUCT_VENDOR_PROPERTIES
71_product_list_vars += PRODUCT_PROPERTY_OVERRIDES
72_product_list_vars += PRODUCT_DEFAULT_PROPERTY_OVERRIDES
73
74# TODO(b/117892318) consider deprecating these too
75_product_list_vars += PRODUCT_SYSTEM_PROPERTY_BLACKLIST
76_product_list_vars += PRODUCT_VENDOR_PROPERTY_BLACKLIST
77
78# The characteristics of the product, which among other things is passed to aapt
79_product_single_value_vars += PRODUCT_CHARACTERISTICS
80
81# A list of words like <source path>:<destination path>[:<owner>].
82# The file at the source path should be copied to the destination path
83# when building  this product.  <destination path> is relative to
84# $(PRODUCT_OUT), so it should look like, e.g., "system/etc/file.xml".
85# The rules for these copy steps are defined in build/make/core/Makefile.
86# The optional :<owner> is used to indicate the owner of a vendor file.
87_product_list_vars += PRODUCT_COPY_FILES
88
89# The OTA key(s) specified by the product config, if any.  The names
90# of these keys are stored in the target-files zip so that post-build
91# signing tools can substitute them for the test key embedded by
92# default.
93_product_list_vars += PRODUCT_OTA_PUBLIC_KEYS
94_product_list_vars += PRODUCT_EXTRA_OTA_KEYS
95_product_list_vars += PRODUCT_EXTRA_RECOVERY_KEYS
96
97# Should we use the default resources or add any product specific overlays
98_product_list_vars += PRODUCT_PACKAGE_OVERLAYS
99_product_list_vars += DEVICE_PACKAGE_OVERLAYS
100
101# Resource overlay list which must be excluded from enforcing RRO.
102_product_list_vars += PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS
103
104# Package list to apply enforcing RRO.
105_product_list_vars += PRODUCT_ENFORCE_RRO_TARGETS
106
107_product_list_vars += PRODUCT_SDK_ATREE_FILES
108_product_list_vars += PRODUCT_SDK_ADDON_NAME
109_product_list_vars += PRODUCT_SDK_ADDON_COPY_FILES
110_product_list_vars += PRODUCT_SDK_ADDON_COPY_MODULES
111_product_list_vars += PRODUCT_SDK_ADDON_DOC_MODULES
112_product_list_vars += PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP
113
114# which Soong namespaces to export to Make
115_product_list_vars += PRODUCT_SOONG_NAMESPACES
116
117_product_list_vars += PRODUCT_DEFAULT_WIFI_CHANNELS
118_product_single_value_vars += PRODUCT_DEFAULT_DEV_CERTIFICATE
119_product_list_vars += PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES
120_product_list_vars += PRODUCT_RESTRICT_VENDOR_FILES
121
122# The list of product-specific kernel header dirs
123_product_list_vars += PRODUCT_VENDOR_KERNEL_HEADERS
124
125# A list of module names in BOOTCLASSPATH (jar files). Each module may be
126# prefixed with "<apex>:", which identifies the APEX that provides it. APEXes
127# are identified by their "variant" names, i.e. their `apex_name` values in
128# Soong, which default to the `name` values. The prefix can also be "platform:"
129# or "system_ext:", and defaults to "platform:" if left out. See the long
130# comment in build/soong/java/dexprepopt_bootjars.go for details.
131_product_list_vars += PRODUCT_BOOT_JARS
132
133# A list of extra BOOTCLASSPATH jars (to be appended after common jars),
134# following the same format as PRODUCT_BOOT_JARS. Products that include
135# device-specific makefiles before AOSP makefiles should use this instead of
136# PRODUCT_BOOT_JARS, so that device-specific jars go after common jars.
137_product_list_vars += PRODUCT_BOOT_JARS_EXTRA
138
139_product_single_value_vars += PRODUCT_SUPPORTS_BOOT_SIGNER
140_product_single_value_vars += PRODUCT_SUPPORTS_VBOOT
141_product_single_value_vars += PRODUCT_SUPPORTS_VERITY
142_product_single_value_vars += PRODUCT_SUPPORTS_VERITY_FEC
143_product_list_vars += PRODUCT_SYSTEM_SERVER_APPS
144# List of system_server classpath jars on the platform.
145_product_list_vars += PRODUCT_SYSTEM_SERVER_JARS
146# List of system_server classpath jars delivered via apex. Format = <apex name>:<jar name>.
147_product_list_vars += PRODUCT_APEX_SYSTEM_SERVER_JARS
148# List of jars on the platform that system_server loads dynamically using separate classloaders.
149_product_list_vars += PRODUCT_STANDALONE_SYSTEM_SERVER_JARS
150# List of jars delivered via apex that system_server loads dynamically using separate classloaders.
151# Format = <apex name>:<jar name>
152_product_list_vars += PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS
153# If true, then suboptimal order of system server jars does not cause an error.
154_product_single_value_vars += PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS
155# If true, then system server jars defined in Android.mk are supported.
156_product_single_value_vars += PRODUCT_BROKEN_DEPRECATED_MK_SYSTEM_SERVER_JARS
157
158# Additional system server jars to be appended at the end of the common list.
159# This is necessary to avoid jars reordering due to makefile inheritance order.
160_product_list_vars += PRODUCT_SYSTEM_SERVER_JARS_EXTRA
161
162# Set to true to disable <uses-library> checks for a product.
163_product_list_vars += PRODUCT_BROKEN_VERIFY_USES_LIBRARIES
164
165# All of the apps that we force preopt, this overrides WITH_DEXPREOPT.
166_product_list_vars += PRODUCT_ALWAYS_PREOPT_EXTRACTED_APK
167_product_list_vars += PRODUCT_DEXPREOPT_SPEED_APPS
168_product_list_vars += PRODUCT_LOADED_BY_PRIVILEGED_MODULES
169_product_single_value_vars += PRODUCT_VBOOT_SIGNING_KEY
170_product_single_value_vars += PRODUCT_VBOOT_SIGNING_SUBKEY
171_product_single_value_vars += PRODUCT_VERITY_SIGNING_KEY
172_product_single_value_vars += PRODUCT_SYSTEM_VERITY_PARTITION
173_product_single_value_vars += PRODUCT_VENDOR_VERITY_PARTITION
174_product_single_value_vars += PRODUCT_PRODUCT_VERITY_PARTITION
175_product_single_value_vars += PRODUCT_SYSTEM_EXT_VERITY_PARTITION
176_product_single_value_vars += PRODUCT_ODM_VERITY_PARTITION
177_product_single_value_vars += PRODUCT_VENDOR_DLKM_VERITY_PARTITION
178_product_single_value_vars += PRODUCT_ODM_DLKM_VERITY_PARTITION
179_product_single_value_vars += PRODUCT_SYSTEM_DLKM_VERITY_PARTITION
180_product_single_value_vars += PRODUCT_SYSTEM_SERVER_DEBUG_INFO
181_product_single_value_vars += PRODUCT_OTHER_JAVA_DEBUG_INFO
182
183# Per-module dex-preopt configs.
184_product_list_vars += PRODUCT_DEX_PREOPT_MODULE_CONFIGS
185_product_single_value_vars += PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER
186_product_list_vars += PRODUCT_DEX_PREOPT_DEFAULT_FLAGS
187_product_single_value_vars += PRODUCT_DEX_PREOPT_BOOT_FLAGS
188_product_single_value_vars += PRODUCT_DEX_PREOPT_PROFILE_DIR
189_product_single_value_vars += PRODUCT_DEX_PREOPT_GENERATE_DM_FILES
190_product_single_value_vars += PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING
191_product_single_value_vars += PRODUCT_DEX_PREOPT_RESOLVE_STARTUP_STRINGS
192
193# Boot image options.
194_product_list_vars += PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION
195_product_single_value_vars += \
196    PRODUCT_EXPORT_BOOT_IMAGE_TO_DIST \
197    PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE \
198    PRODUCT_USES_DEFAULT_ART_CONFIG \
199
200_product_single_value_vars += PRODUCT_SYSTEM_SERVER_COMPILER_FILTER
201# Per-module sanitizer configs
202_product_list_vars += PRODUCT_SANITIZER_MODULE_CONFIGS
203_product_single_value_vars += PRODUCT_SYSTEM_BASE_FS_PATH
204_product_single_value_vars += PRODUCT_VENDOR_BASE_FS_PATH
205_product_single_value_vars += PRODUCT_PRODUCT_BASE_FS_PATH
206_product_single_value_vars += PRODUCT_SYSTEM_EXT_BASE_FS_PATH
207_product_single_value_vars += PRODUCT_ODM_BASE_FS_PATH
208_product_single_value_vars += PRODUCT_VENDOR_DLKM_BASE_FS_PATH
209_product_single_value_vars += PRODUCT_ODM_DLKM_BASE_FS_PATH
210_product_single_value_vars += PRODUCT_SYSTEM_DLKM_BASE_FS_PATH
211
212# The first API level this product shipped with
213_product_single_value_vars += PRODUCT_SHIPPING_API_LEVEL
214
215_product_list_vars += VENDOR_PRODUCT_RESTRICT_VENDOR_FILES
216_product_list_vars += VENDOR_EXCEPTION_MODULES
217_product_list_vars += VENDOR_EXCEPTION_PATHS
218# Whether the product wants to ship libartd. For rules and meaning, see art/Android.mk.
219_product_single_value_vars += PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD
220
221# Make this art variable visible to soong_config.mk.
222_product_single_value_vars += PRODUCT_ART_USE_READ_BARRIER
223
224# Add reserved headroom to a system image.
225_product_single_value_vars += PRODUCT_SYSTEM_HEADROOM
226
227# Whether to save disk space by minimizing java debug info
228_product_single_value_vars += PRODUCT_MINIMIZE_JAVA_DEBUG_INFO
229
230# Whether any paths are excluded from sanitization when SANITIZE_TARGET=integer_overflow
231_product_list_vars += PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS
232
233_product_single_value_vars += PRODUCT_ADB_KEYS
234
235# Whether any paths should have CFI enabled for components
236_product_list_vars += PRODUCT_CFI_INCLUDE_PATHS
237
238# Whether any paths are excluded from sanitization when SANITIZE_TARGET=cfi
239_product_list_vars += PRODUCT_CFI_EXCLUDE_PATHS
240
241# Whether the Scudo hardened allocator is disabled platform-wide
242_product_single_value_vars += PRODUCT_DISABLE_SCUDO
243
244# List of extra VNDK versions to be included
245_product_list_vars += PRODUCT_EXTRA_VNDK_VERSIONS
246
247# Whether APEX should be compressed or not
248_product_single_value_vars += PRODUCT_COMPRESSED_APEX
249
250# VNDK version of product partition. It can be 'current' if the product
251# partitions uses PLATFORM_VNDK_VERSION.
252_product_single_value_vars += PRODUCT_PRODUCT_VNDK_VERSION
253
254_product_single_value_vars += PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS
255_product_single_value_vars += PRODUCT_ENFORCE_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT
256_product_list_vars += PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_ALLOW_LIST
257_product_list_vars += PRODUCT_ARTIFACT_PATH_REQUIREMENT_HINT
258_product_list_vars += PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST
259
260# List of modules that should be forcefully unmarked from being LOCAL_PRODUCT_MODULE, and hence
261# installed on /system directory by default.
262_product_list_vars += PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION
263
264# When this is true, dynamic partitions is retrofitted on a device that has
265# already been launched without dynamic partitions. Otherwise, the device
266# is launched with dynamic partitions.
267# This flag implies PRODUCT_USE_DYNAMIC_PARTITIONS.
268_product_single_value_vars += PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
269
270# List of tags that will be used to gate blueprint modules from the build graph
271_product_list_vars += PRODUCT_INCLUDE_TAGS
272
273# When this is true, various build time as well as runtime debugfs restrictions are enabled.
274_product_single_value_vars += PRODUCT_SET_DEBUGFS_RESTRICTIONS
275
276# Other dynamic partition feature flags.PRODUCT_USE_DYNAMIC_PARTITION_SIZE and
277# PRODUCT_BUILD_SUPER_PARTITION default to the value of PRODUCT_USE_DYNAMIC_PARTITIONS.
278_product_single_value_vars += \
279    PRODUCT_USE_DYNAMIC_PARTITIONS \
280    PRODUCT_USE_DYNAMIC_PARTITION_SIZE \
281    PRODUCT_BUILD_SUPER_PARTITION \
282
283# If set, kernel configuration requirements are present in OTA package (and will be enforced
284# during OTA). Otherwise, kernel configuration requirements are enforced in VTS.
285# Devices that checks the running kernel (instead of the kernel in OTA package) should not
286# set this variable to prevent OTA failures.
287_product_list_vars += PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
288
289# If set to true, this product builds a generic OTA package, which installs generic system images
290# onto matching devices. The product may only build a subset of system images (e.g. only
291# system.img), so devices need to install the package in a system-only OTA manner.
292_product_single_value_vars += PRODUCT_BUILD_GENERIC_OTA_PACKAGE
293
294_product_list_vars += PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
295_product_list_vars += PRODUCT_PACKAGE_NAME_OVERRIDES
296_product_list_vars += PRODUCT_CERTIFICATE_OVERRIDES
297
298# Controls for whether different partitions are built for the current product.
299_product_single_value_vars += PRODUCT_BUILD_SYSTEM_IMAGE
300_product_single_value_vars += PRODUCT_BUILD_SYSTEM_OTHER_IMAGE
301_product_single_value_vars += PRODUCT_BUILD_VENDOR_IMAGE
302_product_single_value_vars += PRODUCT_BUILD_PRODUCT_IMAGE
303_product_single_value_vars += PRODUCT_BUILD_SYSTEM_EXT_IMAGE
304_product_single_value_vars += PRODUCT_BUILD_ODM_IMAGE
305_product_single_value_vars += PRODUCT_BUILD_VENDOR_DLKM_IMAGE
306_product_single_value_vars += PRODUCT_BUILD_ODM_DLKM_IMAGE
307_product_single_value_vars += PRODUCT_BUILD_SYSTEM_DLKM_IMAGE
308_product_single_value_vars += PRODUCT_BUILD_CACHE_IMAGE
309_product_single_value_vars += PRODUCT_BUILD_RAMDISK_IMAGE
310_product_single_value_vars += PRODUCT_BUILD_USERDATA_IMAGE
311_product_single_value_vars += PRODUCT_BUILD_RECOVERY_IMAGE
312_product_single_value_vars += PRODUCT_BUILD_BOOT_IMAGE
313_product_single_value_vars += PRODUCT_BUILD_INIT_BOOT_IMAGE
314_product_single_value_vars += PRODUCT_BUILD_DEBUG_BOOT_IMAGE
315_product_single_value_vars += PRODUCT_BUILD_VENDOR_BOOT_IMAGE
316_product_single_value_vars += PRODUCT_BUILD_VENDOR_KERNEL_BOOT_IMAGE
317_product_single_value_vars += PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE
318_product_single_value_vars += PRODUCT_BUILD_VBMETA_IMAGE
319_product_single_value_vars += PRODUCT_BUILD_SUPER_EMPTY_IMAGE
320_product_single_value_vars += PRODUCT_BUILD_PVMFW_IMAGE
321
322# List of boot jars delivered via updatable APEXes, following the same format as
323# PRODUCT_BOOT_JARS.
324_product_list_vars += PRODUCT_APEX_BOOT_JARS
325
326# If set, device uses virtual A/B.
327_product_single_value_vars += PRODUCT_VIRTUAL_AB_OTA
328
329# If set, device uses virtual A/B Compression.
330_product_single_value_vars += PRODUCT_VIRTUAL_AB_COMPRESSION
331
332# If set, device retrofits virtual A/B.
333_product_single_value_vars += PRODUCT_VIRTUAL_AB_OTA_RETROFIT
334
335# If set, forcefully generate a non-A/B update package.
336# Note: A device configuration should inherit from virtual_ab_ota_plus_non_ab.mk
337# instead of setting this variable directly.
338# Note: Use TARGET_OTA_ALLOW_NON_AB in the build system because
339# TARGET_OTA_ALLOW_NON_AB takes the value of AB_OTA_UPDATER into account.
340_product_single_value_vars += PRODUCT_OTA_FORCE_NON_AB_PACKAGE
341
342# If set, Java module in product partition cannot use hidden APIs.
343_product_single_value_vars += PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE
344
345# If set, only java_sdk_library can be used at inter-partition dependency.
346# Note: Build error if BOARD_VNDK_VERSION is not set while
347#       PRODUCT_ENFORCE_INTER_PARTITION_JAVA_SDK_LIBRARY is true, because
348#       PRODUCT_ENFORCE_INTER_PARTITION_JAVA_SDK_LIBRARY has no meaning if
349#       BOARD_VNDK_VERSION is not set.
350# Note: When PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE is not set, there are
351#       no restrictions at dependency between system and product partition.
352_product_single_value_vars += PRODUCT_ENFORCE_INTER_PARTITION_JAVA_SDK_LIBRARY
353
354# Allowlist for PRODUCT_ENFORCE_INTER_PARTITION_JAVA_SDK_LIBRARY option.
355# Listed modules are allowed at inter-partition dependency even if it isn't
356# a java_sdk_library module.
357_product_list_vars += PRODUCT_INTER_PARTITION_JAVA_LIBRARY_ALLOWLIST
358
359_product_single_value_vars += PRODUCT_INSTALL_EXTRA_FLATTENED_APEXES
360
361# Install a copy of the debug policy to the system_ext partition, and allow
362# init-second-stage to load debug policy from system_ext.
363# This option is only meant to be set by compliance GSI targets.
364_product_single_value_vars += PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT
365
366# If set, metadata files for the following artifacts will be generated.
367# - system/framework/*.jar
368# - system/framework/oat/<arch>/*.{oat,vdex,art}
369# - system/etc/boot-image.prof
370# - system/etc/dirty-image-objects
371# One fsverity metadata container file per one input file will be generated in
372# system.img, with a suffix ".fsv_meta". e.g. a container file for
373# "/system/framework/foo.jar" will be "system/framework/foo.jar.fsv_meta".
374_product_single_value_vars += PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA
375
376# If true, sets the default for MODULE_BUILD_FROM_SOURCE. This overrides
377# BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE but not an explicitly set value.
378_product_single_value_vars += PRODUCT_MODULE_BUILD_FROM_SOURCE
379
380.KATI_READONLY := _product_single_value_vars _product_list_vars
381_product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars)
382
383#
384# Functions for including product makefiles
385#
386
387#
388# $(1): product to inherit
389#
390# To be called from product makefiles, and is later evaluated during the import-nodes
391# call below. It does the following:
392#  1. Inherits all of the variables from $1.
393#  2. Records the inheritance in the .INHERITS_FROM variable
394#
395# (2) and the PRODUCTS variable can be used together to reconstruct the include hierarchy
396# See e.g. product-graph.mk for an example of this.
397#
398define inherit-product
399  $(eval _inherit_product_wildcard := $(wildcard $(1)))\
400  $(if $(_inherit_product_wildcard),,$(error $(1) does not exist.))\
401  $(foreach part,$(_inherit_product_wildcard),\
402    $(if $(findstring ../,$(part)),\
403      $(eval np := $(call normalize-paths,$(part))),\
404      $(eval np := $(strip $(part))))\
405    $(foreach v,$(_product_var_list), \
406        $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
407    $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
408    $(eval inherit_var := PRODUCTS.$(current_mk).INHERITS_FROM) \
409    $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
410    $(call dump-inherit,$(strip $(word 1,$(_include_stack))),$(1)) \
411    $(call dump-config-vals,$(current_mk),inherit))
412endef
413
414# Specifies a number of path prefixes, relative to PRODUCT_OUT, where the
415# product makefile hierarchy rooted in the current node places its artifacts.
416# Creating artifacts outside the specified paths will cause a build-time error.
417define require-artifacts-in-path
418  $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
419  $(eval PRODUCTS.$(current_mk).ARTIFACT_PATH_REQUIREMENTS := $(strip $(1))) \
420  $(eval PRODUCTS.$(current_mk).ARTIFACT_PATH_ALLOWED_LIST := $(strip $(2))) \
421  $(eval ARTIFACT_PATH_REQUIREMENT_PRODUCTS := \
422    $(sort $(ARTIFACT_PATH_REQUIREMENT_PRODUCTS) $(current_mk)))
423endef
424
425# Like require-artifacts-in-path, but does not require all allow-list entries to
426# have an effect.
427define require-artifacts-in-path-relaxed
428  $(require-artifacts-in-path) \
429  $(eval PRODUCTS.$(current_mk).ARTIFACT_PATH_REQUIREMENT_IS_RELAXED := true)
430endef
431
432# Makes including non-existent modules in PRODUCT_PACKAGES an error.
433# $(1): list of non-existent modules to allow.
434define enforce-product-packages-exist
435  $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \
436  $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST := true) \
437  $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_ALLOW_LIST := $(1)) \
438  $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST) \
439  $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_ALLOW_LIST)
440endef
441
442#
443# Do inherit-product only if $(1) exists
444#
445define inherit-product-if-exists
446  $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
447endef
448
449#
450# $(1): product makefile list
451#
452#TODO: check to make sure that products have all the necessary vars defined
453define import-products
454$(call import-nodes,PRODUCTS,$(1),$(_product_var_list),$(_product_single_value_vars))
455endef
456
457
458#
459# Does various consistency checks on the current product.
460# Takes no parameters, so $(call ) is not necessary.
461#
462define check-current-product
463$(if ,, \
464  $(if $(call is-c-identifier,$(PRODUCT_NAME)),, \
465    $(error $(INTERNAL_PRODUCT): PRODUCT_NAME must be a valid C identifier, not "$(pn)")) \
466  $(if $(PRODUCT_BRAND),, \
467    $(error $(INTERNAL_PRODUCT): PRODUCT_BRAND must be defined.)) \
468  $(foreach cf,$(strip $(PRODUCT_COPY_FILES)), \
469    $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
470      $(error $(p): malformed COPY_FILE "$(cf)"))))
471endef
472
473# BoardConfig variables that are also inherited in product mks. Should ideally
474# be cleaned up to not be product variables.
475_readonly_late_variables := \
476  DEVICE_PACKAGE_OVERLAYS \
477  WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY \
478
479# Modified internally in the build system
480_readonly_late_variables += \
481  PRODUCT_COPY_FILES \
482  PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING \
483  PRODUCT_DEX_PREOPT_BOOT_FLAGS \
484
485_readonly_early_variables := $(filter-out $(_readonly_late_variables),$(_product_var_list))
486
487#
488# Mark the variables in _product_stash_var_list as readonly
489#
490define readonly-variables
491$(foreach v,$(1), \
492  $(eval $(v) ?=) \
493  $(eval .KATI_READONLY := $(v)) \
494 )
495endef
496define readonly-product-vars
497$(call readonly-variables,$(_readonly_early_variables))
498endef
499
500define readonly-final-product-vars
501$(call readonly-variables,$(_readonly_late_variables))
502endef
503
504# Macro re-defined inside strip-product-vars.
505get-product-var = $(PRODUCTS.$(strip $(1)).$(2))
506#
507# Strip the variables in _product_var_list and a few build-system
508# internal variables, and assign the ones for the current product
509# to a shorthand that is more convenient to read from elsewhere.
510#
511define strip-product-vars
512$(call dump-phase-start,PRODUCT-EXPAND,,$(_product_var_list),$(_product_single_value_vars), \
513		build/make/core/product.mk) \
514$(foreach v,\
515  $(_product_var_list) \
516    PRODUCT_ENFORCE_PACKAGES_EXIST \
517    PRODUCT_ENFORCE_PACKAGES_EXIST_ALLOW_LIST, \
518  $(eval $(v) := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).$(v)))) \
519  $(eval get-product-var = $$(if $$(filter $$(1),$$(INTERNAL_PRODUCT)),$$($$(2)),$$(PRODUCTS.$$(strip $$(1)).$$(2)))) \
520  $(KATI_obsolete_var PRODUCTS.$(INTERNAL_PRODUCT).$(v),Use $(v) instead) \
521) \
522$(call dump-phase-end,build/make/core/product.mk)
523endef
524
525define add-to-product-copy-files-if-exists
526$(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
527endef
528
529# whitespace placeholder when we record module's dex-preopt config.
530_PDPMC_SP_PLACE_HOLDER := |@SP@|
531# Set up dex-preopt config for a module.
532# $(1) list of module names
533# $(2) the modules' dex-preopt config
534define add-product-dex-preopt-module-config
535$(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
536$(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
537  $(foreach m,$(1),$(m)=$(_c)))
538endef
539
540# whitespace placeholder when we record module's sanitizer config.
541_PSMC_SP_PLACE_HOLDER := |@SP@|
542# Set up sanitizer config for a module.
543# $(1) list of module names
544# $(2) the modules' sanitizer config
545define add-product-sanitizer-module-config
546$(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
547$(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
548  $(foreach m,$(1),$(m)=$(_c)))
549endef
550