I have been thinking about a method how to insert software version number in form Major.minor.build into the source code without manual modification of the source code.
I have got an idea that all the parts of the version number will be derived from information comming from version control software (Mercurial in my case). Major and minor will be automatically filled by number of the tag (M.m) and build will be filled by the revision number. That is the idea.
As far as implementation I think that I could write a script triggered by some hook
(probably the pretag hook). The goal of this script is to create a C language header
file (e.g. Version.h
) with following content
#define MAJOR M
#define MINOR m
#define BUILD b
The Version.h
header will be included by module responsible for software version number
publishing (in my case via filling several records in communication table). To actually
fill the software version number into the source code it will be necessary to do second
step - compilation where linker ensures expansion of the above mentioned symbolic
constants.
Whenever I will release new software I will create a tag first (which assignes actual numbers to the symbolic constants above). Then I run compilation process to push the previously retrieved numbers into correct place in the source code.
Do you think that the suggested method is usable? Thanks for any suggestions.
0.8.1618
(trailing {rev}
) seems good, but think about possible history rewriting (which can change local rev even in the same repo)0.8.229f43b67c2a
(trailing {{node|short}
) isn't good for eyes, but good for historical explorations in most casesI have full version as tags, use own templatealias
semver = "{latesttag}{ifeq(latesttagdistance,0,'','+{latesttagdistance}')}"
for building usable and easy understandable versions string instead of suggested in wiki plain {node|short}
and, as result, my current nice tip
is shown as 0.8.13+38
HTH