1#
2# Copyright (C) 2019 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# This file includes BoardConfig.mk for the device being built,
19# and checks the variable defined therein.
20# ###############################################################
21
22_board_strip_readonly_list := \
23  BOARD_EGL_CFG \
24  BOARD_HAVE_BLUETOOTH \
25  BOARD_INSTALLER_CMDLINE \
26  BOARD_KERNEL_CMDLINE \
27  BOARD_KERNEL_BASE \
28  BOARD_USES_GENERIC_AUDIO \
29  BOARD_USES_RECOVERY_AS_BOOT \
30  BOARD_VENDOR_USE_AKMD \
31  BOARD_WPA_SUPPLICANT_DRIVER \
32  BOARD_WLAN_DEVICE \
33  TARGET_ARCH \
34  TARGET_ARCH_VARIANT \
35  TARGET_CPU_ABI \
36  TARGET_CPU_ABI2 \
37  TARGET_CPU_VARIANT \
38  TARGET_CPU_VARIANT_RUNTIME \
39  TARGET_2ND_ARCH \
40  TARGET_2ND_ARCH_VARIANT \
41  TARGET_2ND_CPU_ABI \
42  TARGET_2ND_CPU_ABI2 \
43  TARGET_2ND_CPU_VARIANT \
44  TARGET_2ND_CPU_VARIANT_RUNTIME \
45  TARGET_BOARD_PLATFORM \
46  TARGET_BOARD_PLATFORM_GPU \
47  TARGET_BOOTLOADER_BOARD_NAME \
48  TARGET_FS_CONFIG_GEN \
49  TARGET_NO_BOOTLOADER \
50  TARGET_NO_KERNEL \
51  TARGET_NO_RECOVERY \
52  TARGET_NO_RADIOIMAGE \
53  TARGET_HARDWARE_3D \
54  WITH_DEXPREOPT \
55
56# File system variables
57_board_strip_readonly_list += \
58  BOARD_FLASH_BLOCK_SIZE \
59  BOARD_BOOTIMAGE_PARTITION_SIZE \
60  BOARD_RECOVERYIMAGE_PARTITION_SIZE \
61  BOARD_SYSTEMIMAGE_PARTITION_SIZE \
62  BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
63  BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
64  BOARD_USERDATAIMAGE_PARTITION_SIZE \
65  BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
66  BOARD_CACHEIMAGE_PARTITION_SIZE \
67  BOARD_VENDORIMAGE_PARTITION_SIZE \
68  BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
69  BOARD_PRODUCTIMAGE_PARTITION_SIZE \
70  BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE \
71  BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE \
72  BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE \
73  BOARD_ODMIMAGE_PARTITION_SIZE \
74  BOARD_ODMIMAGE_FILE_SYSTEM_TYPE \
75  BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE \
76  BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE \
77  BOARD_ODM_DLKMIMAGE_PARTITION_SIZE \
78  BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE \
79
80# Logical partitions related variables.
81_dynamic_partitions_var_list += \
82  BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE \
83  BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE \
84  BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE \
85  BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE \
86  BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE \
87  BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE \
88  BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE \
89  BOARD_SUPER_PARTITION_SIZE \
90  BOARD_SUPER_PARTITION_GROUPS \
91
92_board_strip_readonly_list += $(_dynamic_partitions_var_list)
93
94_build_broken_var_list := \
95  BUILD_BROKEN_DUP_RULES \
96  BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES \
97  BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS \
98  BUILD_BROKEN_PREBUILT_ELF_FILES \
99  BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW \
100  BUILD_BROKEN_USES_NETWORK \
101  BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES \
102  BUILD_BROKEN_DUP_SYSPROP \
103
104_build_broken_var_list += \
105  $(foreach m,$(AVAILABLE_BUILD_MODULE_TYPES) \
106              $(DEFAULT_WARNING_BUILD_MODULE_TYPES) \
107              $(DEFAULT_ERROR_BUILD_MODULE_TYPES), \
108    BUILD_BROKEN_USES_$(m))
109
110_board_true_false_vars := $(_build_broken_var_list)
111_board_strip_readonly_list += $(_build_broken_var_list) \
112  BUILD_BROKEN_NINJA_USES_ENV_VARS
113
114# Conditional to building on linux, as dex2oat currently does not work on darwin.
115ifeq ($(HOST_OS),linux)
116  WITH_DEXPREOPT := true
117endif
118
119# ###############################################################
120# Broken build defaults
121# ###############################################################
122$(foreach v,$(_build_broken_var_list),$(eval $(v) :=))
123BUILD_BROKEN_NINJA_USES_ENV_VARS :=
124
125# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
126# or under vendor/*/$(TARGET_DEVICE).  Search in both places, but
127# make sure only one exists.
128# Real boards should always be associated with an OEM vendor.
129ifdef TARGET_DEVICE_DIR
130  ifneq ($(origin TARGET_DEVICE_DIR),command line)
131    $(error TARGET_DEVICE_DIR may not be set manually)
132  endif
133  board_config_mk := $(TARGET_DEVICE_DIR)/BoardConfig.mk
134else
135  board_config_mk := \
136    $(strip $(sort $(wildcard \
137      $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
138      $(shell test -d device && find -L device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
139      $(shell test -d vendor && find -L vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
140    )))
141  ifeq ($(board_config_mk),)
142    $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
143  endif
144  ifneq ($(words $(board_config_mk)),1)
145    $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
146  endif
147  TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
148  .KATI_READONLY := TARGET_DEVICE_DIR
149endif
150include $(board_config_mk)
151ifeq ($(TARGET_ARCH),)
152  $(error TARGET_ARCH not defined by board config: $(board_config_mk))
153endif
154ifneq ($(MALLOC_IMPL),)
155  $(warning *** Unsupported option MALLOC_IMPL defined by board config: $(board_config_mk).)
156  $(error Use `MALLOC_SVELTE := true` to configure jemalloc for low-memory)
157endif
158board_config_mk :=
159
160# Clean up and verify BoardConfig variables
161$(foreach var,$(_board_strip_readonly_list),$(eval $(var) := $$(strip $$($(var)))))
162$(foreach var,$(_board_true_false_vars), \
163  $(if $(filter-out true false,$($(var))), \
164    $(error Valid values of $(var) are "true", "false", and "". Not "$($(var))")))
165
166# Default *_CPU_VARIANT_RUNTIME to CPU_VARIANT if unspecified.
167TARGET_CPU_VARIANT_RUNTIME := $(or $(TARGET_CPU_VARIANT_RUNTIME),$(TARGET_CPU_VARIANT))
168TARGET_2ND_CPU_VARIANT_RUNTIME := $(or $(TARGET_2ND_CPU_VARIANT_RUNTIME),$(TARGET_2ND_CPU_VARIANT))
169
170# The combo makefiles check and set defaults for various CPU configuration
171combo_target := TARGET_
172combo_2nd_arch_prefix :=
173include $(BUILD_SYSTEM)/combo/select.mk
174
175ifdef TARGET_2ND_ARCH
176  combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
177  include $(BUILD_SYSTEM)/combo/select.mk
178endif
179
180.KATI_READONLY := $(_board_strip_readonly_list)
181
182INTERNAL_KERNEL_CMDLINE := $(BOARD_KERNEL_CMDLINE)
183ifeq ($(TARGET_CPU_ABI),)
184  $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
185endif
186ifneq ($(filter %64,$(TARGET_ARCH)),)
187  TARGET_IS_64_BIT := true
188endif
189
190ifeq (,$(filter true,$(TARGET_SUPPORTS_32_BIT_APPS) $(TARGET_SUPPORTS_64_BIT_APPS)))
191  TARGET_SUPPORTS_32_BIT_APPS := true
192endif
193
194# Quick check to warn about likely cryptic errors later in the build.
195ifeq ($(TARGET_IS_64_BIT),true)
196  ifeq (,$(filter true false,$(TARGET_SUPPORTS_64_BIT_APPS)))
197    $(error Building a 32-bit-app-only product on a 64-bit device. \
198      If this is intentional, set TARGET_SUPPORTS_64_BIT_APPS := false)
199  endif
200endif
201
202# "ro.product.cpu.abilist32" and "ro.product.cpu.abilist64" are
203# comma separated lists of the 32 and 64 bit ABIs (in order of
204# preference) that the target supports. If TARGET_CPU_ABI_LIST_{32,64}_BIT
205# are defined by the board config, we use them. Else, we construct
206# these lists based on whether TARGET_IS_64_BIT is set.
207#
208# Note that this assumes that the 2ND_CPU_ABI for a 64 bit target
209# is always 32 bits. If this isn't the case, these variables should
210# be overriden in the board configuration.
211#
212# Similarly, TARGET_NATIVE_BRIDGE_2ND_ABI for a 64 bit target is always
213# 32 bits. Note that all CPU_ABIs are preferred over all NATIVE_BRIDGE_ABIs.
214_target_native_bridge_abi_list_32_bit :=
215_target_native_bridge_abi_list_64_bit :=
216
217ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
218  ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
219    TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
220    _target_native_bridge_abi_list_64_bit := $(TARGET_NATIVE_BRIDGE_ABI)
221  endif
222endif
223
224# "arm64-v8a-hwasan", the ABI for libraries compiled with HWASAN, is supported
225# in all builds with SANITIZE_TARGET=hwaddress.
226ifneq ($(filter hwaddress,$(SANITIZE_TARGET)),)
227  ifneq ($(filter arm64-v8a,$(TARGET_CPU_ABI_LIST_64_BIT)),)
228    TARGET_CPU_ABI_LIST_64_BIT := arm64-v8a-hwasan $(TARGET_CPU_ABI_LIST_64_BIT)
229  endif
230endif
231
232ifeq (,$(TARGET_CPU_ABI_LIST_32_BIT))
233  ifneq (true,$(TARGET_IS_64_BIT))
234    TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
235    _target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_ABI)
236  else
237    ifeq (true,$(TARGET_SUPPORTS_32_BIT_APPS))
238      # For a 64 bit target, assume that the 2ND_CPU_ABI
239      # is a 32 bit ABI.
240      TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)
241      _target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_2ND_ABI)
242    endif
243  endif
244endif
245
246# "ro.product.cpu.abilist" is a comma separated list of ABIs (in order
247# of preference) that the target supports. If a TARGET_CPU_ABI_LIST
248# is specified by the board configuration, we use that. If not, we
249# build a list out of the TARGET_CPU_ABIs specified by the config.
250# Add NATIVE_BRIDGE_ABIs at the end to keep order of preference.
251ifeq (,$(TARGET_CPU_ABI_LIST))
252  TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT) \
253                         $(_target_native_bridge_abi_list_64_bit) $(_target_native_bridge_abi_list_32_bit)
254endif
255
256# Add NATIVE_BRIDGE_ABIs at the end of 32 and 64 bit CPU_ABIs to keep order of preference.
257TARGET_CPU_ABI_LIST_32_BIT += $(_target_native_bridge_abi_list_32_bit)
258TARGET_CPU_ABI_LIST_64_BIT += $(_target_native_bridge_abi_list_64_bit)
259
260# Strip whitespace from the ABI list string.
261TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
262TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
263TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
264
265# Check if config about image building is valid or not.
266define check_image_config
267  $(eval _uc_name := $(call to-upper,$(1))) \
268  $(eval _lc_name := $(call to-lower,$(1))) \
269  $(if $(filter $(_lc_name),$(TARGET_COPY_OUT_$(_uc_name))), \
270    $(if $(BOARD_USES_$(_uc_name)IMAGE),, \
271      $(error If TARGET_COPY_OUT_$(_uc_name) is '$(_lc_name)', either BOARD_PREBUILT_$(_uc_name)IMAGE or BOARD_$(_uc_name)IMAGE_FILE_SYSTEM_TYPE must be set)), \
272  $(if $(BOARD_USES_$(_uc_name)IMAGE), \
273    $(error TARGET_COPY_OUT_$(_uc_name) must be set to '$(_lc_name)' to use a $(_lc_name) image))) \
274  $(eval _uc_name :=) \
275  $(eval _lc_name :=)
276endef
277
278###########################################
279# Now we can substitute with the real value of TARGET_COPY_OUT_RAMDISK
280ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
281TARGET_COPY_OUT_RAMDISK := $(TARGET_COPY_OUT_ROOT)
282endif
283
284###########################################
285# Now we can substitute with the real value of TARGET_COPY_OUT_DEBUG_RAMDISK
286ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
287TARGET_COPY_OUT_DEBUG_RAMDISK := debug_ramdisk/first_stage_ramdisk
288TARGET_COPY_OUT_VENDOR_DEBUG_RAMDISK := vendor_debug_ramdisk/first_stage_ramdisk
289TARGET_COPY_OUT_TEST_HARNESS_RAMDISK := test_harness_ramdisk/first_stage_ramdisk
290endif
291
292###########################################
293# Configure whether we're building the system image
294BUILDING_SYSTEM_IMAGE := true
295ifeq ($(PRODUCT_BUILD_SYSTEM_IMAGE),)
296  ifndef PRODUCT_USE_DYNAMIC_PARTITION_SIZE
297    ifndef BOARD_SYSTEMIMAGE_PARTITION_SIZE
298      BUILDING_SYSTEM_IMAGE :=
299    endif
300  endif
301else ifeq ($(PRODUCT_BUILD_SYSTEM_IMAGE),false)
302  BUILDING_SYSTEM_IMAGE :=
303endif
304.KATI_READONLY := BUILDING_SYSTEM_IMAGE
305
306# Are we building a system_other image
307BUILDING_SYSTEM_OTHER_IMAGE :=
308ifeq ($(PRODUCT_BUILD_SYSTEM_OTHER_IMAGE),)
309  ifdef BUILDING_SYSTEM_IMAGE
310    ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
311      BUILDING_SYSTEM_OTHER_IMAGE := true
312    endif
313  endif
314else ifeq ($(PRODUCT_BUILD_SYSTEM_OTHER_IMAGE),true)
315  BUILDING_SYSTEM_OTHER_IMAGE := true
316  ifndef BUILDING_SYSTEM_IMAGE
317    $(error PRODUCT_BUILD_SYSTEM_OTHER_IMAGE = true requires building the system image)
318  endif
319endif
320.KATI_READONLY := BUILDING_SYSTEM_OTHER_IMAGE
321
322# Are we building a cache image
323BUILDING_CACHE_IMAGE :=
324ifeq ($(PRODUCT_BUILD_CACHE_IMAGE),)
325  ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
326    BUILDING_CACHE_IMAGE := true
327  endif
328else ifeq ($(PRODUCT_BUILD_CACHE_IMAGE),true)
329  BUILDING_CACHE_IMAGE := true
330  ifndef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
331    $(error PRODUCT_BUILD_CACHE_IMAGE set to true, but BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE not defined)
332  endif
333endif
334.KATI_READONLY := BUILDING_CACHE_IMAGE
335
336# Are we building a boot image
337BUILDING_BOOT_IMAGE :=
338ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
339  BUILDING_BOOT_IMAGE :=
340else ifeq ($(PRODUCT_BUILD_BOOT_IMAGE),)
341  ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
342    BUILDING_BOOT_IMAGE := true
343  endif
344else ifeq ($(PRODUCT_BUILD_BOOT_IMAGE),true)
345  BUILDING_BOOT_IMAGE := true
346endif
347.KATI_READONLY := BUILDING_BOOT_IMAGE
348
349# Are we building a recovery image
350BUILDING_RECOVERY_IMAGE :=
351ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
352  BUILDING_RECOVERY_IMAGE := true
353else ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),)
354  ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
355    ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
356      BUILDING_RECOVERY_IMAGE := true
357    endif
358  endif
359else ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),true)
360  BUILDING_RECOVERY_IMAGE := true
361endif
362.KATI_READONLY := BUILDING_RECOVERY_IMAGE
363
364# Are we building a vendor boot image
365BUILDING_VENDOR_BOOT_IMAGE :=
366ifdef BOARD_BOOT_HEADER_VERSION
367  ifneq ($(call math_gt_or_eq,$(BOARD_BOOT_HEADER_VERSION),3),)
368    ifneq ($(TARGET_NO_VENDOR_BOOT),true)
369      BUILDING_VENDOR_BOOT_IMAGE := true
370    endif
371  endif
372endif
373.KATI_READONLY := BUILDING_VENDOR_BOOT_IMAGE
374
375# Are we building a ramdisk image
376BUILDING_RAMDISK_IMAGE := true
377ifeq ($(PRODUCT_BUILD_RAMDISK_IMAGE),)
378  # TODO: Be smarter about this. This probably only needs to happen when one of the follow is true:
379  #  BUILDING_BOOT_IMAGE
380  #  BUILDING_RECOVERY_IMAGE
381else ifeq ($(PRODUCT_BUILD_RAMDISK_IMAGE),false)
382  BUILDING_RAMDISK_IMAGE :=
383endif
384.KATI_READONLY := BUILDING_RAMDISK_IMAGE
385
386# Are we building a userdata image
387BUILDING_USERDATA_IMAGE :=
388ifeq ($(PRODUCT_BUILD_USERDATA_IMAGE),)
389  ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
390    BUILDING_USERDATA_IMAGE := true
391  endif
392else ifeq ($(PRODUCT_BUILD_USERDATA_IMAGE),true)
393  BUILDING_USERDATA_IMAGE := true
394endif
395.KATI_READONLY := BUILDING_USERDATA_IMAGE
396
397# Are we building a vbmeta image
398BUILDING_VBMETA_IMAGE := true
399ifeq ($(PRODUCT_BUILD_VBMETA_IMAGE),false)
400  BUILDING_VBMETA_IMAGE :=
401endif
402.KATI_READONLY := BUILDING_VBMETA_IMAGE
403
404###########################################
405# Now we can substitute with the real value of TARGET_COPY_OUT_VENDOR
406ifeq ($(TARGET_COPY_OUT_VENDOR),$(_vendor_path_placeholder))
407  TARGET_COPY_OUT_VENDOR := system/vendor
408else ifeq ($(filter vendor system/vendor,$(TARGET_COPY_OUT_VENDOR)),)
409  $(error TARGET_COPY_OUT_VENDOR must be either 'vendor' or 'system/vendor', seeing '$(TARGET_COPY_OUT_VENDOR)'.)
410endif
411PRODUCT_COPY_FILES := $(subst $(_vendor_path_placeholder),$(TARGET_COPY_OUT_VENDOR),$(PRODUCT_COPY_FILES))
412
413BOARD_USES_VENDORIMAGE :=
414ifdef BOARD_PREBUILT_VENDORIMAGE
415  BOARD_USES_VENDORIMAGE := true
416endif
417ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
418  BOARD_USES_VENDORIMAGE := true
419endif
420# TODO(b/137169253): For now, some AOSP targets build with prebuilt vendor image.
421# But target's BOARD_PREBUILT_VENDORIMAGE is not filled.
422ifeq ($(TARGET_COPY_OUT_VENDOR),vendor)
423  BOARD_USES_VENDORIMAGE := true
424else ifdef BOARD_USES_VENDORIMAGE
425  $(error TARGET_COPY_OUT_VENDOR must be set to 'vendor' to use a vendor image)
426endif
427.KATI_READONLY := BOARD_USES_VENDORIMAGE
428
429BUILDING_VENDOR_IMAGE :=
430ifeq ($(PRODUCT_BUILD_VENDOR_IMAGE),)
431  ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
432    BUILDING_VENDOR_IMAGE := true
433  endif
434else ifeq ($(PRODUCT_BUILD_VENDOR_IMAGE),true)
435  BUILDING_VENDOR_IMAGE := true
436  ifndef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
437    $(error PRODUCT_BUILD_VENDOR_IMAGE set to true, but BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE not defined)
438  endif
439endif
440ifdef BOARD_PREBUILT_VENDORIMAGE
441  BUILDING_VENDOR_IMAGE :=
442endif
443.KATI_READONLY := BUILDING_VENDOR_IMAGE
444
445###########################################
446# Now we can substitute with the real value of TARGET_COPY_OUT_PRODUCT
447ifeq ($(TARGET_COPY_OUT_PRODUCT),$(_product_path_placeholder))
448TARGET_COPY_OUT_PRODUCT := system/product
449else ifeq ($(filter product system/product,$(TARGET_COPY_OUT_PRODUCT)),)
450$(error TARGET_COPY_OUT_PRODUCT must be either 'product' or 'system/product', seeing '$(TARGET_COPY_OUT_PRODUCT)'.)
451endif
452PRODUCT_COPY_FILES := $(subst $(_product_path_placeholder),$(TARGET_COPY_OUT_PRODUCT),$(PRODUCT_COPY_FILES))
453
454BOARD_USES_PRODUCTIMAGE :=
455ifdef BOARD_PREBUILT_PRODUCTIMAGE
456  BOARD_USES_PRODUCTIMAGE := true
457endif
458ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
459  BOARD_USES_PRODUCTIMAGE := true
460endif
461$(call check_image_config,product)
462.KATI_READONLY := BOARD_USES_PRODUCTIMAGE
463
464BUILDING_PRODUCT_IMAGE :=
465ifeq ($(PRODUCT_BUILD_PRODUCT_IMAGE),)
466  ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
467    BUILDING_PRODUCT_IMAGE := true
468  endif
469else ifeq ($(PRODUCT_BUILD_PRODUCT_IMAGE),true)
470  BUILDING_PRODUCT_IMAGE := true
471  ifndef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
472    $(error PRODUCT_BUILD_PRODUCT_IMAGE set to true, but BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE not defined)
473  endif
474endif
475ifdef BOARD_PREBUILT_PRODUCTIMAGE
476  BUILDING_PRODUCT_IMAGE :=
477endif
478.KATI_READONLY := BUILDING_PRODUCT_IMAGE
479
480###########################################
481# TODO(b/135957588) TARGET_COPY_OUT_PRODUCT_SERVICES will be set to
482# TARGET_COPY_OUT_PRODUCT as a workaround.
483TARGET_COPY_OUT_PRODUCT_SERVICES := $(TARGET_COPY_OUT_PRODUCT)
484
485###########################################
486# Now we can substitute with the real value of TARGET_COPY_OUT_SYSTEM_EXT
487ifeq ($(TARGET_COPY_OUT_SYSTEM_EXT),$(_system_ext_path_placeholder))
488TARGET_COPY_OUT_SYSTEM_EXT := system/system_ext
489else ifeq ($(filter system_ext system/system_ext,$(TARGET_COPY_OUT_SYSTEM_EXT)),)
490$(error TARGET_COPY_OUT_SYSTEM_EXT must be either 'system_ext' or 'system/system_ext', seeing '$(TARGET_COPY_OUT_SYSTEM_EXT)'.)
491endif
492PRODUCT_COPY_FILES := $(subst $(_system_ext_path_placeholder),$(TARGET_COPY_OUT_SYSTEM_EXT),$(PRODUCT_COPY_FILES))
493
494BOARD_USES_SYSTEM_EXTIMAGE :=
495ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
496  BOARD_USES_SYSTEM_EXTIMAGE := true
497endif
498ifdef BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE
499  BOARD_USES_SYSTEM_EXTIMAGE := true
500endif
501$(call check_image_config,system_ext)
502.KATI_READONLY := BOARD_USES_SYSTEM_EXTIMAGE
503
504BUILDING_SYSTEM_EXT_IMAGE :=
505ifeq ($(PRODUCT_BUILD_SYSTEM_EXT_IMAGE),)
506  ifdef BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE
507    BUILDING_SYSTEM_EXT_IMAGE := true
508  endif
509else ifeq ($(PRODUCT_BUILD_SYSTEM_EXT_IMAGE),true)
510  BUILDING_SYSTEM_EXT_IMAGE := true
511  ifndef BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE
512    $(error PRODUCT_BUILD_SYSTEM_EXT_IMAGE set to true, but BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE not defined)
513  endif
514endif
515ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
516  BUILDING_SYSTEM_EXT_IMAGE :=
517endif
518.KATI_READONLY := BUILDING_SYSTEM_EXT_IMAGE
519
520###########################################
521# Now we can substitute with the real value of TARGET_COPY_OUT_VENDOR_DLKM
522ifeq ($(TARGET_COPY_OUT_VENDOR_DLKM),$(_vendor_dlkm_path_placeholder))
523  TARGET_COPY_OUT_VENDOR_DLKM := $(TARGET_COPY_OUT_VENDOR)/vendor_dlkm
524else ifeq ($(filter vendor_dlkm system/vendor/vendor_dlkm vendor/vendor_dlkm,$(TARGET_COPY_OUT_VENDOR_DLKM)),)
525  $(error TARGET_COPY_OUT_VENDOR_DLKM must be either 'vendor_dlkm', 'system/vendor/vendor_dlkm' or 'vendor/vendor_dlkm', seeing '$(TARGET_COPY_OUT_VENDOR_DLKM)'.)
526endif
527PRODUCT_COPY_FILES := $(subst $(_vendor_dlkm_path_placeholder),$(TARGET_COPY_OUT_VENDOR_DLKM),$(PRODUCT_COPY_FILES))
528
529BOARD_USES_VENDOR_DLKMIMAGE :=
530ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
531  BOARD_USES_VENDOR_DLKMIMAGE := true
532endif
533ifdef BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE
534  BOARD_USES_VENDOR_DLKMIMAGE := true
535endif
536$(call check_image_config,vendor_dlkm)
537
538BUILDING_VENDOR_DLKM_IMAGE :=
539ifeq ($(PRODUCT_BUILD_VENDOR_DLKM_IMAGE),)
540  ifdef BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE
541    BUILDING_VENDOR_DLKM_IMAGE := true
542  endif
543else ifeq ($(PRODUCT_BUILD_VENDOR_DLKM_IMAGE),true)
544  BUILDING_VENDOR_DLKM_IMAGE := true
545  ifndef BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE
546    $(error PRODUCT_BUILD_VENDOR_DLKM_IMAGE set to true, but BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE not defined)
547  endif
548endif
549ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
550  BUILDING_VENDOR_DLKM_IMAGE :=
551endif
552.KATI_READONLY := BUILDING_VENDOR_DLKM_IMAGE
553
554###########################################
555# Now we can substitute with the real value of TARGET_COPY_OUT_ODM
556ifeq ($(TARGET_COPY_OUT_ODM),$(_odm_path_placeholder))
557  TARGET_COPY_OUT_ODM := $(TARGET_COPY_OUT_VENDOR)/odm
558else ifeq ($(filter odm system/vendor/odm vendor/odm,$(TARGET_COPY_OUT_ODM)),)
559  $(error TARGET_COPY_OUT_ODM must be either 'odm', 'system/vendor/odm' or 'vendor/odm', seeing '$(TARGET_COPY_OUT_ODM)'.)
560endif
561PRODUCT_COPY_FILES := $(subst $(_odm_path_placeholder),$(TARGET_COPY_OUT_ODM),$(PRODUCT_COPY_FILES))
562
563BOARD_USES_ODMIMAGE :=
564ifdef BOARD_PREBUILT_ODMIMAGE
565  BOARD_USES_ODMIMAGE := true
566endif
567ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
568  BOARD_USES_ODMIMAGE := true
569endif
570$(call check_image_config,odm)
571
572BUILDING_ODM_IMAGE :=
573ifeq ($(PRODUCT_BUILD_ODM_IMAGE),)
574  ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
575    BUILDING_ODM_IMAGE := true
576  endif
577else ifeq ($(PRODUCT_BUILD_ODM_IMAGE),true)
578  BUILDING_ODM_IMAGE := true
579  ifndef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
580    $(error PRODUCT_BUILD_ODM_IMAGE set to true, but BOARD_ODMIMAGE_FILE_SYSTEM_TYPE not defined)
581  endif
582endif
583ifdef BOARD_PREBUILT_ODMIMAGE
584  BUILDING_ODM_IMAGE :=
585endif
586.KATI_READONLY := BUILDING_ODM_IMAGE
587
588
589###########################################
590# Now we can substitute with the real value of TARGET_COPY_OUT_ODM_DLKM
591ifeq ($(TARGET_COPY_OUT_ODM_DLKM),$(_odm_dlkm_path_placeholder))
592  TARGET_COPY_OUT_ODM_DLKM := $(TARGET_COPY_OUT_VENDOR)/odm_dlkm
593else ifeq ($(filter odm_dlkm system/vendor/odm_dlkm vendor/odm_dlkm,$(TARGET_COPY_OUT_ODM_DLKM)),)
594  $(error TARGET_COPY_OUT_ODM_DLKM must be either 'odm_dlkm', 'system/vendor/odm_dlkm' or 'vendor/odm_dlkm', seeing '$(TARGET_COPY_OUT_ODM_DLKM)'.)
595endif
596PRODUCT_COPY_FILES := $(subst $(_odm_dlkm_path_placeholder),$(TARGET_COPY_OUT_ODM_DLKM),$(PRODUCT_COPY_FILES))
597
598BOARD_USES_ODM_DLKMIMAGE :=
599ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
600  BOARD_USES_ODM_DLKMIMAGE := true
601endif
602ifdef BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE
603  BOARD_USES_ODM_DLKMIMAGE := true
604endif
605$(call check_image_config,odm_dlkm)
606
607BUILDING_ODM_DLKM_IMAGE :=
608ifeq ($(PRODUCT_BUILD_ODM_DLKM_IMAGE),)
609  ifdef BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE
610    BUILDING_ODM_DLKM_IMAGE := true
611  endif
612else ifeq ($(PRODUCT_BUILD_ODM_DLKM_IMAGE),true)
613  BUILDING_ODM_DLKM_IMAGE := true
614  ifndef BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE
615    $(error PRODUCT_BUILD_ODM_DLKM_IMAGE set to true, but BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE not defined)
616  endif
617endif
618ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
619  BUILDING_ODM_DLKM_IMAGE :=
620endif
621.KATI_READONLY := BUILDING_ODM_DLKM_IMAGE
622
623###########################################
624# Ensure consistency among TARGET_RECOVERY_UPDATER_LIBS, AB_OTA_UPDATER, and PRODUCT_OTA_FORCE_NON_AB_PACKAGE.
625TARGET_RECOVERY_UPDATER_LIBS ?=
626AB_OTA_UPDATER ?=
627.KATI_READONLY := TARGET_RECOVERY_UPDATER_LIBS AB_OTA_UPDATER
628
629# Ensure that if PRODUCT_OTA_FORCE_NON_AB_PACKAGE == true, then AB_OTA_UPDATER must be true
630ifeq ($(PRODUCT_OTA_FORCE_NON_AB_PACKAGE),true)
631  ifneq ($(AB_OTA_UPDATER),true)
632    $(error AB_OTA_UPDATER must be set to true when PRODUCT_OTA_FORCE_NON_AB_PACKAGE is true)
633  endif
634endif
635
636# In some configurations, A/B and non-A/B may coexist. Check TARGET_OTA_ALLOW_NON_AB
637# to see if non-A/B is supported.
638TARGET_OTA_ALLOW_NON_AB := false
639ifneq ($(AB_OTA_UPDATER),true)
640  TARGET_OTA_ALLOW_NON_AB := true
641else ifeq ($(PRODUCT_OTA_FORCE_NON_AB_PACKAGE),true)
642  TARGET_OTA_ALLOW_NON_AB := true
643endif
644.KATI_READONLY := TARGET_OTA_ALLOW_NON_AB
645
646ifneq ($(TARGET_OTA_ALLOW_NON_AB),true)
647  ifneq ($(strip $(TARGET_RECOVERY_UPDATER_LIBS)),)
648    $(error Do not use TARGET_RECOVERY_UPDATER_LIBS when using TARGET_OTA_ALLOW_NON_AB)
649  endif
650endif
651
652# Quick check for building generic OTA packages. Currently it only supports A/B OTAs.
653ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
654  ifneq ($(AB_OTA_UPDATER),true)
655    $(error PRODUCT_BUILD_GENERIC_OTA_PACKAGE with 'AB_OTA_UPDATER != true' is not supported)
656  endif
657endif
658
659ifdef BOARD_PREBUILT_DTBIMAGE_DIR
660  ifneq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true)
661    $(error BOARD_PREBUILT_DTBIMAGE_DIR with 'BOARD_INCLUDE_DTB_IN_BOOTIMG != true' is not supported)
662  endif
663endif
664
665# Check BOARD_VNDK_VERSION
666define check_vndk_version
667  $(eval vndk_path := prebuilts/vndk/v$(1)) \
668  $(if $(wildcard $(vndk_path)/*/Android.bp),,$(error VNDK version $(1) not found))
669endef
670
671ifdef BOARD_VNDK_VERSION
672  ifeq ($(BOARD_VNDK_VERSION),$(PLATFORM_VNDK_VERSION))
673    $(error BOARD_VNDK_VERSION is equal to PLATFORM_VNDK_VERSION; use BOARD_VNDK_VERSION := current))
674  endif
675  ifneq ($(BOARD_VNDK_VERSION),current)
676    $(call check_vndk_version,$(BOARD_VNDK_VERSION))
677  endif
678  TARGET_VENDOR_TEST_SUFFIX := /vendor
679else
680  TARGET_VENDOR_TEST_SUFFIX :=
681endif
682
683###########################################
684# APEXes are by default flattened, i.e. non-updatable.
685# It can be unflattened (and updatable) by inheriting from
686# updatable_apex.mk
687#
688# APEX flattening can also be forcibly enabled (resp. disabled) by
689# setting OVERRIDE_TARGET_FLATTEN_APEX to true (resp. false), e.g. by
690# setting the OVERRIDE_TARGET_FLATTEN_APEX environment variable.
691ifdef OVERRIDE_TARGET_FLATTEN_APEX
692  TARGET_FLATTEN_APEX := $(OVERRIDE_TARGET_FLATTEN_APEX)
693else
694  ifeq (,$(TARGET_FLATTEN_APEX))
695    TARGET_FLATTEN_APEX := true
696  endif
697endif
698
699ifeq (,$(TARGET_BUILD_UNBUNDLED))
700ifdef PRODUCT_EXTRA_VNDK_VERSIONS
701  $(foreach v,$(PRODUCT_EXTRA_VNDK_VERSIONS),$(call check_vndk_version,$(v)))
702endif
703endif
704
705# Ensure that BOARD_SYSTEMSDK_VERSIONS are all within PLATFORM_SYSTEMSDK_VERSIONS
706_unsupported_systemsdk_versions := $(filter-out $(PLATFORM_SYSTEMSDK_VERSIONS),$(BOARD_SYSTEMSDK_VERSIONS))
707ifneq (,$(_unsupported_systemsdk_versions))
708  $(error System SDK versions '$(_unsupported_systemsdk_versions)' in BOARD_SYSTEMSDK_VERSIONS are not supported.\
709          Supported versions are $(PLATFORM_SYSTEMSDK_VERSIONS))
710endif
711
712###########################################
713# Handle BUILD_BROKEN_USES_BUILD_*
714
715$(foreach m,$(DEFAULT_WARNING_BUILD_MODULE_TYPES),\
716  $(if $(filter false,$(BUILD_BROKEN_USES_$(m))),\
717    $(KATI_obsolete_var $(m),Please convert to Soong),\
718    $(KATI_deprecated_var $(m),Please convert to Soong)))
719
720$(if $(filter true,$(BUILD_BROKEN_USES_BUILD_COPY_HEADERS)),\
721  $(KATI_deprecated_var BUILD_COPY_HEADERS,See $(CHANGES_URL)#copy_headers),\
722  $(KATI_obsolete_var BUILD_COPY_HEADERS,See $(CHANGES_URL)#copy_headers))
723
724$(foreach m,$(filter-out BUILD_COPY_HEADERS,$(DEFAULT_ERROR_BUILD_MODULE_TYPES)),\
725  $(if $(filter true,$(BUILD_BROKEN_USES_$(m))),\
726    $(KATI_deprecated_var $(m),Please convert to Soong),\
727    $(KATI_obsolete_var $(m),Please convert to Soong)))
728