blob: eb568becc44fc84a4f5c202b23ca24fa36b25517 [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
Jeff Hamilton426a9f82023-10-19 04:54:15 +000031# PLATFORM_SYSTEMSDK_VERSIONS
32# PLATFORM_VERSION_LAST_STABLE
Ian Kasprzak1b2eea52024-02-21 17:12:16 +000033# PLATFORM_VERSION_KNOWN_CODENAMES
Jeff Hamilton426a9f82023-10-19 04:54:15 +000034#
35
36# Look for an optional file containing overrides of the defaults,
37# but don't cry if we don't find it. We could just use -include, but
38# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set
39# if the file exists.
40#
41INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk)
42ifdef INTERNAL_BUILD_ID_MAKEFILE
43 include $(INTERNAL_BUILD_ID_MAKEFILE)
44endif
Sasha Smundak13359032021-09-12 17:09:01 -070045
Joe Onorato6d7afa02023-06-05 16:43:55 -070046ifdef TARGET_PLATFORM_VERSION
47 $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION))
Sasha Smundak13359032021-09-12 17:09:01 -070048endif
Joe Onorato6d7afa02023-06-05 16:43:55 -070049TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION)
Sasha Smundak13359032021-09-12 17:09:01 -070050.KATI_READONLY := TARGET_PLATFORM_VERSION
51
Jeff Hamilton426a9f82023-10-19 04:54:15 +000052ifdef PLATFORM_SECURITY_PATCH
53 $(error Do not set PLATFORM_SECURITY_PATCH directly. Use RELEASE_PLATFORM_SECURITY_PATCH. value: $(PLATFORM_SECURITY_PATCH))
Joe Onorato89f17ef2023-07-14 14:16:11 -070054endif
Jeff Hamilton426a9f82023-10-19 04:54:15 +000055PLATFORM_SECURITY_PATCH := $(RELEASE_PLATFORM_SECURITY_PATCH)
56.KATI_READONLY := PLATFORM_SECURITY_PATCH
Joe Onorato89f17ef2023-07-14 14:16:11 -070057
Jeff Hamilton426a9f82023-10-19 04:54:15 +000058ifdef PLATFORM_SDK_VERSION
59 $(error Do not set PLATFORM_SDK_VERSION directly. Use RELEASE_PLATFORM_SDK_VERSION. value: $(PLATFORM_SDK_VERSION))
Sasha Smundak13359032021-09-12 17:09:01 -070060endif
Jeff Hamilton426a9f82023-10-19 04:54:15 +000061PLATFORM_SDK_VERSION := $(RELEASE_PLATFORM_SDK_VERSION)
62.KATI_READONLY := PLATFORM_SDK_VERSION
Sebastian Ene573fbcd2022-04-27 09:32:39 +000063
Jeff Hamilton426a9f82023-10-19 04:54:15 +000064ifdef PLATFORM_SDK_EXTENSION_VERSION
65 $(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 +000066endif
Jeff Hamilton426a9f82023-10-19 04:54:15 +000067PLATFORM_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_SDK_EXTENSION_VERSION)
68.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION
69
70# This is the sdk extension version that PLATFORM_SDK_VERSION ships with.
71PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION)
72.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION
73
74ifdef PLATFORM_VERSION_CODENAME
75 $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME))
76endif
77PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME)
78.KATI_READONLY := PLATFORM_VERSION_CODENAME
79
80ifdef PLATFORM_VERSION_ALL_CODENAMES
81 $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES))
82endif
83PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES)
84.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES
85
86ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES
87 $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES))
88endif
89PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)
90.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES
91
92ifdef PLATFORM_VERSION_LAST_STABLE
93 $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME))
94endif
95PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE)
96.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE
97
Ian Kasprzak1b2eea52024-02-21 17:12:16 +000098ifdef PLATFORM_VERSION_KNOWN_CODENAMES
99 $(error Do not set PLATFORM_VERSION_KNOWN_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES. value: $(PLATFORM_VERSION_KNOWN_CODENAMES))
100endif
101PLATFORM_VERSION_KNOWN_CODENAMES := $(RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES)
Jeff Hamilton426a9f82023-10-19 04:54:15 +0000102.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES
satayev2d945862022-02-09 21:59:28 +0000103
Sasha Smundak13359032021-09-12 17:09:01 -0700104ifndef PLATFORM_VERSION
105 ifeq (REL,$(PLATFORM_VERSION_CODENAME))
106 PLATFORM_VERSION := $(PLATFORM_VERSION_LAST_STABLE)
107 else
108 PLATFORM_VERSION := $(PLATFORM_VERSION_CODENAME)
109 endif
110endif
111.KATI_READONLY := PLATFORM_VERSION
112
Colin Crossa4925442022-02-28 18:01:35 -0800113ifndef PLATFORM_DISPLAY_VERSION
114 PLATFORM_DISPLAY_VERSION := $(PLATFORM_VERSION)
115endif
116.KATI_READONLY := PLATFORM_DISPLAY_VERSION
Sasha Smundak13359032021-09-12 17:09:01 -0700117
118ifeq (REL,$(PLATFORM_VERSION_CODENAME))
119 PLATFORM_PREVIEW_SDK_VERSION := 0
120else
121 ifndef PLATFORM_PREVIEW_SDK_VERSION
122 # This is the definition of a preview SDK version over and above the current
123 # platform SDK version. Unlike the platform SDK version, a higher value
124 # for preview SDK version does NOT mean that all prior preview APIs are
125 # included. Packages reading this value to determine compatibility with
126 # known APIs should check that this value is precisely equal to the preview
127 # SDK version the package was built for, otherwise it should fall back to
128 # assuming the device can only support APIs as of the previous official
129 # public release.
130 # This value will always be forced to 0 for release builds by the logic
131 # in the "ifeq" block above, so the value below will be used on any
132 # non-release builds, and it should always be at least 1, to indicate that
133 # APIs may have changed since the claimed PLATFORM_SDK_VERSION.
134 PLATFORM_PREVIEW_SDK_VERSION := 1
135 endif
136endif
137.KATI_READONLY := PLATFORM_PREVIEW_SDK_VERSION
138
139ifndef DEFAULT_APP_TARGET_SDK
140 # This is the default minSdkVersion and targetSdkVersion to use for
141 # all .apks created by the build system. It can be overridden by explicitly
142 # setting these in the .apk's AndroidManifest.xml. It is either the code
143 # name of the development build or, if this is a release build, the official
144 # SDK version of this release.
145 ifeq (REL,$(PLATFORM_VERSION_CODENAME))
146 DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION)
147 else
148 DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)
149 endif
150endif
151.KATI_READONLY := DEFAULT_APP_TARGET_SDK
152
Sasha Smundak13359032021-09-12 17:09:01 -0700153ifndef PLATFORM_SYSTEMSDK_MIN_VERSION
154 # This is the oldest version of system SDK that the platform supports. Contrary
155 # to the public SDK where platform essentially supports all previous SDK versions,
156 # platform supports only a few number of recent system SDK versions as some of
157 # old system APIs are gradually deprecated, removed and then deleted.
Nick Kovacs2092c972022-08-08 18:44:42 +0000158 PLATFORM_SYSTEMSDK_MIN_VERSION := 29
Sasha Smundak13359032021-09-12 17:09:01 -0700159endif
160.KATI_READONLY := PLATFORM_SYSTEMSDK_MIN_VERSION
161
162# This is the list of system SDK versions that the current platform supports.
163PLATFORM_SYSTEMSDK_VERSIONS :=
164ifneq (,$(PLATFORM_SYSTEMSDK_MIN_VERSION))
165 $(if $(call math_is_number,$(PLATFORM_SYSTEMSDK_MIN_VERSION)),,\
166 $(error PLATFORM_SYSTEMSDK_MIN_VERSION must be a number, but was $(PLATFORM_SYSTEMSDK_MIN_VERSION)))
167 PLATFORM_SYSTEMSDK_VERSIONS := $(call int_range_list,$(PLATFORM_SYSTEMSDK_MIN_VERSION),$(PLATFORM_SDK_VERSION))
168endif
169# Platform always supports the current version
170ifeq (REL,$(PLATFORM_VERSION_CODENAME))
171 PLATFORM_SYSTEMSDK_VERSIONS += $(PLATFORM_SDK_VERSION)
172else
173 PLATFORM_SYSTEMSDK_VERSIONS += $(subst $(comma),$(space),$(PLATFORM_VERSION_ALL_CODENAMES))
174endif
175PLATFORM_SYSTEMSDK_VERSIONS := $(strip $(sort $(PLATFORM_SYSTEMSDK_VERSIONS)))
176.KATI_READONLY := PLATFORM_SYSTEMSDK_VERSIONS
177
178.KATI_READONLY := PLATFORM_SECURITY_PATCH
179
180ifndef PLATFORM_SECURITY_PATCH_TIMESTAMP
181 # Used to indicate the matching timestamp for the security patch string in PLATFORM_SECURITY_PATCH.
182 PLATFORM_SECURITY_PATCH_TIMESTAMP := $(shell date -d 'TZ="GMT" $(PLATFORM_SECURITY_PATCH)' +%s)
183endif
184.KATI_READONLY := PLATFORM_SECURITY_PATCH_TIMESTAMP
185
186ifndef PLATFORM_BASE_OS
187 # Used to indicate the base os applied to the device.
188 # Can be an arbitrary string, but must be a single word.
189 #
190 # If there is no $PLATFORM_BASE_OS set, keep it empty.
191 PLATFORM_BASE_OS :=
192endif
193.KATI_READONLY := PLATFORM_BASE_OS
194
195ifndef BUILD_ID
196 # Used to signify special builds. E.g., branches and/or releases,
197 # like "M5-RC7". Can be an arbitrary string, but must be a single
198 # word and a valid file name.
199 #
200 # If there is no BUILD_ID set, make it obvious.
201 BUILD_ID := UNKNOWN
202endif
203.KATI_READONLY := BUILD_ID
204
205ifndef BUILD_DATETIME
206 # Used to reproduce builds by setting the same time. Must be the number
207 # of seconds since the Epoch.
208 BUILD_DATETIME := $(shell date +%s)
209endif
210
211DATE := date -d @$(BUILD_DATETIME)
212.KATI_READONLY := DATE
213
214# Everything should be using BUILD_DATETIME_FROM_FILE instead.
215# BUILD_DATETIME and DATE can be removed once BUILD_NUMBER moves
216# to soong_ui.
217$(KATI_obsolete_var BUILD_DATETIME,Use BUILD_DATETIME_FROM_FILE)
218
Jeongik Cha05210f92023-04-27 11:05:22 +0900219ifndef HAS_BUILD_NUMBER
Sasha Smundak13359032021-09-12 17:09:01 -0700220 HAS_BUILD_NUMBER := false
221endif
Jeongik Cha05210f92023-04-27 11:05:22 +0900222.KATI_READONLY := HAS_BUILD_NUMBER
Sasha Smundak13359032021-09-12 17:09:01 -0700223
Linus Tufvesson984b0692024-04-12 12:18:06 +0200224ifdef PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION
225 $(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 -0700226endif
Linus Tufvesson984b0692024-04-12 12:18:06 +0200227PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION := $(RELEASE_PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION)
Sasha Smundak13359032021-09-12 17:09:01 -0700228.KATI_READONLY := PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION