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