1# 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 17 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_VERSION_FULL 26# PLATFORM_SDK_EXTENSION_VERSION 27# PLATFORM_BASE_SDK_EXTENSION_VERSION 28# PLATFORM_VERSION_CODENAME 29# DEFAULT_APP_TARGET_SDK 30# BUILD_ID 31# BUILD_NUMBER 32# PLATFORM_SECURITY_PATCH 33# PLATFORM_SYSTEMSDK_VERSIONS 34# PLATFORM_VERSION_LAST_STABLE 35# PLATFORM_VERSION_KNOWN_CODENAMES 36# 37 38# Look for an optional file containing overrides of the defaults, 39# but don't cry if we don't find it. We could just use -include, but 40# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set 41# if the file exists. 42# 43INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) 44ifdef INTERNAL_BUILD_ID_MAKEFILE 45 include $(INTERNAL_BUILD_ID_MAKEFILE) 46endif 47 48ifdef TARGET_PLATFORM_VERSION 49 $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION)) 50endif 51TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION) 52.KATI_READONLY := TARGET_PLATFORM_VERSION 53 54ifdef PLATFORM_SECURITY_PATCH 55 $(error Do not set PLATFORM_SECURITY_PATCH directly. Use RELEASE_PLATFORM_SECURITY_PATCH. value: $(PLATFORM_SECURITY_PATCH)) 56endif 57PLATFORM_SECURITY_PATCH := $(RELEASE_PLATFORM_SECURITY_PATCH) 58.KATI_READONLY := PLATFORM_SECURITY_PATCH 59 60ifdef PLATFORM_SDK_VERSION 61 $(error Do not set PLATFORM_SDK_VERSION directly. Use RELEASE_PLATFORM_SDK_VERSION. value: $(PLATFORM_SDK_VERSION)) 62endif 63PLATFORM_SDK_VERSION := $(RELEASE_PLATFORM_SDK_VERSION) 64.KATI_READONLY := PLATFORM_SDK_VERSION 65 66ifdef PLATFORM_SDK_VERSION_FULL 67 $(error Do not set PLATFORM_SDK_VERSION_FULL directly. Use RELEASE_PLATFORM_SDK_VERSION_FULL. value: $(PLATFORM_SDK_VERSION_FULL)) 68endif 69ifeq ($(RELEASE_PLATFORM_SDK_VERSION_FULL),) 70 PLATFORM_SDK_VERSION_FULL := "$(PLATFORM_SDK_VERSION).0" 71else 72 ifneq ($(RELEASE_PLATFORM_SDK_VERSION),$(word 1,$(subst ., ,$(RELEASE_PLATFORM_SDK_VERSION_FULL)))) 73 $(error if RELEASE_PLATFORM_SDK_VERSION_FULL ($(RELEASE_PLATFORM_SDK_VERSION_FULL)) is set, its major version must match RELEASE_PLATFORM_SDK_VERSION ($(RELEASE_PLATFORM_SDK_VERSION))) 74 endif 75 PLATFORM_SDK_VERSION_FULL := "$(RELEASE_PLATFORM_SDK_VERSION_FULL)" 76endif 77.KATI_READONLY := PLATFORM_SDK_VERSION_FULL 78 79ifdef PLATFORM_SDK_EXTENSION_VERSION 80 $(error Do not set PLATFORM_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_SDK_EXTENSION_VERSION. value: $(PLATFORM_SDK_EXTENSION_VERSION)) 81endif 82PLATFORM_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_SDK_EXTENSION_VERSION) 83.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION 84 85ifdef PLATFORM_BASE_SDK_EXTENSION_VERSION 86 $(error Do not set PLATFORM_BASE_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION. value: $(PLATFORM_BASE_SDK_EXTENSION_VERSION)) 87endif 88ifdef RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION 89 # This is the sdk extension version that PLATFORM_SDK_VERSION ships with. 90 PLATFORM_BASE_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION) 91else 92 # Fallback to PLATFORM_SDK_EXTENSION_VERSION if RELEASE_PLATFORM_BASE_SDK_EXTENSION_VERSION is undefined. 93 PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) 94endif 95.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION 96 97ifdef PLATFORM_VERSION_CODENAME 98 $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME)) 99endif 100PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME) 101.KATI_READONLY := PLATFORM_VERSION_CODENAME 102 103ifdef PLATFORM_VERSION_ALL_CODENAMES 104 $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES)) 105endif 106PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES) 107.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES 108 109ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES 110 $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)) 111endif 112PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES) 113.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES 114 115ifdef PLATFORM_VERSION_LAST_STABLE 116 $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME)) 117endif 118PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE) 119.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE 120 121ifdef PLATFORM_VERSION_KNOWN_CODENAMES 122 $(error Do not set PLATFORM_VERSION_KNOWN_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES. value: $(PLATFORM_VERSION_KNOWN_CODENAMES)) 123endif 124PLATFORM_VERSION_KNOWN_CODENAMES := $(RELEASE_PLATFORM_VERSION_KNOWN_CODENAMES) 125.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES 126 127ifndef PLATFORM_VERSION 128 ifeq (REL,$(PLATFORM_VERSION_CODENAME)) 129 PLATFORM_VERSION := $(PLATFORM_VERSION_LAST_STABLE) 130 else 131 PLATFORM_VERSION := $(PLATFORM_VERSION_CODENAME) 132 endif 133endif 134.KATI_READONLY := PLATFORM_VERSION 135 136ifndef PLATFORM_DISPLAY_VERSION 137 PLATFORM_DISPLAY_VERSION := $(PLATFORM_VERSION) 138endif 139.KATI_READONLY := PLATFORM_DISPLAY_VERSION 140 141ifeq (REL,$(PLATFORM_VERSION_CODENAME)) 142 PLATFORM_PREVIEW_SDK_VERSION := 0 143else 144 ifndef PLATFORM_PREVIEW_SDK_VERSION 145 # This is the definition of a preview SDK version over and above the current 146 # platform SDK version. Unlike the platform SDK version, a higher value 147 # for preview SDK version does NOT mean that all prior preview APIs are 148 # included. Packages reading this value to determine compatibility with 149 # known APIs should check that this value is precisely equal to the preview 150 # SDK version the package was built for, otherwise it should fall back to 151 # assuming the device can only support APIs as of the previous official 152 # public release. 153 # This value will always be forced to 0 for release builds by the logic 154 # in the "ifeq" block above, so the value below will be used on any 155 # non-release builds, and it should always be at least 1, to indicate that 156 # APIs may have changed since the claimed PLATFORM_SDK_VERSION. 157 PLATFORM_PREVIEW_SDK_VERSION := 1 158 endif 159endif 160.KATI_READONLY := PLATFORM_PREVIEW_SDK_VERSION 161 162ifndef DEFAULT_APP_TARGET_SDK 163 # This is the default minSdkVersion and targetSdkVersion to use for 164 # all .apks created by the build system. It can be overridden by explicitly 165 # setting these in the .apk's AndroidManifest.xml. It is either the code 166 # name of the development build or, if this is a release build, the official 167 # SDK version of this release. 168 ifeq (REL,$(PLATFORM_VERSION_CODENAME)) 169 DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION) 170 else 171 DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME) 172 endif 173endif 174.KATI_READONLY := DEFAULT_APP_TARGET_SDK 175 176ifndef PLATFORM_SYSTEMSDK_MIN_VERSION 177 # This is the oldest version of system SDK that the platform supports. Contrary 178 # to the public SDK where platform essentially supports all previous SDK versions, 179 # platform supports only a few number of recent system SDK versions as some of 180 # old system APIs are gradually deprecated, removed and then deleted. 181 PLATFORM_SYSTEMSDK_MIN_VERSION := 29 182endif 183.KATI_READONLY := PLATFORM_SYSTEMSDK_MIN_VERSION 184 185# This is the list of system SDK versions that the current platform supports. 186PLATFORM_SYSTEMSDK_VERSIONS := 187ifneq (,$(PLATFORM_SYSTEMSDK_MIN_VERSION)) 188 $(if $(call math_is_number,$(PLATFORM_SYSTEMSDK_MIN_VERSION)),,\ 189 $(error PLATFORM_SYSTEMSDK_MIN_VERSION must be a number, but was $(PLATFORM_SYSTEMSDK_MIN_VERSION))) 190 PLATFORM_SYSTEMSDK_VERSIONS := $(call int_range_list,$(PLATFORM_SYSTEMSDK_MIN_VERSION),$(PLATFORM_SDK_VERSION)) 191endif 192# Platform always supports the current version 193ifeq (REL,$(PLATFORM_VERSION_CODENAME)) 194 PLATFORM_SYSTEMSDK_VERSIONS += $(PLATFORM_SDK_VERSION) 195else 196 PLATFORM_SYSTEMSDK_VERSIONS += $(subst $(comma),$(space),$(PLATFORM_VERSION_ALL_CODENAMES)) 197endif 198PLATFORM_SYSTEMSDK_VERSIONS := $(strip $(sort $(PLATFORM_SYSTEMSDK_VERSIONS))) 199.KATI_READONLY := PLATFORM_SYSTEMSDK_VERSIONS 200 201.KATI_READONLY := PLATFORM_SECURITY_PATCH 202 203ifndef PLATFORM_SECURITY_PATCH_TIMESTAMP 204 # Used to indicate the matching timestamp for the security patch string in PLATFORM_SECURITY_PATCH. 205 PLATFORM_SECURITY_PATCH_TIMESTAMP := $(shell date -d 'TZ="GMT" $(PLATFORM_SECURITY_PATCH)' +%s) 206endif 207.KATI_READONLY := PLATFORM_SECURITY_PATCH_TIMESTAMP 208 209# PLATFORM_BASE_OS is used to indicate the base os applied 210# to the device. Can be an arbitrary string, but must be a 211# single word. 212# 213# If there is no $PLATFORM_BASE_OS set, keep it empty. 214# 215# PLATFORM_BASE_OS can either be set via an enviornment 216# variable, or set via the PRODUCT_BASE_OS product variable. 217PLATFORM_BASE_OS_ENV_INPUT := $(PLATFORM_BASE_OS) 218.KATI_READONLY := PLATFORM_BASE_OS_ENV_INPUT 219PLATFORM_BASE_OS := 220 221ifndef BUILD_ID 222 # Used to signify special builds. E.g., branches and/or releases, 223 # like "M5-RC7". Can be an arbitrary string, but must be a single 224 # word and a valid file name. 225 # 226 # If there is no BUILD_ID set, make it obvious. 227 BUILD_ID := UNKNOWN 228endif 229.KATI_READONLY := BUILD_ID 230 231ifndef BUILD_DATETIME 232 # Used to reproduce builds by setting the same time. Must be the number 233 # of seconds since the Epoch. 234 BUILD_DATETIME := $(shell date +%s) 235endif 236 237DATE := date -d @$(BUILD_DATETIME) 238.KATI_READONLY := DATE 239 240# Everything should be using BUILD_DATETIME_FROM_FILE instead. 241# BUILD_DATETIME and DATE can be removed once BUILD_NUMBER moves 242# to soong_ui. 243$(KATI_obsolete_var BUILD_DATETIME,Use BUILD_DATETIME_FROM_FILE) 244 245ifndef HAS_BUILD_NUMBER 246 HAS_BUILD_NUMBER := false 247endif 248.KATI_READONLY := HAS_BUILD_NUMBER 249 250ifdef PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION 251 $(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)) 252endif 253PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION := $(RELEASE_PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION) 254.KATI_READONLY := PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION 255