Here's another recipe for variety.
On 7/13/2015 9:50 PM, Christopher M. Fuhrman wrote:
Here's how I do it in my GNUmakefile/Makefile:
What's the advantage of using a manifest file?
In a recent firmware project I wanted to make it more difficult to
accidentally deliver a build made from a workspace with uncommitted
changes, while also compiling in the fossil commit ID.
While DRH is right that using manifest and manifest.uuid is the "best"
way because it allows builds to be made from a tarball, it also does not
provide any protection from tweaks to the sources. So I use the files,
but also test fossil changes.
My distribution builds are always clean compiles of the entire source
tree. So the makefile provides a UUID to the C Preprocessor via the
option -DBUILD_UUID_STRING=$(UUID) along with a second define to signal
a release build. There is also a file version.h containing the
"marketing" version number, and I want to use that number in the file
name of the ZIP I build for distribution.
Near the top of the root Makefile, I do the following (unwrapping the
lines to recover from email formatting is left as an exercise here...):
#
# Discover fossil checkin id and public version number
#
MANIFESTUUID := $(shell sed -e "s/\(.\{10\}\).*/\1/" manifest.uuid)
VERSIONMAJ := $(shell sed -n -e "/define VERSION_MAJ/
s/^[^0-9]*\([0-9]*\)[^0-9]*$$/\1/p" src/version.h)
VERSIONMIN := $(shell sed -n -e "/define VERSION_MIN/
s/^[^0-9]*\([0-9]*\)[^0-9]*$$/\1/p" src/version.h)
VERSIONPAT := $(shell sed -n -e "/define VERSION_PAT/
s/^[^0-9]*\([0-9]*\)[^0-9]*$$/\1/p" src/version.h)
CHECKCLEAN := $(if $(shell fossil changes),-WITH-UNCOMMITTED-CHANGES)
#
# Create a filename-friendly version string like v1.123p42 where
# exacly three digits of the minor version number are displayed.
#
VERSION := v$(VERSIONMAJ).$(shell echo 000$(VERSIONMIN) | sed -n -e
s/^.*\([0-9]\{3\}\).*$$/\1/p )p$(VERSIONPAT)$(CHECKCLEAN)
#
# Create a UUID string for clean builds which will look like either
# [abcdef0123] or [abcdef0123]-WITH-UNCOMMITED-CHANGES
#
UUID := [$(MANIFESTUUID)]$(CHECKCLEAN)
CPPFLAGS += -DBUILD_UUID_STRING=$(UUID)
In the rules that package up the release ZIP, I've copied the firmware
HEX file with a name that includes both $(VERSION) and $(MANIFESTUUID),
but name the finished ZIP with just $(VERSION).
Since $(VERSION) ends up including "-WITH-UNCOMMITED-CHANGES" if the
checkout is dirty, it is much harder to accidentally send that file to
the customer, and if sent they tend to ask awkward questions.
I'm not particularly worried about the performance of this, since
development was done in an IDE, the makefile is primarily used for
release builds which will include the equivalent of make clean all so a
few invokations of sed vanish in the noise of about a hundred
invokations of GCC.
In other projects I've used Perl, AWK, and/or Lua to do similar tasks.
There really is more than one way to do it.
--
Ross Berteig r...@cheshireeng.com
Cheshire Engineering Corp. http://www.CheshireEng.com/
+1 626 303 1602
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users