blob: 61abc36e10ad9ec5869087985f5f4e83c56dfe2f [file] [log] [blame]
Anton Hanssonbb76ce82019-02-26 12:34:03 +00001#
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 sanity-checks the variable defined therein.
20# ###############################################################
21
Anton Hanssond488d2d2019-02-26 15:49:25 +000022_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 \
Yifan Hong8d297372020-01-24 14:28:03 -080029 BOARD_USES_RECOVERY_AS_BOOT \
Anton Hanssond488d2d2019-02-26 15:49:25 +000030 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 \
Dan Willemsend32e6d12019-04-10 12:25:07 -070048 TARGET_FS_CONFIG_GEN \
Anton Hanssond488d2d2019-02-26 15:49:25 +000049 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 \
Justin Yun6151e3f2019-06-25 15:58:13 +090071 BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE \
72 BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE \
Anton Hanssond488d2d2019-02-26 15:49:25 +000073 BOARD_ODMIMAGE_PARTITION_SIZE \
74 BOARD_ODMIMAGE_FILE_SYSTEM_TYPE \
75
76# Logical partitions related variables.
77_dynamic_partitions_var_list += \
78 BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE \
79 BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE \
80 BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE \
81 BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE \
Justin Yun6151e3f2019-06-25 15:58:13 +090082 BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE \
Anton Hanssond488d2d2019-02-26 15:49:25 +000083 BOARD_SUPER_PARTITION_SIZE \
84 BOARD_SUPER_PARTITION_GROUPS \
85
86_board_strip_readonly_list += $(_dynamic_partitions_var_list)
87
88_build_broken_var_list := \
Anton Hanssond488d2d2019-02-26 15:49:25 +000089 BUILD_BROKEN_DUP_RULES \
Yifan Hong5e57a772020-01-09 16:15:11 -080090 BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS \
Logan Chien2a880752019-09-17 09:45:09 -070091 BUILD_BROKEN_PREBUILT_ELF_FILES \
Inseob Kim5d60c8a2019-10-17 10:32:59 +000092 BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW \
Dan Willemsen0586c652019-04-09 09:56:48 -070093 BUILD_BROKEN_USES_NETWORK \
Yifan Hong5e57a772020-01-09 16:15:11 -080094 BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES \
Anton Hanssond488d2d2019-02-26 15:49:25 +000095
Dan Willemsen695849e2019-04-17 12:25:09 -070096_build_broken_var_list += \
97 $(foreach m,$(AVAILABLE_BUILD_MODULE_TYPES) \
98 $(DEFAULT_WARNING_BUILD_MODULE_TYPES) \
99 $(DEFAULT_ERROR_BUILD_MODULE_TYPES), \
100 BUILD_BROKEN_USES_$(m))
101
Anton Hanssond488d2d2019-02-26 15:49:25 +0000102_board_true_false_vars := $(_build_broken_var_list)
Dan Willemsen26076252020-01-02 20:08:10 -0800103_board_strip_readonly_list += $(_build_broken_var_list) \
104 BUILD_BROKEN_NINJA_USES_ENV_VARS
Anton Hanssond488d2d2019-02-26 15:49:25 +0000105
Anton Hansson74dc00b2019-02-27 14:38:27 +0000106# Conditional to building on linux, as dex2oat currently does not work on darwin.
107ifeq ($(HOST_OS),linux)
108 WITH_DEXPREOPT := true
109endif
110
Anton Hanssonb9544692019-02-26 13:37:28 +0000111# ###############################################################
112# Broken build defaults
113# ###############################################################
Dan Willemsen0586c652019-04-09 09:56:48 -0700114$(foreach v,$(_build_broken_var_list),$(eval $(v) :=))
Dan Willemsen26076252020-01-02 20:08:10 -0800115BUILD_BROKEN_NINJA_USES_ENV_VARS :=
Anton Hanssonb9544692019-02-26 13:37:28 +0000116
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000117# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
118# or under vendor/*/$(TARGET_DEVICE). Search in both places, but
119# make sure only one exists.
120# Real boards should always be associated with an OEM vendor.
121ifdef TARGET_DEVICE_DIR
122 ifneq ($(origin TARGET_DEVICE_DIR),command line)
123 $(error TARGET_DEVICE_DIR may not be set manually)
124 endif
125 board_config_mk := $(TARGET_DEVICE_DIR)/BoardConfig.mk
126else
127 board_config_mk := \
128 $(strip $(sort $(wildcard \
129 $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
130 $(shell test -d device && find -L device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
131 $(shell test -d vendor && find -L vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
132 )))
133 ifeq ($(board_config_mk),)
134 $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
135 endif
136 ifneq ($(words $(board_config_mk)),1)
137 $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
138 endif
139 TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
140 .KATI_READONLY := TARGET_DEVICE_DIR
141endif
142include $(board_config_mk)
143ifeq ($(TARGET_ARCH),)
144 $(error TARGET_ARCH not defined by board config: $(board_config_mk))
145endif
146ifneq ($(MALLOC_IMPL),)
147 $(warning *** Unsupported option MALLOC_IMPL defined by board config: $(board_config_mk).)
148 $(error Use `MALLOC_SVELTE := true` to configure jemalloc for low-memory)
149endif
150board_config_mk :=
151
Anton Hanssond488d2d2019-02-26 15:49:25 +0000152# Clean up and verify BoardConfig variables
153$(foreach var,$(_board_strip_readonly_list),$(eval $(var) := $$(strip $$($(var)))))
154$(foreach var,$(_board_true_false_vars), \
155 $(if $(filter-out true false,$($(var))), \
156 $(error Valid values of $(var) are "true", "false", and "". Not "$($(var))")))
Anton Hanssonb9544692019-02-26 13:37:28 +0000157
158# Default *_CPU_VARIANT_RUNTIME to CPU_VARIANT if unspecified.
159TARGET_CPU_VARIANT_RUNTIME := $(or $(TARGET_CPU_VARIANT_RUNTIME),$(TARGET_CPU_VARIANT))
160TARGET_2ND_CPU_VARIANT_RUNTIME := $(or $(TARGET_2ND_CPU_VARIANT_RUNTIME),$(TARGET_2ND_CPU_VARIANT))
161
Anton Hansson19279852019-02-28 17:15:57 +0000162# The combo makefiles sanity-check and set defaults for various CPU configuration
163combo_target := TARGET_
164combo_2nd_arch_prefix :=
165include $(BUILD_SYSTEM)/combo/select.mk
166
167ifdef TARGET_2ND_ARCH
168 combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
169 include $(BUILD_SYSTEM)/combo/select.mk
170endif
171
Anton Hanssond488d2d2019-02-26 15:49:25 +0000172.KATI_READONLY := $(_board_strip_readonly_list)
173
174INTERNAL_KERNEL_CMDLINE := $(BOARD_KERNEL_CMDLINE)
Anton Hanssonb9544692019-02-26 13:37:28 +0000175ifeq ($(TARGET_CPU_ABI),)
176 $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
177endif
178ifneq ($(filter %64,$(TARGET_ARCH)),)
179 TARGET_IS_64_BIT := true
180endif
181
182ifeq (,$(filter true,$(TARGET_SUPPORTS_32_BIT_APPS) $(TARGET_SUPPORTS_64_BIT_APPS)))
183 TARGET_SUPPORTS_32_BIT_APPS := true
184endif
185
186# Sanity check to warn about likely cryptic errors later in the build.
187ifeq ($(TARGET_IS_64_BIT),true)
188 ifeq (,$(filter true false,$(TARGET_SUPPORTS_64_BIT_APPS)))
Anton Hansson6d25fc62019-05-10 15:29:28 +0100189 $(error Building a 32-bit-app-only product on a 64-bit device. \
Anton Hanssonb9544692019-02-26 13:37:28 +0000190 If this is intentional, set TARGET_SUPPORTS_64_BIT_APPS := false)
191 endif
192endif
193
194# "ro.product.cpu.abilist32" and "ro.product.cpu.abilist64" are
195# comma separated lists of the 32 and 64 bit ABIs (in order of
196# preference) that the target supports. If TARGET_CPU_ABI_LIST_{32,64}_BIT
197# are defined by the board config, we use them. Else, we construct
198# these lists based on whether TARGET_IS_64_BIT is set.
199#
200# Note that this assumes that the 2ND_CPU_ABI for a 64 bit target
201# is always 32 bits. If this isn't the case, these variables should
202# be overriden in the board configuration.
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200203#
204# Similarly, TARGET_NATIVE_BRIDGE_2ND_ABI for a 64 bit target is always
205# 32 bits. Note that all CPU_ABIs are preferred over all NATIVE_BRIDGE_ABIs.
206_target_native_bridge_abi_list_32_bit :=
207_target_native_bridge_abi_list_64_bit :=
208
Anton Hanssonb9544692019-02-26 13:37:28 +0000209ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
210 ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
211 TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200212 _target_native_bridge_abi_list_64_bit := $(TARGET_NATIVE_BRIDGE_ABI)
Anton Hanssonb9544692019-02-26 13:37:28 +0000213 endif
214endif
215
Peter Collingbourne6aea25d2019-05-16 14:09:35 -0700216# "arm64-v8a-hwasan", the ABI for libraries compiled with HWASAN, is supported
217# in all builds with SANITIZE_TARGET=hwaddress.
218ifneq ($(filter hwaddress,$(SANITIZE_TARGET)),)
219 ifneq ($(filter arm64-v8a,$(TARGET_CPU_ABI_LIST_64_BIT)),)
220 TARGET_CPU_ABI_LIST_64_BIT := arm64-v8a-hwasan $(TARGET_CPU_ABI_LIST_64_BIT)
221 endif
222endif
223
Anton Hanssonb9544692019-02-26 13:37:28 +0000224ifeq (,$(TARGET_CPU_ABI_LIST_32_BIT))
225 ifneq (true,$(TARGET_IS_64_BIT))
226 TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200227 _target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_ABI)
Anton Hanssonb9544692019-02-26 13:37:28 +0000228 else
229 ifeq (true,$(TARGET_SUPPORTS_32_BIT_APPS))
230 # For a 64 bit target, assume that the 2ND_CPU_ABI
231 # is a 32 bit ABI.
232 TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200233 _target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_2ND_ABI)
Anton Hanssonb9544692019-02-26 13:37:28 +0000234 endif
235 endif
236endif
237
238# "ro.product.cpu.abilist" is a comma separated list of ABIs (in order
239# of preference) that the target supports. If a TARGET_CPU_ABI_LIST
240# is specified by the board configuration, we use that. If not, we
241# build a list out of the TARGET_CPU_ABIs specified by the config.
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200242# Add NATIVE_BRIDGE_ABIs at the end to keep order of preference.
Anton Hanssonb9544692019-02-26 13:37:28 +0000243ifeq (,$(TARGET_CPU_ABI_LIST))
244 ifeq ($(TARGET_IS_64_BIT)|$(TARGET_PREFER_32_BIT_APPS),true|true)
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200245 TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_32_BIT) $(TARGET_CPU_ABI_LIST_64_BIT) \
246 $(_target_native_bridge_abi_list_32_bit) $(_target_native_bridge_abi_list_64_bit)
Anton Hanssonb9544692019-02-26 13:37:28 +0000247 else
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200248 TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT) \
249 $(_target_native_bridge_abi_list_64_bit) $(_target_native_bridge_abi_list_32_bit)
Anton Hanssonb9544692019-02-26 13:37:28 +0000250 endif
251endif
252
Evgeny Eltsin28fbe7f2019-07-29 16:23:19 +0200253# Add NATIVE_BRIDGE_ABIs at the end of 32 and 64 bit CPU_ABIs to keep order of preference.
254TARGET_CPU_ABI_LIST_32_BIT += $(_target_native_bridge_abi_list_32_bit)
255TARGET_CPU_ABI_LIST_64_BIT += $(_target_native_bridge_abi_list_64_bit)
256
Anton Hanssonb9544692019-02-26 13:37:28 +0000257# Strip whitespace from the ABI list string.
258TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
259TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
260TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
261
Jeongik Chabb688a92019-07-12 12:51:37 +0900262# Check if config about image building is valid or not.
263define check_image_config
264 $(eval _uc_name := $(call to-upper,$(1))) \
265 $(eval _lc_name := $(call to-lower,$(1))) \
266 $(if $(filter $(_lc_name),$(TARGET_COPY_OUT_$(_uc_name))), \
267 $(if $(BOARD_USES_$(_uc_name)IMAGE),, \
268 $(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)), \
269 $(if $(BOARD_USES_$(_uc_name)IMAGE), \
270 $(error TARGET_COPY_OUT_$(_uc_name) must be set to '$(_lc_name)' to use a $(_lc_name) image))) \
271 $(eval _uc_name :=) \
272 $(eval _lc_name :=)
273endef
274
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000275###########################################
276# Now we can substitute with the real value of TARGET_COPY_OUT_RAMDISK
277ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
278TARGET_COPY_OUT_RAMDISK := $(TARGET_COPY_OUT_ROOT)
279endif
280
281###########################################
Bowgo Tsai0013f552019-03-20 17:59:52 +0800282# Now we can substitute with the real value of TARGET_COPY_OUT_DEBUG_RAMDISK
283ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
284TARGET_COPY_OUT_DEBUG_RAMDISK := debug_ramdisk/first_stage_ramdisk
Bowgo Tsai6a683672020-02-14 19:00:15 +0800285TARGET_COPY_OUT_VENDOR_DEBUG_RAMDISK := vendor_debug_ramdisk/first_stage_ramdisk
Bowgo Tsai5c40c712019-10-08 10:22:19 +0800286TARGET_COPY_OUT_TEST_HARNESS_RAMDISK := test_harness_ramdisk/first_stage_ramdisk
Bowgo Tsai0013f552019-03-20 17:59:52 +0800287endif
288
289###########################################
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000290# Configure whether we're building the system image
291BUILDING_SYSTEM_IMAGE := true
292ifeq ($(PRODUCT_BUILD_SYSTEM_IMAGE),)
293 ifndef PRODUCT_USE_DYNAMIC_PARTITION_SIZE
294 ifndef BOARD_SYSTEMIMAGE_PARTITION_SIZE
295 BUILDING_SYSTEM_IMAGE :=
296 endif
297 endif
298else ifeq ($(PRODUCT_BUILD_SYSTEM_IMAGE),false)
299 BUILDING_SYSTEM_IMAGE :=
300endif
301.KATI_READONLY := BUILDING_SYSTEM_IMAGE
302
303# Are we building a system_other image
304BUILDING_SYSTEM_OTHER_IMAGE :=
305ifeq ($(PRODUCT_BUILD_SYSTEM_OTHER_IMAGE),)
306 ifdef BUILDING_SYSTEM_IMAGE
307 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
308 BUILDING_SYSTEM_OTHER_IMAGE := true
309 endif
310 endif
311else ifeq ($(PRODUCT_BUILD_SYSTEM_OTHER_IMAGE),true)
312 BUILDING_SYSTEM_OTHER_IMAGE := true
313 ifndef BUILDING_SYSTEM_IMAGE
314 $(error PRODUCT_BUILD_SYSTEM_OTHER_IMAGE = true requires building the system image)
315 endif
316endif
317.KATI_READONLY := BUILDING_SYSTEM_OTHER_IMAGE
318
319# Are we building a cache image
320BUILDING_CACHE_IMAGE :=
321ifeq ($(PRODUCT_BUILD_CACHE_IMAGE),)
322 ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
323 BUILDING_CACHE_IMAGE := true
324 endif
325else ifeq ($(PRODUCT_BUILD_CACHE_IMAGE),true)
326 BUILDING_CACHE_IMAGE := true
327 ifndef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
328 $(error PRODUCT_BUILD_CACHE_IMAGE set to true, but BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE not defined)
329 endif
330endif
331.KATI_READONLY := BUILDING_CACHE_IMAGE
332
Chris Grossa784ef12019-04-22 11:09:57 -0700333# Are we building a boot image
334BUILDING_BOOT_IMAGE :=
335ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
336 BUILDING_BOOT_IMAGE :=
337else ifeq ($(PRODUCT_BUILD_BOOT_IMAGE),)
338 ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
339 BUILDING_BOOT_IMAGE := true
340 endif
341else ifeq ($(PRODUCT_BUILD_BOOT_IMAGE),true)
342 BUILDING_BOOT_IMAGE := true
343endif
344.KATI_READONLY := BUILDING_BOOT_IMAGE
345
346# Are we building a recovery image
347BUILDING_RECOVERY_IMAGE :=
348ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
349 BUILDING_RECOVERY_IMAGE := true
350else ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),)
351 ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
352 ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
353 BUILDING_RECOVERY_IMAGE := true
354 endif
355 endif
356else ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),true)
357 BUILDING_RECOVERY_IMAGE := true
358endif
359.KATI_READONLY := BUILDING_RECOVERY_IMAGE
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000360
Steve Mucklee1b10862019-07-10 10:49:37 -0700361# Are we building a vendor boot image
362BUILDING_VENDOR_BOOT_IMAGE :=
363ifdef BOARD_BOOT_HEADER_VERSION
364 ifneq ($(call math_gt_or_eq,$(BOARD_BOOT_HEADER_VERSION),3),)
365 BUILDING_VENDOR_BOOT_IMAGE := true
366 ifdef BUILDING_RECOVERY_IMAGE
367 ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
368 $(error Boot header version >=3 requires recovery as boot)
369 endif
370 endif
371 endif
372endif
373.KATI_READONLY := BUILDING_VENDOR_BOOT_IMAGE
374
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000375# 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
Paul Trautrim4e143232019-08-13 16:30:57 +0900397# 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
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000404###########################################
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
Jeongik Chabb688a92019-07-12 12:51:37 +0900420# TODO(b/137169253): For now, some AOSP targets build with prebuilt vendor image.
421# But target's BOARD_PREBUILT_VENDORIMAGE is not filled.
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000422ifeq ($(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
Jeongik Chabb688a92019-07-12 12:51:37 +0900461$(call check_image_config,product)
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000462.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###########################################
Justin Yun6151e3f2019-06-25 15:58:13 +0900481# 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)
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000484
Justin Yun6151e3f2019-06-25 15:58:13 +0900485###########################################
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)'.)
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000491endif
Justin Yun6151e3f2019-06-25 15:58:13 +0900492PRODUCT_COPY_FILES := $(subst $(_system_ext_path_placeholder),$(TARGET_COPY_OUT_SYSTEM_EXT),$(PRODUCT_COPY_FILES))
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000493
Justin Yun6151e3f2019-06-25 15:58:13 +0900494BOARD_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
Jeongik Chabb688a92019-07-12 12:51:37 +0900501$(call check_image_config,system_ext)
Justin Yun6151e3f2019-06-25 15:58:13 +0900502.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
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000508 endif
Justin Yun6151e3f2019-06-25 15:58:13 +0900509else 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)
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000513 endif
514endif
Justin Yun6151e3f2019-06-25 15:58:13 +0900515ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
516 BUILDING_SYSTEM_EXT_IMAGE :=
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000517endif
Justin Yun6151e3f2019-06-25 15:58:13 +0900518.KATI_READONLY := BUILDING_SYSTEM_EXT_IMAGE
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000519
520###########################################
521# Now we can substitute with the real value of TARGET_COPY_OUT_ODM
522ifeq ($(TARGET_COPY_OUT_ODM),$(_odm_path_placeholder))
dianlujitao339ef4c2019-10-10 09:26:00 +0800523 TARGET_COPY_OUT_ODM := $(TARGET_COPY_OUT_VENDOR)/odm
524else ifeq ($(filter odm system/vendor/odm vendor/odm,$(TARGET_COPY_OUT_ODM)),)
525 $(error TARGET_COPY_OUT_ODM must be either 'odm', 'system/vendor/odm' or 'vendor/odm', seeing '$(TARGET_COPY_OUT_ODM)'.)
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000526endif
527PRODUCT_COPY_FILES := $(subst $(_odm_path_placeholder),$(TARGET_COPY_OUT_ODM),$(PRODUCT_COPY_FILES))
528
529BOARD_USES_ODMIMAGE :=
530ifdef BOARD_PREBUILT_ODMIMAGE
531 BOARD_USES_ODMIMAGE := true
532endif
533ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
534 BOARD_USES_ODMIMAGE := true
535endif
Jeongik Chabb688a92019-07-12 12:51:37 +0900536$(call check_image_config,odm)
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000537
538BUILDING_ODM_IMAGE :=
Dan Willemsen25a69372019-04-19 15:00:12 -0700539ifeq ($(PRODUCT_BUILD_ODM_IMAGE),)
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000540 ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
541 BUILDING_ODM_IMAGE := true
542 endif
543else ifeq ($(PRODUCT_BUILD_ODM_IMAGE),true)
544 BUILDING_ODM_IMAGE := true
545 ifndef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
546 $(error PRODUCT_BUILD_ODM_IMAGE set to true, but BOARD_ODMIMAGE_FILE_SYSTEM_TYPE not defined)
547 endif
548endif
549ifdef BOARD_PREBUILT_ODMIMAGE
550 BUILDING_ODM_IMAGE :=
551endif
552.KATI_READONLY := BUILDING_ODM_IMAGE
553
554###########################################
555# Ensure that only TARGET_RECOVERY_UPDATER_LIBS *or* AB_OTA_UPDATER is set.
556TARGET_RECOVERY_UPDATER_LIBS ?=
557AB_OTA_UPDATER ?=
558.KATI_READONLY := TARGET_RECOVERY_UPDATER_LIBS AB_OTA_UPDATER
559ifeq ($(AB_OTA_UPDATER),true)
560 ifneq ($(strip $(TARGET_RECOVERY_UPDATER_LIBS)),)
561 $(error Do not use TARGET_RECOVERY_UPDATER_LIBS when using AB_OTA_UPDATER)
562 endif
563endif
564
Tao Bao9be20c72019-04-08 21:11:59 -0700565# Sanity check for building generic OTA packages. Currently it only supports A/B OTAs.
566ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
567 ifneq ($(AB_OTA_UPDATER),true)
568 $(error PRODUCT_BUILD_GENERIC_OTA_PACKAGE with 'AB_OTA_UPDATER != true' is not supported)
569 endif
570endif
571
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700572ifdef BOARD_PREBUILT_DTBIMAGE_DIR
573 ifneq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true)
574 $(error BOARD_PREBUILT_DTBIMAGE_DIR with 'BOARD_INCLUDE_DTB_IN_BOOTIMG != true' is not supported)
575 endif
576endif
577
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000578# Check BOARD_VNDK_VERSION
579define check_vndk_version
580 $(eval vndk_path := prebuilts/vndk/v$(1)) \
581 $(if $(wildcard $(vndk_path)/*/Android.bp),,$(error VNDK version $(1) not found))
582endef
583
584ifdef BOARD_VNDK_VERSION
585 ifneq ($(BOARD_VNDK_VERSION),current)
Inseob Kimf0cec692019-12-03 15:09:44 +0900586 $(call check_vndk_version,$(BOARD_VNDK_VERSION))
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000587 endif
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000588 TARGET_VENDOR_TEST_SUFFIX := /vendor
589else
590 TARGET_VENDOR_TEST_SUFFIX :=
591endif
592
Jiyong Park02426e62019-05-08 20:23:42 +0900593###########################################
594# APEXes are by default flattened, i.e. non-updatable.
595# It can be unflattened (and updatable) by inheriting from
596# updatable_apex.mk
Roland Levillainb3a503d2019-10-04 14:06:26 +0100597#
598# APEX flattening can also be forcibly enabled (resp. disabled) by
599# setting OVERRIDE_TARGET_FLATTEN_APEX to true (resp. false), e.g. by
600# setting the OVERRIDE_TARGET_FLATTEN_APEX environment variable.
601ifdef OVERRIDE_TARGET_FLATTEN_APEX
602 TARGET_FLATTEN_APEX := $(OVERRIDE_TARGET_FLATTEN_APEX)
603else
604 ifeq (,$(TARGET_FLATTEN_APEX))
605 TARGET_FLATTEN_APEX := true
606 endif
Jiyong Park02426e62019-05-08 20:23:42 +0900607endif
608
Anton Hanssonbb76ce82019-02-26 12:34:03 +0000609ifeq (,$(TARGET_BUILD_APPS))
610ifdef PRODUCT_EXTRA_VNDK_VERSIONS
611 $(foreach v,$(PRODUCT_EXTRA_VNDK_VERSIONS),$(call check_vndk_version,$(v)))
612endif
613endif
614
615# Ensure that BOARD_SYSTEMSDK_VERSIONS are all within PLATFORM_SYSTEMSDK_VERSIONS
616_unsupported_systemsdk_versions := $(filter-out $(PLATFORM_SYSTEMSDK_VERSIONS),$(BOARD_SYSTEMSDK_VERSIONS))
617ifneq (,$(_unsupported_systemsdk_versions))
618 $(error System SDK versions '$(_unsupported_systemsdk_versions)' in BOARD_SYSTEMSDK_VERSIONS are not supported.\
619 Supported versions are $(PLATFORM_SYSTEMSDK_VERSIONS))
620endif
Dan Willemsen695849e2019-04-17 12:25:09 -0700621
622###########################################
623# Handle BUILD_BROKEN_USES_BUILD_*
624
Dan Willemsen66d21d42020-01-27 19:26:02 -0800625$(foreach m,$(filter-out BUILD_COPY_HEADERS,$(DEFAULT_WARNING_BUILD_MODULE_TYPES)),\
Dan Willemsen695849e2019-04-17 12:25:09 -0700626 $(if $(filter false,$(BUILD_BROKEN_USES_$(m))),\
627 $(KATI_obsolete_var $(m),Please convert to Soong),\
628 $(KATI_deprecated_var $(m),Please convert to Soong)))
629
Dan Willemsen66d21d42020-01-27 19:26:02 -0800630$(if $(filter false,$(BUILD_BROKEN_USES_BUILD_COPY_HEADERS)),\
631 $(KATI_obsolete_var BUILD_COPY_HEADERS,See $(CHANGES_URL)#copy_headers),\
632 $(KATI_deprecated_var BUILD_COPY_HEADERS,See $(CHANGES_URL)#copy_headers))
633
Dan Willemsen695849e2019-04-17 12:25:09 -0700634$(foreach m,$(DEFAULT_ERROR_BUILD_MODULE_TYPES),\
635 $(if $(filter true,$(BUILD_BROKEN_USES_$(m))),\
636 $(KATI_deprecated_var $(m),Please convert to Soong),\
637 $(KATI_obsolete_var $(m),Please convert to Soong)))