How do I use custom makefile rules to add build info?
Posted: Tue Sep 08, 2020 3:53 am
I use a build number file to put build numbers into both the executable and git commits, and the same setup puts build info defines into the compiler. Currently that's via "include foo.make". "build_number.txt" gets incremented by a git pre-commit step ("build 12345" is easier on humans than "commit 029c5b784b65245f8f3427fccf7e5640e77d536a").
But if I put "$(BUILD_NUMBER_LDFLAGS)" into the project compiler options that gets stripped when generating the makefile.
Those are used to label builds in the CI system and generate reports, so it would be a significant hassle to do without them. But not fatal in the same way not being able to support both clang and gcc would be.
Also, I'm losing linker paths info: the executable generated isn't linked to some libraries even though they're in the linker path, and I can't see how to set a runtime library search path (because the libraries are not in the same place on the target machines (not least because we build for different OS's))
Code: Select all
BUILD_NUMBER_LDFLAGS = -D__BUILD_DATE=$$(date +'%Y%m%d')
BUILD_NUMBER_LDFLAGS += -D__BUILD_NUMBER=$$(cat $(build_number.txt))
BUILD_NUMBER_LDFLAGS += -D__BUILD_DESC=\"${CND_CONF}\"
Those are used to label builds in the CI system and generate reports, so it would be a significant hassle to do without them. But not fatal in the same way not being able to support both clang and gcc would be.
Also, I'm losing linker paths info: the executable generated isn't linked to some libraries even though they're in the linker path, and I can't see how to set a runtime library search path (because the libraries are not in the same place on the target machines (not least because we build for different OS's))