8

I am building AOSP, v4.4.2. I want to specify a part of the "Build number" string (as per Settings -> About tablet).

About tablet page

I know that this can be done for the Kernel by using the CONFIG_LOCALVERSION defconfig value. But I want to change "Build number", not "Kernel version" (which I was able to do successfully).

Currently, the pertinent parts of my AOSP build are like this:

# Source build variables
. build/envsetup.sh

# Specify the build target:
# * user -> limited access; suited for production (no ADB)
# * userdebug -> like "user" but with root access and debuggability; preferred for debugging
# * eng -> development configuration with additional debugging tools (with ADB)
lunch mydevice-eng

# Build it!
time m 2>&1 | tee build.out

What should I change to specify the build number?

Community
  • 1
  • 1
CJBS
  • 15,147
  • 6
  • 86
  • 135

2 Answers2

14

The Makefile is what defines how the build number is created (concatenated) for a build.


user builds

For user builds (build target, as specified with lunch), the build number will simply be "$(BUILD_ID) $(BUILD_KEYS)", except if the DISPLAY_BUILD_NUMBER parameter is set to “true”.

eng/userdebug builds

For other builds (i.e. eng/userdebug), much more info is included:

build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)

The Makefile source is available here: https://android.googlesource.com/platform/build/+/android-4.4.2_r1/core/Makefile#106


Setting build parameters in a make file

As mentioned by @eldarerathis, the BUILD_ID value in build/core/build_id.mk is where part of the build string is defined, however this might be overridden in another make (*.mk) file.

When running lunch, the value of the BUILD_ID will be printed for verification. If this value is different to that found in the build_id.mk file, then search for where it’s being set, and re-configure it. For example, if as part of lunch, the output includes “4.4.2_1.0.0-ga”:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4.2
...
HOST_BUILD_TYPE=release
BUILD_ID=4.4.2_1.0.0-ga
OUT_DIR=out
============================================

...then search for “4.4.2_1.0.0-ga” to find it:

me@mybox:~/AOSP$find . -name "*.mk" | xargs grep  "4.4.2_1.0.0-ga"

Then, update the .mk file that contains the BUILD_ID. Set other build parameters accordingly.

BUILD_NUMBER, PLATFORM_VERSION and BUILD_ID are located in: build/core/version_defaults.mk. The values are only set if the build is initiated without them set.

Setting build parameters as a parameter at build time

Alternatively (and in my view preferably), these parameters can be set as part of the build command line like this:

me@mybox:~/AOSP$ time m BUILD_ID="MyBuildv1.2" BUILD_NUMBER=12345   2>&1 | tee build.out 
Community
  • 1
  • 1
CJBS
  • 15,147
  • 6
  • 86
  • 135
12

The BUILD_ID value in build/core/build_id.mk is where this is defined:

# BUILD_ID is usually used to specify the branch name
# (like "MAIN") or a branch name and a release candidate
# (like "CRB01").  It must be a single word, and is
# capitalized by convention.

export BUILD_ID=KOT49H

That value gets written to your build's properties, and Settings reads it from there, so you simply need to change that one export to whatever you want. The comment is merely informational, you need not follow the conventions outlined there. In the master branch they have it defined as AOSP currently.

Another available flag is DISPLAY_BUILD_NUMBER (example). It's optional, and probably not needed in your situation, but here is a description of how it works, in case it might be of use:

# DISPLAY_BUILD_NUMBER should only be set for development branches,
# If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
# a more descriptive BUILD_ID_DISPLAY, otherwise BUILD_ID_DISPLAY
# is the same as BUILD_ID
DISPLAY_BUILD_NUMBER := true
eldarerathis
  • 35,455
  • 10
  • 90
  • 93
  • Thanks; this looks promising. When I re-do `lunch mydevice-eng` after modifying `build/core/build_id.mk`, I still have the following printed-out: `BUILD_ID=4.4.2_1.0.0-ga`. Does this matter? (I didn't let the full build run) – CJBS Jan 27 '15 at 22:20
  • I've honestly not seen `lunch` output anything like that. I see it echo exactly what I've defined in `build_id.mk`. Is that the build number you ordinarily see in your settings after you flash a build? – eldarerathis Jan 28 '15 at 00:27
  • I've worked it out, and will post the full details soon. You've certainly put me on the right path, so thanks (+1). Basically there's a manufacturer-specific make file that's setting it after it gets set in `build_id.mk` – CJBS Jan 28 '15 at 00:41
  • Ah, so it was something in the device tree that was overriding it? Is this a non-Nexus device? Might explain why I had not seen that. – eldarerathis Jan 28 '15 at 14:14