1# Copyright (C) 2015 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15 16# The version code scheme for the package apk is: 17# Mmbbbtad 18# where 19# M - major version (one or more digits) 20# m - minor version (exactly 1 digit) 21# bbb - manually specified build number (exactly 3 digits) 22# t - build type (exactly 1 digit). Current valid values are: 23# 0 : internal (dev build) 24# 1 : prod build 25# a - device architecture (exactly 1 digit). Current valid values are: 26# 0 : non-native 27# 1 : armv5te 28# 3 : armv7-a 29# 4 : arm64-v8a 30# 5 : mips 31# 6 : mips-64 32# 7 : x86 33# 8 : x86-64 34# d - asset density (exactly 1 digit). Current valid values are: 35# 0 : all densities 36# 2 : mdpi 37# 4 : hdpi 38# 6 : xhdpi 39# 8 : xxhdpi 40# 9 : xxxhdpi 41# Mmbbb is specified manually. tad is automatically set during the build. 42# 43# For the client jar, the version code is agnostic to the target architecture and density: Mmbbbt00 44# 45# NOTE: arch needs to be more significant than density because x86 devices support running ARM 46# code in emulation mode, so all x86 versions must be higher than all ARM versions to ensure 47# we deliver true x86 code to those devices. 48 49# Specify the following manually. Note that base_version_minor must be exactly 1 digit and 50# base_version_build must be exactly 3 digits. 51base_version_major := 1 52base_version_minor := 0 53base_version_build := 001 54 55##################################################### 56##################################################### 57# Collect automatic version code parameters 58ifneq "" "$(filter eng.%,$(BUILD_NUMBER))" 59 # This is an eng build 60 base_version_buildtype := 0 61else 62 # This is a build server build 63 base_version_buildtype := 1 64endif 65 66# Set the device architecture digit 67ifeq "$(TARGET_ARCH)" "arm" 68 ifeq "$(TARGET_ARCH_VARIANT)" "armv5te" 69 base_version_arch := 1 70 else ifeq "$(TARGET_ARCH_VARIANT)" "armv7-a" 71 base_version_arch := 3 72 endif 73else ifeq "$(TARGET_ARCH)" "arm64" 74 base_version_arch := 4 75else ifeq "$(TARGET_ARCH)" "mips" 76 base_version_arch := 5 77else ifeq "$(TARGET_ARCH)" "x86" 78 base_version_arch := 7 79else ifeq "$(TARGET_ARCH)" "x86_64" 80 base_version_arch := 8 81else 82 base_version_arch := 0 83endif 84 85ifeq "$(package_dpi)" "mdpi" 86 base_version_density := 2 87else ifeq "$(package_dpi)" "hdpi" 88 base_version_density := 4 89else ifeq "$(package_dpi)" "xhdpi" 90 base_version_density := 6 91else ifeq "$(package_dpi)" "xxhdpi" 92 base_version_density := 8 93else ifeq "$(package_dpi)" "xxxhdpi" 94 base_version_density := 9 95else 96 base_version_density := 0 97endif 98 99# Build the version code 100version_code_package := $(base_version_major)$(base_version_minor)$(base_version_build)$(base_version_buildtype)$(base_version_arch)$(base_version_density) 101 102# The version name scheme for the package apk is: 103# - For platform builds: M.m.bbb 104# - For eng build (t=1): M.m.bbb eng.$(USER)-hh 105# - For build server (t=0): M.m.bbb (nnnnnn-hh) 106# where nnnnnn is the build number from the build server (no zero-padding) 107# On eng builds, the BUILD_NUMBER has the user and timestamp inline 108ifdef TARGET_BUILD_APPS 109ifneq "" "$(filter eng.%,$(BUILD_NUMBER))" 110 git_hash := $(shell git --git-dir $(LOCAL_PATH)/.git log -n 1 --pretty=format:%h) 111 date_string := $(shell date +%m%d%y_%H%M%S) 112 version_name_package := $(base_version_major).$(base_version_minor).$(base_version_build) (eng.$(USER).$(git_hash).$(date_string)-$(base_version_arch)$(base_version_density)) 113else 114 version_name_package := $(base_version_major).$(base_version_minor).$(base_version_build) ($(BUILD_NUMBER)-$(base_version_arch)$(base_version_density)) 115endif 116else # !TARGET_BUILD_APPS 117 version_name_package := $(base_version_major).$(base_version_minor).$(base_version_build) 118endif 119 120# Cleanup the locals 121base_version_major := 122base_version_minor := 123base_version_build := 124base_version_buildtype := 125base_version_arch := 126base_version_density := 127git_hash := 128date_string := 129