在 C 可执行文件中注入 mercurial 变更集作为版本信息 [英] Injecting mercurial changeset as version information in a C executable
问题描述
我希望我正在处理的项目的可执行文件记录最新的 mercurial 变更集,以便当用户抱怨错误行为时,我可以跟踪他们使用的版本.我的一些可执行文件是 Python 的,而其他的则是 C 编译的.有没有办法自动执行此操作,或者您能否向我指出展示我可以查看的解决方案的项目?
I would like the executables for a project I am working on to have the latest mercurial changeset recorded so that when a user complains about buggy behavior, I can track which version they are using. Some of my executables are Python and others are compiled C. Is there a way to automate this, or can you point me to projects that exhibit solutions that I can look at?
我在我的项目中使用了 autoconf...以防万一使解决方案更容易.
I am using autoconf in my project... in case that makes the solution easier.
谢谢!
设置jmp
推荐答案
将此添加到 configure.ac
:
AM_CONDITIONAL([IS_HG_REPO], [test -d "$srcdir/.hg"])
将以下行添加到 Makefile.am
:
if IS_HG_REPO
AM_CPPFLAGS = -DHGVERSION=""$(PACKAGE) `hg parents --template 'hgid: {node|short}'`""
else
AM_CPPFLAGS = -DHGVERSION=PACKAGE_STRING
endif
这会将 HGVERSION
定义为 APPNAME hgid: 24d0921ee4bd
或 APPNAME VERSION
形式的字符串,如果从发布 tarball 构建.
This will define HGVERSION
as a string of the form APPNAME hgid: 24d0921ee4bd
or APPNAME VERSION
, if building from a release tarball.
这篇关于在 C 可执行文件中注入 mercurial 变更集作为版本信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!