blob: cae87aa9421b520ecd68676bb5c52c163ead63c6 [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
26# PLATFORM_VERSION_CODENAME
27# DEFAULT_APP_TARGET_SDK
28# BUILD_ID
29# BUILD_NUMBER
30# PLATFORM_SECURITY_PATCH
31# PLATFORM_VNDK_VERSION
32# PLATFORM_SYSTEMSDK_VERSIONS
33# PLATFORM_VERSION_LAST_STABLE
Alex Buynytskyy569b9e02024-01-22 21:23:54 +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
71# This is the sdk extension version that PLATFORM_SDK_VERSION ships with.
72PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION)
73.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION
74
75ifdef PLATFORM_VERSION_CODENAME
76 $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME))
77endif
78PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME)
79.KATI_READONLY := PLATFORM_VERSION_CODENAME
80
81ifdef PLATFORM_VERSION_ALL_CODENAMES
82 $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES))
83endif
84PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES)
85.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES
86
87ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES
88 $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES))
89endif
90PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)
91.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES
92
93ifdef PLATFORM_VERSION_LAST_STABLE
94 $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME))
95endif
96PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE)
97.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE
98
Alex Buynytskyy569b9e02024-01-22 21:23:54 +000099ifdef PLATFORM_VERSION_KNOWN_CODENAMES
100 $(error Do not set PLATFORM_VERSION_KNOWN_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES. value: $(PLATFORM_VERSION_KNOWN_CODENAMES))
101endif
102PLATFORM_VERSION_KNOWN_CODENAMES := $(RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES)
Jeff Hamilton426a9f82023-10-19 04:54:15 +0000103.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES
satayev2d945862022-02-09 21:59:28 +0000104
Sasha Smundak13359032021-09-12 17:09:01 -0700105ifndef PLATFORM_VERSION
106 ifeq (REL,$(PLATFORM_VERSION_CODENAME))
107 PLATFORM_VERSION := $(PLATFORM_VERSION_LAST_STABLE)
108 else
109 PLATFORM_VERSION := $(PLATFORM_VERSION_CODENAME)
110 endif
111endif
112.KATI_READONLY := PLATFORM_VERSION
113
Colin Crossa4925442022-02-28 18:01:35 -0800114ifndef PLATFORM_DISPLAY_VERSION
115 PLATFORM_DISPLAY_VERSION := $(PLATFORM_VERSION)
116endif
117.KATI_READONLY := PLATFORM_DISPLAY_VERSION
Sasha Smundak13359032021-09-12 17:09:01 -0700118
119ifeq (REL,$(PLATFORM_VERSION_CODENAME))
120 PLATFORM_PREVIEW_SDK_VERSION := 0
121else
122 ifndef PLATFORM_PREVIEW_SDK_VERSION
123 # This is the definition of a preview SDK version over and above the current
124 # platform SDK version. Unlike the platform SDK version, a higher value
125 # for preview SDK version does NOT mean that all prior preview APIs are
126 # included. Packages reading this value to determine compatibility with
127 # known APIs should check that this value is precisely equal to the preview
128 # SDK version the package was built for, otherwise it should fall back to
129 # assuming the device can only support APIs as of the previous official
130 # public release.
131 # This value will always be forced to 0 for release builds by the logic
132 # in the "ifeq" block above, so the value below will be used on any
133 # non-release builds, and it should always be at least 1, to indicate that
134 # APIs may have changed since the claimed PLATFORM_SDK_VERSION.
135 PLATFORM_PREVIEW_SDK_VERSION := 1
136 endif
137endif
138.KATI_READONLY := PLATFORM_PREVIEW_SDK_VERSION
139
140ifndef DEFAULT_APP_TARGET_SDK
141 # This is the default minSdkVersion and targetSdkVersion to use for
142 # all .apks created by the build system. It can be overridden by explicitly
143 # setting these in the .apk's AndroidManifest.xml. It is either the code
144 # name of the development build or, if this is a release build, the official
145 # SDK version of this release.
146 ifeq (REL,$(PLATFORM_VERSION_CODENAME))
147 DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION)
148 else
149 DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)
150 endif
151endif
152.KATI_READONLY := DEFAULT_APP_TARGET_SDK
153
154ifndef PLATFORM_VNDK_VERSION
155 # This is the definition of the VNDK version for the current VNDK libraries.
Justin Yune9525902023-09-12 16:13:37 +0900156 # With trunk stable, VNDK will not be frozen but deprecated.
157 # This version will be removed with the VNDK deprecation.
Sasha Smundak13359032021-09-12 17:09:01 -0700158 ifeq (REL,$(PLATFORM_VERSION_CODENAME))
Justin Yune9525902023-09-12 16:13:37 +0900159 ifdef RELEASE_PLATFORM_VNDK_VERSION
160 PLATFORM_VNDK_VERSION := $(RELEASE_PLATFORM_VNDK_VERSION)
161 else
162 PLATFORM_VNDK_VERSION := $(PLATFORM_SDK_VERSION)
163 endif
Sasha Smundak13359032021-09-12 17:09:01 -0700164 else
165 PLATFORM_VNDK_VERSION := $(PLATFORM_VERSION_CODENAME)
166 endif
167endif
168.KATI_READONLY := PLATFORM_VNDK_VERSION
169
170ifndef PLATFORM_SYSTEMSDK_MIN_VERSION
171 # This is the oldest version of system SDK that the platform supports. Contrary
172 # to the public SDK where platform essentially supports all previous SDK versions,
173 # platform supports only a few number of recent system SDK versions as some of
174 # old system APIs are gradually deprecated, removed and then deleted.
Nick Kovacs2092c972022-08-08 18:44:42 +0000175 PLATFORM_SYSTEMSDK_MIN_VERSION := 29
Sasha Smundak13359032021-09-12 17:09:01 -0700176endif
177.KATI_READONLY := PLATFORM_SYSTEMSDK_MIN_VERSION
178
179# This is the list of system SDK versions that the current platform supports.
180PLATFORM_SYSTEMSDK_VERSIONS :=
181ifneq (,$(PLATFORM_SYSTEMSDK_MIN_VERSION))
182 $(if $(call math_is_number,$(PLATFORM_SYSTEMSDK_MIN_VERSION)),,\
183 $(error PLATFORM_SYSTEMSDK_MIN_VERSION must be a number, but was $(PLATFORM_SYSTEMSDK_MIN_VERSION)))
184 PLATFORM_SYSTEMSDK_VERSIONS := $(call int_range_list,$(PLATFORM_SYSTEMSDK_MIN_VERSION),$(PLATFORM_SDK_VERSION))
185endif
186# Platform always supports the current version
187ifeq (REL,$(PLATFORM_VERSION_CODENAME))
188 PLATFORM_SYSTEMSDK_VERSIONS += $(PLATFORM_SDK_VERSION)
189else
190 PLATFORM_SYSTEMSDK_VERSIONS += $(subst $(comma),$(space),$(PLATFORM_VERSION_ALL_CODENAMES))
191endif
192PLATFORM_SYSTEMSDK_VERSIONS := $(strip $(sort $(PLATFORM_SYSTEMSDK_VERSIONS)))
193.KATI_READONLY := PLATFORM_SYSTEMSDK_VERSIONS
194
195.KATI_READONLY := PLATFORM_SECURITY_PATCH
196
197ifndef PLATFORM_SECURITY_PATCH_TIMESTAMP
198 # Used to indicate the matching timestamp for the security patch string in PLATFORM_SECURITY_PATCH.
199 PLATFORM_SECURITY_PATCH_TIMESTAMP := $(shell date -d 'TZ="GMT" $(PLATFORM_SECURITY_PATCH)' +%s)
200endif
201.KATI_READONLY := PLATFORM_SECURITY_PATCH_TIMESTAMP
202
203ifndef PLATFORM_BASE_OS
204 # Used to indicate the base os applied to the device.
205 # Can be an arbitrary string, but must be a single word.
206 #
207 # If there is no $PLATFORM_BASE_OS set, keep it empty.
208 PLATFORM_BASE_OS :=
209endif
210.KATI_READONLY := PLATFORM_BASE_OS
211
212ifndef BUILD_ID
213 # Used to signify special builds. E.g., branches and/or releases,
214 # like "M5-RC7". Can be an arbitrary string, but must be a single
215 # word and a valid file name.
216 #
217 # If there is no BUILD_ID set, make it obvious.
218 BUILD_ID := UNKNOWN
219endif
220.KATI_READONLY := BUILD_ID
221
222ifndef BUILD_DATETIME
223 # Used to reproduce builds by setting the same time. Must be the number
224 # of seconds since the Epoch.
225 BUILD_DATETIME := $(shell date +%s)
226endif
227
228DATE := date -d @$(BUILD_DATETIME)
229.KATI_READONLY := DATE
230
231# Everything should be using BUILD_DATETIME_FROM_FILE instead.
232# BUILD_DATETIME and DATE can be removed once BUILD_NUMBER moves
233# to soong_ui.
234$(KATI_obsolete_var BUILD_DATETIME,Use BUILD_DATETIME_FROM_FILE)
235
Jeongik Cha05210f92023-04-27 11:05:22 +0900236ifndef HAS_BUILD_NUMBER
Sasha Smundak13359032021-09-12 17:09:01 -0700237 HAS_BUILD_NUMBER := false
238endif
Jeongik Cha05210f92023-04-27 11:05:22 +0900239.KATI_READONLY := HAS_BUILD_NUMBER
Sasha Smundak13359032021-09-12 17:09:01 -0700240
241ifndef PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION
242 # Used to set minimum supported target sdk version. Apps targeting sdk
243 # version lower than the set value will result in a warning being shown
244 # when any activity from the app is started.
Nick Kovacs67ebe092022-08-05 19:32:08 +0000245 PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION := 28
Sasha Smundak13359032021-09-12 17:09:01 -0700246endif
247.KATI_READONLY := PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION