Following this guide on CM Wiki, I've been compiling CM for my own devices for more than a year now, but that does nothing more than recreating nightly builds. I always wanted to venture beyond the basics and today I got my hands on making some first steps.
What I'm planning to do right now is to customize /system/build.prop
prior to building, as opposed to modifying it after flashing. I did some research and identified some scripts and makefiles responsible for generating it, and the one makefile in question is vendor/cm/config/common.mk
. The section I'm looking to modify alters the "CyanogenMod version" field displayed in Settings-About, as in the pic below:
common.mk
has these lines corresponding to it (slightly modified to shorten):
ifeq ($(CM_BUILDTYPE), RELEASE)
ifndef TARGET_VENDOR_RELEASE_BUILD_ID
CM_VERSION := $(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR).$(PRODUCT_VERSION_MAINTENANCE)$(PRODUCT_VERSION_DEVICE_SPECIFIC)-$(CM_BUILD)
else
ifeq ($(TARGET_BUILD_VARIANT),user)
ifeq ($(CM_VERSION_MAINTENANCE),0)
CM_VERSION := $(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR)-$(TARGET_VENDOR_RELEASE_BUILD_ID)-$(CM_BUILD)
else
CM_VERSION := $(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR).$(CM_VERSION_MAINTENANCE)-$(TARGET_VENDOR_RELEASE_BUILD_ID)-$(CM_BUILD)
endif
else
CM_VERSION := $(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR).$(PRODUCT_VERSION_MAINTENANCE)$(PRODUCT_VERSION_DEVICE_SPECIFIC)-$(CM_BUILD)
endif
endif
else
ifeq ($(CM_VERSION_MAINTENANCE),0)
CM_VERSION := $(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR)-$(shell date -u +%Y%m%d)-$(CM_BUILDTYPE)$(CM_EXTRAVERSION)-$(CM_BUILD)
else
CM_VERSION := $(PRODUCT_VERSION_MAJOR).$(PRODUCT_VERSION_MINOR).$(CM_VERSION_MAINTENANCE)-$(shell date -u +%Y%m%d)-$(CM_BUILDTYPE)$(CM_EXTRAVERSION)-$(CM_BUILD)
endif
endif
PRODUCT_PROPERTY_OVERRIDES += \
ro.cm.version=$(CM_VERSION) \
ro.cm.releasetype=$(CM_BUILDTYPE) \
ro.modversion=$(CM_VERSION) \
ro.cm.display.version=$(CM_VERSION)
Now I want to define another variable with space that stores the custom string that I want to display in that field, for example "CM13 FOO BAR", so I'd write this:
ifndef CM_VERSION_CUSTOM
CM_VERSION_CUSTOM := CM13 FOO BAR
endif
...and assign CM_VERSION_CUSTOM to where CM_VERSION applies.
In practise this doesn't work at all - the string was outputted to /build.prop
incorrectly, sometimes as if each space is a newline, sometimes as if the contents after the 1st space doesn't exist, like this:
ro.cm.version=CM13
FOO
BAR
ro.modversion=CM13
ro.cm.display.version=CM13
I tried adding quotes (' and " tested), either to the string definition or to where CM_VERSION CUSTOM was referenced (like "$(CM_VERSION_CUSTOM)"), but none helped. I'm not familiar with makefile at all, so I'm at a loss right now. Can someone point me in the right way?