From e81ec6960a64077cb46983499e80bdcc2dc316e2 Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Tue, 9 Nov 2021 23:09:52 +0900 Subject: [PATCH] Fix BOARD_SYSTEMSDK_VERSIONS checks BOARD_SYSTEMSDK_VERSIONS must be greater than or equal to the minimum of PRODUCT_SHIPPING_API_LEVEL and BOARD_API_LEVEL. If BOARD_API_LEVEL is not defined, read BOARD_SHIPPING_API_LEVEL. If both board api levels are not defined, compare only with PRODUCT_SHIPPING_API_LEVEL. Bug: 204964200 Bug: 201489975 Bug: 202919753 Test: manual test with different settings Change-Id: I36fa0b2fed3bca9ebe1baad46ee1dbe8cb1414e3 --- common/math.mk | 12 ++++++++++++ core/config.mk | 15 +++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/common/math.mk b/common/math.mk index ec15f88ee0..0271ea8b03 100644 --- a/common/math.mk +++ b/common/math.mk @@ -121,14 +121,26 @@ $(strip $(call _math_check_valid,$(1)) $(call _math_check_valid,$(2)) \ $(lastword $(filter $(1) $(2),$(__MATH_NUMBERS)))) endef +# Returns the lesser of $1 or $2. +define math_min +$(strip $(call _math_check_valid,$(1)) $(call _math_check_valid,$(2)) \ + $(firstword $(filter $(1) $(2),$(__MATH_NUMBERS)))) +endef + $(call math-expect-error,(call math_max),Argument missing) $(call math-expect-error,(call math_max,1),Argument missing) $(call math-expect-error,(call math_max,1 2,3),Multiple words in a single argument: 1 2) +$(call math-expect-error,(call math_min,1,2 3),Multiple words in a single argument: 2 3) $(call math-expect,(call math_max,0,1),1) $(call math-expect,(call math_max,1,0),1) $(call math-expect,(call math_max,1,1),1) $(call math-expect,(call math_max,5,42),42) $(call math-expect,(call math_max,42,5),42) +$(call math-expect,(call math_min,0,1),0) +$(call math-expect,(call math_min,1,0),0) +$(call math-expect,(call math_min,1,1),1) +$(call math-expect,(call math_min,7,32),7) +$(call math-expect,(call math_min,32,7),7) define math_gt_or_eq $(if $(filter $(1),$(call math_max,$(1),$(2))),true) diff --git a/core/config.mk b/core/config.mk index e24e957930..de0a06b608 100644 --- a/core/config.mk +++ b/core/config.mk @@ -753,13 +753,16 @@ else endif .KATI_READONLY := BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES -min_systemsdk_version := $(firstword $(BOARD_API_LEVEL) $(BOARD_SHIPPING_API_LEVEL) $(PRODUCT_SHIPPING_API_LEVEL)) -ifneq (,$(min_systemsdk_version)) -ifneq ($(call numbers_less_than,$(min_systemsdk_version),$(BOARD_SYSTEMSDK_VERSIONS)),) - $(error BOARD_SYSTEMSDK_VERSIONS ($(BOARD_SYSTEMSDK_VERSIONS)) must all be greater than or equal to BOARD_API_LEVEL, BOARD_SHIPPING_API_LEVEL or PRODUCT_SHIPPING_API_LEVEL ($(min_systemsdk_version))) -endif -endif ifdef PRODUCT_SHIPPING_API_LEVEL + board_api_level := $(firstword $(BOARD_API_LEVEL) $(BOARD_SHIPPING_API_LEVEL)) + ifneq (,$(board_api_level)) + min_systemsdk_version := $(call math_min,$(board_api_level),$(PRODUCT_SHIPPING_API_LEVEL)) + else + min_systemsdk_version := $(PRODUCT_SHIPPING_API_LEVEL) + endif + ifneq ($(call numbers_less_than,$(min_systemsdk_version),$(BOARD_SYSTEMSDK_VERSIONS)),) + $(error BOARD_SYSTEMSDK_VERSIONS ($(BOARD_SYSTEMSDK_VERSIONS)) must all be greater than or equal to BOARD_API_LEVEL, BOARD_SHIPPING_API_LEVEL or PRODUCT_SHIPPING_API_LEVEL ($(min_systemsdk_version))) + endif ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),28),) ifneq ($(TARGET_IS_64_BIT), true) ifneq ($(TARGET_USES_64_BIT_BINDER), true)