blob: 2bf41eccebffe5ab9d1d853ab8d1c72982f2d060 [file] [log] [blame]
Sasha Smundak13359032021-09-12 17:09:01 -07001#
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
Jeff Hamilton426a9f82023-10-19 04:54:15 +000017
18#
19# Handle various build version information.
20#
21# Guarantees that the following are defined:
22# PLATFORM_VERSION
23# PLATFORM_DISPLAY_VERSION
24# PLATFORM_SDK_VERSION
25# PLATFORM_SDK_EXTENSION_VERSION
Linus Tufvesson509eed22024-11-21 17:47:29 +010026# PLATFORM_BASE_SDK_EXTENSION_VERSION
Jeff Hamilton426a9f82023-10-19 04:54:15 +000027# PLATFORM_VERSION_CODENAME
28# DEFAULT_APP_TARGET_SDK
29# BUILD_ID
30# BUILD_NUMBER
31# PLATFORM_SECURITY_PATCH
Jeff Hamilton426a9f82023-10-19 04:54:15 +000032# PLATFORM_SYSTEMSDK_VERSIONS
33# PLATFORM_VERSION_LAST_STABLE
Ian Kasprzak1b2eea52024-02-21 17:12:16 +000034# PLATFORM_VERSION_KNOWN_CODENAMES
Jeff Hamilton426a9f82023-10-19 04:54:15 +000035#
36
37# Look for an optional file containing overrides of the defaults,
38# but don't cry if we don't find it. We could just use -include, but
39# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set
40# if the file exists.
41#
42INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk)
43ifdef INTERNAL_BUILD_ID_MAKEFILE
44 include $(INTERNAL_BUILD_ID_MAKEFILE)
45endif
Sasha Smundak13359032021-09-12 17:09:01 -070046
Joe Onorato6d7afa02023-06-05 16:43:55 -070047ifdef TARGET_PLATFORM_VERSION
48 $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION))
Sasha Smundak13359032021-09-12 17:09:01 -070049endif
Joe Onorato6d7afa02023-06-05 16:43:55 -070050TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION)
Sasha Smundak13359032021-09-12 17:09:01 -070051.KATI_READONLY := TARGET_PLATFORM_VERSION
52
Jeff Hamilton426a9f82023-10-19 04:54:15 +000053ifdef PLATFORM_SECURITY_PATCH
54 $(error Do not set PLATFORM_SECURITY_PATCH directly. Use RELEASE_PLATFORM_SECURITY_PATCH. value: $(PLATFORM_SECURITY_PATCH))
Joe Onorato89f17ef2023-07-14 14:16:11 -070055endif
Jeff Hamilton426a9f82023-10-19 04:54:15 +000056PLATFORM_SECURITY_PATCH := $(RELEASE_PLATFORM_SECURITY_PATCH)
57.KATI_READONLY := PLATFORM_SECURITY_PATCH
Joe Onorato89f17ef2023-07-14 14:16:11 -070058
Jeff Hamilton426a9f82023-10-19 04:54:15 +000059ifdef PLATFORM_SDK_VERSION
60 $(error Do not set PLATFORM_SDK_VERSION directly. Use RELEASE_PLATFORM_SDK_VERSION. value: $(PLATFORM_SDK_VERSION))
Sasha Smundak13359032021-09-12 17:09:01 -070061endif
Jeff Hamilton426a9f82023-10-19 04:54:15 +000062PLATFORM_SDK_VERSION := $(RELEASE_PLATFORM_SDK_VERSION)
63.KATI_READONLY := PLATFORM_SDK_VERSION
Sebastian Ene573fbcd2022-04-27 09:32:39 +000064
Jeff Hamilton426a9f82023-10-19 04:54:15 +000065ifdef PLATFORM_SDK_EXTENSION_VERSION
66 $(error Do not set PLATFORM_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_SDK_EXTENSION_VERSION. value: $(PLATFORM_SDK_EXTENSION_VERSION))
satayev2d945862022-02-09 21:59:28 +000067endif
Jeff Hamilton426a9f82023-10-19 04:54:15 +000068PLATFORM_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_SDK_EXTENSION_VERSION)
69.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION
70
Linus Tufvesson509eed22024-11-21 17:47:29 +010071ifdef PLATFORM_BASE_SDK_EXTENSION_VERSION
72 $(error Do not set PLATFORM_BASE_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION. value: $(PLATFORM_BASE_SDK_EXTENSION_VERSION))
73endif
74ifdef RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION
75 # This is the sdk extension version that PLATFORM_SDK_VERSION ships with.
76 PLATFORM_BASE_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION)
77else
78 # Fallback to PLATFORM_SDK_EXTENSION_VERSION if RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION is undefined.
79 PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION)
80endif
Jeff Hamilton426a9f82023-10-19 04:54:15 +000081.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION
82
83ifdef PLATFORM_VERSION_CODENAME
84 $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME))
85endif
86PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME)
87.KATI_READONLY := PLATFORM_VERSION_CODENAME
88
89ifdef PLATFORM_VERSION_ALL_CODENAMES
90 $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES))
91endif
92PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES)
93.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES
94
95ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES
96 $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES))
97endif
98PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)
99.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES
100
101ifdef PLATFORM_VERSION_LAST_STABLE
102 $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME))
103endif
104PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE)
105.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE
106
Ian Kasprzak1b2eea52024-02-21 17:12:16 +0000107ifdef PLATFORM_VERSION_KNOWN_CODENAMES
108 $(error Do not set PLATFORM_VERSION_KNOWN_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES. value: $(PLATFORM_VERSION_KNOWN_CODENAMES))
109endif
110PLATFORM_VERSION_KNOWN_CODENAMES := $(RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES)
Jeff Hamilton426a9f82023-10-19 04:54:15 +0000111.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES
satayev2d945862022-02-09 21:59:28 +0000112
Sasha Smundak13359032021-09-12 17:09:01 -0700113ifndef PLATFORM_VERSION
114 ifeq (REL,$(PLATFORM_VERSION_CODENAME))
115 PLATFORM_VERSION := $(PLATFORM_VERSION_LAST_STABLE)
116 else
117 PLATFORM_VERSION := $(PLATFORM_VERSION_CODENAME)
118 endif
119endif
120.KATI_READONLY := PLATFORM_VERSION
121
Colin Crossa4925442022-02-28 18:01:35 -0800122ifndef PLATFORM_DISPLAY_VERSION
123 PLATFORM_DISPLAY_VERSION := $(PLATFORM_VERSION)
124endif
125.KATI_READONLY := PLATFORM_DISPLAY_VERSION
Sasha Smundak13359032021-09-12 17:09:01 -0700126
127ifeq (REL,$(PLATFORM_VERSION_CODENAME))
128 PLATFORM_PREVIEW_SDK_VERSION := 0
129else
130 ifndef PLATFORM_PREVIEW_SDK_VERSION
131 # This is the definition of a preview SDK version over and above the current
132 # platform SDK version. Unlike the platform SDK version, a higher value
133 # for preview SDK version does NOT mean that all prior preview APIs are
134 # included. Packages reading this value to determine compatibility with
135 # known APIs should check that this value is precisely equal to the preview
136 # SDK version the package was built for, otherwise it should fall back to
137 # assuming the device can only support APIs as of the previous official
138 # public release.
139 # This value will always be forced to 0 for release builds by the logic
140 # in the "ifeq" block above, so the value below will be used on any
141 # non-release builds, and it should always be at least 1, to indicate that
142 # APIs may have changed since the claimed PLATFORM_SDK_VERSION.
143 PLATFORM_PREVIEW_SDK_VERSION := 1
144 endif
145endif
146.KATI_READONLY := PLATFORM_PREVIEW_SDK_VERSION
147
148ifndef DEFAULT_APP_TARGET_SDK
149 # This is the default minSdkVersion and targetSdkVersion to use for
150 # all .apks created by the build system. It can be overridden by explicitly
151 # setting these in the .apk's AndroidManifest.xml. It is either the code
152 # name of the development build or, if this is a release build, the official
153 # SDK version of this release.
154 ifeq (REL,$(PLATFORM_VERSION_CODENAME))
155 DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION)
156 else
157 DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)
158 endif
159endif
160.KATI_READONLY := DEFAULT_APP_TARGET_SDK
161
Sasha Smundak13359032021-09-12 17:09:01 -0700162ifndef PLATFORM_SYSTEMSDK_MIN_VERSION
163 # This is the oldest version of system SDK that the platform supports. Contrary
164 # to the public SDK where platform essentially supports all previous SDK versions,
165 # platform supports only a few number of recent system SDK versions as some of
166 # old system APIs are gradually deprecated, removed and then deleted.
Nick Kovacs2092c972022-08-08 18:44:42 +0000167 PLATFORM_SYSTEMSDK_MIN_VERSION := 29
Sasha Smundak13359032021-09-12 17:09:01 -0700168endif
169.KATI_READONLY := PLATFORM_SYSTEMSDK_MIN_VERSION
170
171# This is the list of system SDK versions that the current platform supports.
172PLATFORM_SYSTEMSDK_VERSIONS :=
173ifneq (,$(PLATFORM_SYSTEMSDK_MIN_VERSION))
174 $(if $(call math_is_number,$(PLATFORM_SYSTEMSDK_MIN_VERSION)),,\
175 $(error PLATFORM_SYSTEMSDK_MIN_VERSION must be a number, but was $(PLATFORM_SYSTEMSDK_MIN_VERSION)))
176 PLATFORM_SYSTEMSDK_VERSIONS := $(call int_range_list,$(PLATFORM_SYSTEMSDK_MIN_VERSION),$(PLATFORM_SDK_VERSION))
177endif
178# Platform always supports the current version
179ifeq (REL,$(PLATFORM_VERSION_CODENAME))
180 PLATFORM_SYSTEMSDK_VERSIONS += $(PLATFORM_SDK_VERSION)
181else
182 PLATFORM_SYSTEMSDK_VERSIONS += $(subst $(comma),$(space),$(PLATFORM_VERSION_ALL_CODENAMES))
183endif
184PLATFORM_SYSTEMSDK_VERSIONS := $(strip $(sort $(PLATFORM_SYSTEMSDK_VERSIONS)))
185.KATI_READONLY := PLATFORM_SYSTEMSDK_VERSIONS
186
187.KATI_READONLY := PLATFORM_SECURITY_PATCH
188
189ifndef PLATFORM_SECURITY_PATCH_TIMESTAMP
190 # Used to indicate the matching timestamp for the security patch string in PLATFORM_SECURITY_PATCH.
191 PLATFORM_SECURITY_PATCH_TIMESTAMP := $(shell date -d 'TZ="GMT" $(PLATFORM_SECURITY_PATCH)' +%s)
192endif
193.KATI_READONLY := PLATFORM_SECURITY_PATCH_TIMESTAMP
194
Lokesh Kumar Goelc4baa3a2024-02-09 01:05:51 +0000195# PLATFORM_BASE_OS is used to indicate the base os applied
196# to the device. Can be an arbitrary string, but must be a
197# single word.
198#
199# If there is no $PLATFORM_BASE_OS set, keep it empty.
200#
201# PLATFORM_BASE_OS can either be set via an enviornment
202# variable, or set via the PRODUCT_BASE_OS product variable.
203PLATFORM_BASE_OS_ENV_INPUT := $(PLATFORM_BASE_OS)
204.KATI_READONLY := PLATFORM_BASE_OS_ENV_INPUT
205PLATFORM_BASE_OS :=
Sasha Smundak13359032021-09-12 17:09:01 -0700206
207ifndef BUILD_ID
208 # Used to signify special builds. E.g., branches and/or releases,
209 # like "M5-RC7". Can be an arbitrary string, but must be a single
210 # word and a valid file name.
211 #
212 # If there is no BUILD_ID set, make it obvious.
213 BUILD_ID := UNKNOWN
214endif
215.KATI_READONLY := BUILD_ID
216
217ifndef BUILD_DATETIME
218 # Used to reproduce builds by setting the same time. Must be the number
219 # of seconds since the Epoch.
220 BUILD_DATETIME := $(shell date +%s)
221endif
222
223DATE := date -d @$(BUILD_DATETIME)
224.KATI_READONLY := DATE
225
226# Everything should be using BUILD_DATETIME_FROM_FILE instead.
227# BUILD_DATETIME and DATE can be removed once BUILD_NUMBER moves
228# to soong_ui.
229$(KATI_obsolete_var BUILD_DATETIME,Use BUILD_DATETIME_FROM_FILE)
230
Jeongik Cha05210f92023-04-27 11:05:22 +0900231ifndef HAS_BUILD_NUMBER
Sasha Smundak13359032021-09-12 17:09:01 -0700232 HAS_BUILD_NUMBER := false
233endif
Jeongik Cha05210f92023-04-27 11:05:22 +0900234.KATI_READONLY := HAS_BUILD_NUMBER
Sasha Smundak13359032021-09-12 17:09:01 -0700235
Linus Tufvesson984b0692024-04-12 12:18:06 +0200236ifdef PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION
237 $(error Do not set PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION directly. Use RELEASE_PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION. value: $(PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION))
Sasha Smundak13359032021-09-12 17:09:01 -0700238endif
Linus Tufvesson984b0692024-04-12 12:18:06 +0200239PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION := $(RELEASE_PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION)
Sasha Smundak13359032021-09-12 17:09:01 -0700240.KATI_READONLY := PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION