[英]How to insert Git-based version in autoconf-managed project?
How can I assign a dynamic, git-based version number to an autoconf project? 如何为autoconf项目分配动态的基于git的版本号? Autoconf requires a static string argument to
Autoconf需要一个静态字符串参数
AC_INIT([Title],[version],[name])
AC_INIT documentation says that one can use M4 to supply a shell-based version. AC_INIT文档说可以使用M4提供基于shell的版本。 M4 is beyond my ken.
M4超出了我的范围。 I'd like to version my software according to the results of this command
我想根据此命令的结果对我的软件进行版本控制
version=`git describe --abbrev=7 --dirty --always --tags`
This produces something like 4.6.6-alpha07-9-ga3e01a8
. 这产生类似
4.6.6-alpha07-9-ga3e01a8
。
I may not understand high level answers. 我可能不理解高级答案。 I need a solution like "cut and paste this into your autoconf.ac and/or acinclude.m4".
我需要一个解决方案,例如“将其剪切并粘贴到您的autoconf.ac和/或acinclude.m4”。
Any help appreciated. 任何帮助赞赏。
How about: 怎么样:
AC_INIT([Title], [m4_esyscmd_s([git describe --abbrev=7 --dirty --always --tags])])
should work for you. 应该适合你。
Just running git describe
in m4_esyscmd
for the AC_INIT
version still leaves a few things to be desired: 只需在
m4_esyscmd
为AC_INIT
版本运行git describe
仍然有一些不足之处:
What version to use if you build a dist tarball? 如果你构建一个dist tarball,使用什么版本? There is no
git describe
useful output to be had here at all. 根本没有
git describe
有用的输出。
What version to use if you have just committed a change? 如果您刚刚提交了更改,可以使用哪个版本? Do you update the
configure
version from git describe
, or just continue to build with the existing version? 您是从
git describe
更新configure
版本,还是继续使用现有版本构建?
For my own packages (such as ndim-utils ), I have solved these issues (and a few more) by 对于我自己的包(例如ndim-utils ),我已经解决了这些问题(以及更多)
Having a special build-helpers/package-version
script which determines the version to use from a version-stamp
file if found, or git describe
. 有一个特殊的
build-helpers/package-version
脚本,用于确定要在版本version-stamp
文件中使用的version-stamp
如果找到)或git describe
。 configure.ac
AC_INIT
will m4_esyscmd
that script. configure.ac
AC_INIT
将m4_esyscmd
该脚本。
Having a special build-helpers/package-version.mk
to include from the top-level Makefile.am
which generates a version-stamp
file for dist tarballs, checks whether the current git describe
output differs from what configure
has stored, and a few other things. 从顶级
Makefile.am
包含一个特殊的build-helpers/package-version.mk
,它为dist tarball生成一个version-stamp
文件,检查当前git describe
输出是否与configure
存储的不同,以及一些其他事情。
Having a GNUmakefile.in
which updates the version stored in configure
internals from git describe
when necessary. 有一个
GNUmakefile.in
可以在必要时更新git describe
存储在configure
internals中的版本。
And I probably have forgotten a few issues addressed in that solution. 我可能已经忘记了该解决方案中解决的一些问题。
I am not certain that those scripts are ready to just copy over to your project, but I wanted to mention here that there are a few more things to consider. 我不确定那些脚本是否已准备好复制到您的项目中,但我想在此提及还有一些需要考虑的事项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.