blob: 460073daf77cd7c0bd1658bc31926e141ca7cfff [file] [log] [blame]
Jiyong Park641b6cc2018-01-15 14:48:40 +09001#
2# Copyright (C) 2018 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
17ifdef BOARD_SYSTEMSDK_VERSIONS
Jeongik Cha62b98922020-04-25 04:31:39 +090018 # Apps and jars in vendor, product or odm partition are forced to build against System SDK.
Jeongik Cha74529792019-07-19 13:40:18 +090019 _cannot_use_platform_apis :=
Jiyong Park641b6cc2018-01-15 14:48:40 +090020 ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_PROPRIETARY_MODULE)))
21 # Note: no need to check LOCAL_MODULE_PATH* since LOCAL_[VENDOR|ODM|OEM]_MODULE is already
22 # set correctly before this is included.
Jeongik Cha74529792019-07-19 13:40:18 +090023 _cannot_use_platform_apis := true
24 else ifeq ($(LOCAL_PRODUCT_MODULE),true)
25 ifeq ($(PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE),true)
26 _cannot_use_platform_apis := true
27 endif
Jiyong Park641b6cc2018-01-15 14:48:40 +090028 endif
29 ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
30 ifndef LOCAL_SDK_VERSION
Jeongik Cha74529792019-07-19 13:40:18 +090031 ifeq ($(_cannot_use_platform_apis),true)
Jeongik Cha62b98922020-04-25 04:31:39 +090032 ifeq (,$(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY))
Anton Hansson038177b2019-01-29 15:01:06 +000033 # Runtime resource overlays are exempted from building against System SDK.
Jeongik Cha62b98922020-04-25 04:31:39 +090034 # TODO(b/155027019): remove this, after no product/vendor apps rely on this behavior.
Jiyong Parkc0ece102018-03-26 17:16:33 +090035 LOCAL_SDK_VERSION := system_current
36 endif
Jiyong Park641b6cc2018-01-15 14:48:40 +090037 endif
38 endif
39 endif
40endif
41
42# Ensure that the selected System SDK version is one of the supported versions.
43# The range of support versions becomes narrower when BOARD_SYSTEMSDK_VERSIONS
44# is set, which is a subset of PLATFORM_SYSTEMSDK_VERSIONS.
45ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
Jeongik Cha74529792019-07-19 13:40:18 +090046 ifneq ($(_cannot_use_platform_apis),true)
Jiyong Park641b6cc2018-01-15 14:48:40 +090047 # apps bundled in system partition can use all system sdk versions provided by the platform
48 _supported_systemsdk_versions := $(PLATFORM_SYSTEMSDK_VERSIONS)
49 else ifdef BOARD_SYSTEMSDK_VERSIONS
50 # When BOARD_SYSTEMSDK_VERSIONS is set, vendors apps are restricted to use those versions
51 # which is equal to or smaller than PLATFORM_SYSTEMSDK_VERSIONS
52 _supported_systemsdk_versions := $(BOARD_SYSTEMSDK_VERSIONS)
53 else
54 # If not, vendor apks are treated equally to system apps
55 _supported_systemsdk_versions := $(PLATFORM_SYSTEMSDK_VERSIONS)
56 endif
57 _system_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
58 ifneq ($(_system_sdk_version),$(filter $(_system_sdk_version),$(_supported_systemsdk_versions)))
59 $(call pretty-error,Incompatible LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)'. \
60 System SDK version '$(_system_sdk_version)' is not supported. Supported versions are: $(_supported_systemsdk_versions))
61 endif
62 _system_sdk_version :=
63 _supported_systemsdk_versions :=
64endif