• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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$(sort $(shell find $(2) -name "$(1)" -type f | $(SED_EXTENDED) "s:($(2)/?(.*)):\\1\\:$(3)/\\2:" | sed "s://:/:g"))
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
147include $(BUILD_SYSTEM)/device.mk
148
149# Read all product definitions.
150#
151# Products are defined in AndroidProducts.mk files:
152android_products_makefiles := $(file <$(OUT_DIR)/.module_paths/AndroidProducts.mk.list) \
153  $(SRC_TARGET_DIR)/product/AndroidProducts.mk
154
155# An AndroidProduct.mk file sets the following variables:
156#   PRODUCT_MAKEFILES specifies product makefiles. Each item in this list
157#     is either a <product>:path/to/file.mk, or just path/to/<product.mk>
158#   COMMON_LUNCH_CHOICES specifies <product>-<variant> values to be shown
159#     in the `lunch` menu
160#   STARLARK_OPT_IN_PRODUCTS specifies products to use Starlark-based
161#     product configuration by default
162
163# Builds a list of first/second elements of each pair:
164#   $(call _first,a:A b:B,:) returns 'a b'
165#   $(call _second,a-A b-B,-) returns 'A B'
166_first=$(filter-out $(2)%,$(subst $(2),$(space)$(2),$(1)))
167_second=$(filter-out %$(2),$(subst $(2),$(2)$(space),$(1)))
168
169# Returns <product>:<path> pair from a PRODUCT_MAKEFILE item.
170# If an item is <product>:path/to/file.mk, return it as is,
171# otherwise assume that an item is path/to/<product>.mk and
172# return <product>:path/to/<product>.mk
173_product-spec=$(strip $(if $(findstring :,$(1)),$(1),$(basename $(notdir $(1))):$(1)))
174
175# Reads given AndroidProduct.mk file and sets the following variables:
176#  ap_product_paths -- the list of <product>:<path> pairs
177#  ap_common_lunch_choices -- the list of <product>-<build variant> items
178#  ap_products_using_starlark_config -- the list of products using starlark config
179# In addition, validates COMMON_LUNCH_CHOICES and STARLARK_OPT_IN_PRODUCTS values
180define _read-ap-file
181  $(eval PRODUCT_MAKEFILES :=) \
182  $(eval COMMON_LUNCH_CHOICES :=) \
183  $(eval STARLARK_OPT_IN_PRODUCTS := ) \
184  $(eval ap_product_paths :=) \
185  $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
186  $(eval include $(f)) \
187  $(foreach p, $(PRODUCT_MAKEFILES),$(eval ap_product_paths += $(call _product-spec,$(p)))) \
188  $(eval ap_common_lunch_choices  := $(COMMON_LUNCH_CHOICES)) \
189  $(eval ap_products_using_starlark_config := $(STARLARK_OPT_IN_PRODUCTS)) \
190  $(eval _products := $(call _first,$(ap_product_paths),:)) \
191  $(eval _bad := $(filter-out $(_products),$(call _first,$(ap_common_lunch_choices),-))) \
192  $(if $(_bad),$(error COMMON_LUNCH_CHOICES contains products(s) not defined in this file: $(_bad))) \
193  $(eval _bad := $(filter-out %-eng %-userdebug %-user,$(ap_common_lunch_choices))) \
194  $(if $(_bad),$(error invalid variant in COMMON_LUNCH_CHOICES: $(_bad)))
195  $(eval _bad := $(filter-out $(_products),$(ap_products_using_starlark_config))) \
196  $(if $(_bad),$(error STARLARK_OPT_IN_PRODUCTS contains product(s) not defined in this file: $(_bad)))
197endef
198
199# Build cumulative lists of all product specs/lunch choices/Starlark-based products.
200product_paths :=
201common_lunch_choices :=
202products_using_starlark_config :=
203$(foreach f,$(android_products_makefiles), \
204    $(call _read-ap-file,$(f)) \
205    $(eval product_paths += $(ap_product_paths)) \
206    $(eval common_lunch_choices += $(ap_common_lunch_choices)) \
207    $(eval products_using_starlark_config += $(ap_products_using_starlark_config)) \
208)
209
210# Dedup, extract product names, etc.
211product_paths := $(sort $(product_paths))
212all_named_products := $(sort $(call _first,$(product_paths),:))
213all_product_makefiles := $(sort $(call _second,$(product_paths),:))
214current_product_makefile := $(call _second,$(filter $(TARGET_PRODUCT):%,$(product_paths)),:)
215COMMON_LUNCH_CHOICES := $(sort $(common_lunch_choices))
216
217# Check that there are no duplicate product names
218$(foreach p,$(all_named_products), \
219  $(if $(filter 1,$(words $(filter $(p):%,$(product_paths)))),, \
220    $(error Product name must be unique, "$(p)" used by $(call _second,$(filter $(p):%,$(product_paths)),:))))
221
222ifneq ($(ALLOW_RULES_IN_PRODUCT_CONFIG),)
223_product_config_saved_KATI_ALLOW_RULES := $(.KATI_ALLOW_RULES)
224.KATI_ALLOW_RULES := $(ALLOW_RULES_IN_PRODUCT_CONFIG)
225endif
226
227ifeq (,$(current_product_makefile))
228  $(error Can not locate config makefile for product "$(TARGET_PRODUCT)")
229endif
230
231ifneq (,$(filter $(TARGET_PRODUCT),$(products_using_starlark_config)))
232  RBC_PRODUCT_CONFIG := true
233  RBC_BOARD_CONFIG := true
234endif
235
236ifndef RBC_PRODUCT_CONFIG
237$(call import-products, $(current_product_makefile))
238else
239  $(shell mkdir -p $(OUT_DIR)/rbc)
240  $(call dump-variables-rbc, $(OUT_DIR)/rbc/make_vars_pre_product_config.mk)
241
242  $(shell build/soong/scripts/update_out \
243    $(OUT_DIR)/rbc/rbc_product_config_results.mk \
244    build/soong/scripts/rbc-run \
245    $(current_product_makefile) \
246    $(OUT_DIR)/rbc/make_vars_pre_product_config.mk)
247  ifneq ($(.SHELLSTATUS),0)
248    $(error product configuration converter failed: $(.SHELLSTATUS))
249  endif
250  include $(OUT_DIR)/rbc/rbc_product_config_results.mk
251endif
252
253# This step was already handled in the RBC product configuration.
254ifeq ($(RBC_PRODUCT_CONFIG)$(SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK),)
255# Import all the products that have made artifact path requirements, so that we can verify
256# the artifacts they produce. They might be intermediate makefiles instead of real products.
257$(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\
258  $(if $(filter-out $(makefile),$(PRODUCTS)),$(eval $(call import-products,$(makefile))))\
259)
260endif
261
262INTERNAL_PRODUCT := $(current_product_makefile)
263# Strip and assign the PRODUCT_ variables.
264$(call strip-product-vars)
265
266# Quick check
267$(check-current-product)
268
269ifneq ($(ALLOW_RULES_IN_PRODUCT_CONFIG),)
270.KATI_ALLOW_RULES := $(_saved_KATI_ALLOW_RULES)
271_product_config_saved_KATI_ALLOW_RULES :=
272endif
273
274############################################################################
275
276current_product_makefile :=
277all_product_makefiles :=
278all_product_configs :=
279
280#############################################################################
281# Check product include tag allowlist
282BLUEPRINT_INCLUDE_TAGS_ALLOWLIST := com.android.mainline_go com.android.mainline
283.KATI_READONLY := BLUEPRINT_INCLUDE_TAGS_ALLOWLIST
284$(foreach include_tag,$(PRODUCT_INCLUDE_TAGS), \
285	$(if $(filter $(include_tag),$(BLUEPRINT_INCLUDE_TAGS_ALLOWLIST)),,\
286	$(call pretty-error, $(include_tag) is not in BLUEPRINT_INCLUDE_TAGS_ALLOWLIST: $(BLUEPRINT_INCLUDE_TAGS_ALLOWLIST))))
287#############################################################################
288
289# Quick check and assign default values
290
291TARGET_DEVICE := $(PRODUCT_DEVICE)
292
293# TODO: also keep track of things like "port", "land" in product files.
294
295# Figure out which resoure configuration options to use for this
296# product.
297# If CUSTOM_LOCALES contains any locales not already included
298# in PRODUCT_LOCALES, add them to PRODUCT_LOCALES.
299extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES))
300ifneq (,$(extra_locales))
301  ifneq ($(CALLED_FROM_SETUP),true)
302    # Don't spam stdout, because envsetup.sh may be scraping values from it.
303    $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)])
304  endif
305  PRODUCT_LOCALES += $(extra_locales)
306  extra_locales :=
307endif
308
309# Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG
310PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) $(PRODUCT_AAPT_CONFIG)
311
312# Keep a copy of the space-separated config
313PRODUCT_AAPT_CONFIG_SP := $(PRODUCT_AAPT_CONFIG)
314PRODUCT_AAPT_CONFIG := $(subst $(space),$(comma),$(PRODUCT_AAPT_CONFIG))
315
316###########################################################
317## Add 'platform:' prefix to jars not in <apex>:<module> format.
318##
319## This makes sure that a jar corresponds to ConfigureJarList format of <apex> and <module> pairs
320## where needed.
321##
322## $(1): a list of jars either in <module> or <apex>:<module> format
323###########################################################
324
325define qualify-platform-jars
326  $(foreach jar,$(1),$(if $(findstring :,$(jar)),,platform:)$(jar))
327endef
328
329# Extra boot jars must be appended at the end after common boot jars.
330PRODUCT_BOOT_JARS += $(PRODUCT_BOOT_JARS_EXTRA)
331
332PRODUCT_BOOT_JARS := $(call qualify-platform-jars,$(PRODUCT_BOOT_JARS))
333
334# b/191127295: force core-icu4j onto boot image. It comes from a non-updatable APEX jar, but has
335# historically been part of the boot image; even though APEX jars are not meant to be part of the
336# boot image.
337# TODO(b/191686720): remove PRODUCT_APEX_BOOT_JARS to avoid a special handling of core-icu4j
338# in make rules.
339PRODUCT_APEX_BOOT_JARS := $(filter-out com.android.i18n:core-icu4j,$(PRODUCT_APEX_BOOT_JARS))
340# All APEX jars come after /system and /system_ext jars, so adding core-icu4j at the end of the list
341PRODUCT_BOOT_JARS += com.android.i18n:core-icu4j
342
343# The extra system server jars must be appended at the end after common system server jars.
344PRODUCT_SYSTEM_SERVER_JARS += $(PRODUCT_SYSTEM_SERVER_JARS_EXTRA)
345
346PRODUCT_SYSTEM_SERVER_JARS := $(call qualify-platform-jars,$(PRODUCT_SYSTEM_SERVER_JARS))
347
348# Sort APEX boot and system server jars. We use deterministic alphabetical order
349# when constructing BOOTCLASSPATH and SYSTEMSERVERCLASSPATH definition on device
350# after an update. Enforce it in the build system as well to avoid recompiling
351# everything after an update due a change in the order.
352PRODUCT_APEX_BOOT_JARS := $(sort $(PRODUCT_APEX_BOOT_JARS))
353PRODUCT_APEX_SYSTEM_SERVER_JARS := $(sort $(PRODUCT_APEX_SYSTEM_SERVER_JARS))
354
355PRODUCT_STANDALONE_SYSTEM_SERVER_JARS := \
356  $(call qualify-platform-jars,$(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS))
357
358ifndef PRODUCT_SYSTEM_NAME
359  PRODUCT_SYSTEM_NAME := $(PRODUCT_NAME)
360endif
361ifndef PRODUCT_SYSTEM_DEVICE
362  PRODUCT_SYSTEM_DEVICE := $(PRODUCT_DEVICE)
363endif
364ifndef PRODUCT_SYSTEM_BRAND
365  PRODUCT_SYSTEM_BRAND := $(PRODUCT_BRAND)
366endif
367ifndef PRODUCT_MODEL
368  PRODUCT_MODEL := $(PRODUCT_NAME)
369endif
370ifndef PRODUCT_SYSTEM_MODEL
371  PRODUCT_SYSTEM_MODEL := $(PRODUCT_MODEL)
372endif
373
374ifndef PRODUCT_MANUFACTURER
375  PRODUCT_MANUFACTURER := unknown
376endif
377ifndef PRODUCT_SYSTEM_MANUFACTURER
378  PRODUCT_SYSTEM_MANUFACTURER := $(PRODUCT_MANUFACTURER)
379endif
380
381ifndef PRODUCT_CHARACTERISTICS
382  TARGET_AAPT_CHARACTERISTICS := default
383else
384  TARGET_AAPT_CHARACTERISTICS := $(PRODUCT_CHARACTERISTICS)
385endif
386
387ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
388  ifneq (1,$(words $(PRODUCT_DEFAULT_DEV_CERTIFICATE)))
389    $(error PRODUCT_DEFAULT_DEV_CERTIFICATE='$(PRODUCT_DEFAULT_DEV_CERTIFICATE)', \
390      only 1 certificate is allowed.)
391  endif
392endif
393
394$(foreach pair,$(PRODUCT_APEX_BOOT_JARS), \
395  $(eval jar := $(call word-colon,2,$(pair))) \
396  $(if $(findstring $(jar), $(PRODUCT_BOOT_JARS)), \
397    $(error A jar in PRODUCT_APEX_BOOT_JARS must not be in PRODUCT_BOOT_JARS, but $(jar) is)))
398
399ENFORCE_SYSTEM_CERTIFICATE := $(PRODUCT_ENFORCE_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT)
400ENFORCE_SYSTEM_CERTIFICATE_ALLOW_LIST := $(PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_ALLOW_LIST)
401
402PRODUCT_OTA_PUBLIC_KEYS := $(sort $(PRODUCT_OTA_PUBLIC_KEYS))
403PRODUCT_EXTRA_OTA_KEYS := $(sort $(PRODUCT_EXTRA_OTA_KEYS))
404PRODUCT_EXTRA_RECOVERY_KEYS := $(sort $(PRODUCT_EXTRA_RECOVERY_KEYS))
405
406# Resolve and setup per-module dex-preopt configs.
407DEXPREOPT_DISABLED_MODULES :=
408# If a module has multiple setups, the first takes precedence.
409_pdpmc_modules :=
410$(foreach c,$(PRODUCT_DEX_PREOPT_MODULE_CONFIGS),\
411  $(eval m := $(firstword $(subst =,$(space),$(c))))\
412  $(if $(filter $(_pdpmc_modules),$(m)),,\
413    $(eval _pdpmc_modules += $(m))\
414    $(eval cf := $(patsubst $(m)=%,%,$(c)))\
415    $(eval cf := $(subst $(_PDPMC_SP_PLACE_HOLDER),$(space),$(cf)))\
416    $(if $(filter disable,$(cf)),\
417      $(eval DEXPREOPT_DISABLED_MODULES += $(m)),\
418      $(eval DEXPREOPT.$(TARGET_PRODUCT).$(m).CONFIG := $(cf)))))
419_pdpmc_modules :=
420
421
422# Resolve and setup per-module sanitizer configs.
423# If a module has multiple setups, the first takes precedence.
424_psmc_modules :=
425$(foreach c,$(PRODUCT_SANITIZER_MODULE_CONFIGS),\
426  $(eval m := $(firstword $(subst =,$(space),$(c))))\
427  $(if $(filter $(_psmc_modules),$(m)),,\
428    $(eval _psmc_modules += $(m))\
429    $(eval cf := $(patsubst $(m)=%,%,$(c)))\
430    $(eval cf := $(subst $(_PSMC_SP_PLACE_HOLDER),$(space),$(cf)))\
431    $(eval SANITIZER.$(TARGET_PRODUCT).$(m).CONFIG := $(cf))))
432_psmc_modules :=
433
434# Reset ADB keys for non-debuggable builds
435ifeq (,$(filter eng userdebug,$(TARGET_BUILD_VARIANT)))
436  PRODUCT_ADB_KEYS :=
437endif
438ifneq ($(filter-out 0 1,$(words $(PRODUCT_ADB_KEYS))),)
439  $(error Only one file may be in PRODUCT_ADB_KEYS: $(PRODUCT_ADB_KEYS))
440endif
441
442# Show a warning wall of text if non-compliance-GSI products set this option.
443ifdef PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT
444  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)))
445    $(warning PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT is set but \
446      PRODUCT_NAME ($(PRODUCT_NAME)) doesn't look like a GSI for compliance \
447      testing. This is a special configuration for compliance GSI, so do make \
448      sure you understand the security implications before setting this \
449      option. If you don't know what this option does, then you probably \
450      shouldn't set this.)
451  endif
452endif
453
454ifndef PRODUCT_USE_DYNAMIC_PARTITIONS
455  PRODUCT_USE_DYNAMIC_PARTITIONS := $(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)
456endif
457
458# All requirements of PRODUCT_USE_DYNAMIC_PARTITIONS falls back to
459# PRODUCT_USE_DYNAMIC_PARTITIONS if not defined.
460ifndef PRODUCT_USE_DYNAMIC_PARTITION_SIZE
461  PRODUCT_USE_DYNAMIC_PARTITION_SIZE := $(PRODUCT_USE_DYNAMIC_PARTITIONS)
462endif
463
464ifndef PRODUCT_BUILD_SUPER_PARTITION
465  PRODUCT_BUILD_SUPER_PARTITION := $(PRODUCT_USE_DYNAMIC_PARTITIONS)
466endif
467
468ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),)
469  ifdef PRODUCT_SHIPPING_API_LEVEL
470    ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29))
471      PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := true
472    endif
473  endif
474endif
475
476ifeq ($(PRODUCT_SET_DEBUGFS_RESTRICTIONS),)
477  ifdef PRODUCT_SHIPPING_API_LEVEL
478    ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),31))
479      PRODUCT_SET_DEBUGFS_RESTRICTIONS := true
480    endif
481  endif
482endif
483
484ifdef PRODUCT_SHIPPING_API_LEVEL
485  ifneq (,$(call math_gt_or_eq,29,$(PRODUCT_SHIPPING_API_LEVEL)))
486    PRODUCT_PACKAGES += $(PRODUCT_PACKAGES_SHIPPING_API_LEVEL_29)
487  endif
488endif
489
490# If build command defines OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS,
491# override PRODUCT_EXTRA_VNDK_VERSIONS with it.
492ifdef OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS
493  PRODUCT_EXTRA_VNDK_VERSIONS := $(OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS)
494endif
495
496###########################################
497# APEXes are by default not compressed
498#
499# APEX compression can be forcibly enabled (resp. disabled) by
500# setting OVERRIDE_PRODUCT_COMPRESSED_APEX to true (resp. false), e.g. by
501# setting the OVERRIDE_PRODUCT_COMPRESSED_APEX environment variable.
502ifdef OVERRIDE_PRODUCT_COMPRESSED_APEX
503  PRODUCT_COMPRESSED_APEX := $(OVERRIDE_PRODUCT_COMPRESSED_APEX)
504endif
505
506$(KATI_obsolete_var OVERRIDE_PRODUCT_EXTRA_VNDK_VERSIONS \
507    ,Use PRODUCT_EXTRA_VNDK_VERSIONS instead)
508
509# If build command defines OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE,
510# override PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE with it unless it is
511# defined as `false`. If the value is `false` clear
512# PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE
513# OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE can be used for
514# testing only.
515ifdef OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE
516  ifeq (false,$(OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE))
517    PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE :=
518  else
519    PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := $(OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE)
520  endif
521else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),)
522  # No shipping level defined
523else ifeq ($(call math_gt,$(PRODUCT_SHIPPING_API_LEVEL),29),true)
524  # Enforce product interface if PRODUCT_SHIPPING_API_LEVEL is greater than 29.
525  PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE := true
526endif
527
528$(KATI_obsolete_var OVERRIDE_PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE,Use PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE instead)
529
530# If build command defines PRODUCT_USE_PRODUCT_VNDK_OVERRIDE as `false`,
531# PRODUCT_PRODUCT_VNDK_VERSION will not be defined automatically.
532# PRODUCT_USE_PRODUCT_VNDK_OVERRIDE can be used for testing only.
533PRODUCT_USE_PRODUCT_VNDK := false
534ifneq ($(PRODUCT_USE_PRODUCT_VNDK_OVERRIDE),)
535  PRODUCT_USE_PRODUCT_VNDK := $(PRODUCT_USE_PRODUCT_VNDK_OVERRIDE)
536else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),)
537  # No shipping level defined
538else ifeq ($(call math_gt,$(PRODUCT_SHIPPING_API_LEVEL),29),true)
539  # Enforce product interface for VNDK if PRODUCT_SHIPPING_API_LEVEL is greater
540  # than 29.
541  PRODUCT_USE_PRODUCT_VNDK := true
542endif
543
544ifeq ($(PRODUCT_USE_PRODUCT_VNDK),true)
545  ifndef PRODUCT_PRODUCT_VNDK_VERSION
546    PRODUCT_PRODUCT_VNDK_VERSION := current
547  endif
548endif
549
550$(KATI_obsolete_var PRODUCT_USE_PRODUCT_VNDK,Use PRODUCT_PRODUCT_VNDK_VERSION instead)
551$(KATI_obsolete_var PRODUCT_USE_PRODUCT_VNDK_OVERRIDE,Use PRODUCT_PRODUCT_VNDK_VERSION instead)
552
553ifdef PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS
554    $(error PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS is deprecated, consider using RRO for \
555      $(PRODUCT_ENFORCE_RRO_EXEMPTED_TARGETS))
556endif
557
558define product-overrides-config
559$$(foreach rule,$$(PRODUCT_$(1)_OVERRIDES),\
560    $$(if $$(filter 2,$$(words $$(subst :,$$(space),$$(rule)))),,\
561        $$(error Rule "$$(rule)" in PRODUCT_$(1)_OVERRIDE is not <module_name>:<new_value>)))
562endef
563
564$(foreach var, \
565    MANIFEST_PACKAGE_NAME \
566    PACKAGE_NAME \
567    CERTIFICATE, \
568  $(eval $(call product-overrides-config,$(var))))
569
570# Macro to use below. $(1) is the name of the partition
571define product-build-image-config
572ifneq ($$(filter-out true false,$$(PRODUCT_BUILD_$(1)_IMAGE)),)
573    $$(error Invalid PRODUCT_BUILD_$(1)_IMAGE: $$(PRODUCT_BUILD_$(1)_IMAGE) -- true false and empty are supported)
574endif
575endef
576
577# Copy and check the value of each PRODUCT_BUILD_*_IMAGE variable
578$(foreach image, \
579    PVMFW \
580    SYSTEM \
581    SYSTEM_OTHER \
582    VENDOR \
583    PRODUCT \
584    SYSTEM_EXT \
585    ODM \
586    VENDOR_DLKM \
587    ODM_DLKM \
588    SYSTEM_DLKM \
589    CACHE \
590    RAMDISK \
591    USERDATA \
592    BOOT \
593    RECOVERY, \
594  $(eval $(call product-build-image-config,$(image))))
595
596product-build-image-config :=
597
598$(call readonly-product-vars)
599