svn - Looking for a way to store versions in a binary compiled from git repo -
i'm looking tips implement binary --version
provide information version compiled from.
the project using autotools
build system, , stored in git repo acts svn frontend.
what have inside binary is:
- compilation time
- svn commit acts base
- last git commit id , time
- if possible last commit affects specific binary
you'll want write source code use #defined constant version string. can pass in through build -dmy_version=...
option. that'll let embed default value in code, too, wrapped in #ifndef
, in case!
#ifndef my_version #define my_version 0.0.1-alpha #endif print_version() { printf("my product: %s\n", my_version); }
a nice way handle on build process side make intermediate build product makefile snippet my_version = "..."
. again adds redundancy letting distribute project version file created, build doesn't have depend on presence of scm.
you can create version string like, example:
echo -n 'my_version = "' > version_file git describe >> version_file echo "compiled on $(date)" >> version_file ... echo '"' >> version_file
then in primary makefile, include snippet, , add -dmy_version='"$(my_version)"'
build flags appropriate object.
a slight variation: make generated file purely version string, pull value appropriate variable in makefile.
if need specific git commands desired output, feel free comment. git describe
great one, though, meant kind of thing. default output closest tag ancestor of current commit, hyphen, number of commits since tag, hyphen, , abbreviated commit hash.
Comments
Post a Comment