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. 51 base_version_major := 1 52 base_version_minor := 0 53 base_version_build := 001 54 55 ##################################################### 56 ##################################################### 57 # Collect automatic version code parameters 58 ifeq ($(strip $(HAS_BUILD_NUMBER)),false) 59 # This is an eng build 60 base_version_buildtype := 0 61 else 62 # This is a build server build 63 base_version_buildtype := 1 64 endif 65 66 # Set the device architecture digit 67 ifeq "$(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 73 else ifeq "$(TARGET_ARCH)" "arm64" 74 base_version_arch := 4 75 else ifeq "$(TARGET_ARCH)" "mips" 76 base_version_arch := 5 77 else ifeq "$(TARGET_ARCH)" "x86" 78 base_version_arch := 7 79 else ifeq "$(TARGET_ARCH)" "x86_64" 80 base_version_arch := 8 81 else 82 base_version_arch := 0 83 endif 84 85 ifeq "$(package_dpi)" "mdpi" 86 base_version_density := 2 87 else ifeq "$(package_dpi)" "hdpi" 88 base_version_density := 4 89 else ifeq "$(package_dpi)" "xhdpi" 90 base_version_density := 6 91 else ifeq "$(package_dpi)" "xxhdpi" 92 base_version_density := 8 93 else ifeq "$(package_dpi)" "xxxhdpi" 94 base_version_density := 9 95 else 96 base_version_density := 0 97 endif 98 99 # Build the version code 100 version_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 108 ifdef TARGET_BUILD_APPS 109 ifeq ($(strip $(HAS_BUILD_NUMBER)),false) 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)) 113 else 114 version_name_package := $(base_version_major).$(base_version_minor).$(base_version_build) ($(BUILD_NUMBER_FROM_FILE)-$(base_version_arch)$(base_version_density)) 115 endif 116 else # !TARGET_BUILD_APPS 117 version_name_package := $(base_version_major).$(base_version_minor).$(base_version_build) 118 endif 119 120 # Cleanup the locals 121 base_version_major := 122 base_version_minor := 123 base_version_build := 124 base_version_buildtype := 125 base_version_arch := 126 base_version_density := 127 git_hash := 128 date_string := 129