简体   繁体   English

如何在autoconf管理的项目中插入基于Git的版本?

[英]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_esyscmdAC_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_INITm4_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.

相关问题 Eclipse无法识别基于git的项目 - Eclipse doesn't recognise git-based project Android Studio - 基于 Git 的多平台项目的 CRLF 与 LF - Android Studio - CRLF vs LF for a Git-based multiplatform project 在基于git的CMS中,如何唯一标识git存储库中的文件? - In a git-based CMS, how to uniquely identify files in git repository? 基于Git的网站部署工作流程 - Git-based website deployment workflow 使用基于Git的Visual Studio Online构建解决方案失败,并带有项目引用 - Building solution using Git-based Visual Studio Online fails with project references bup(基于git的图像备份)如何计算存储对象的哈希 - How does bup (git-based image backup) computes hashes of stored objects 这些基于git的代码部署方法背后的原因是什么? - What's the reasoning behind these approaches to git-based code deployment? 企业中基于Git的源代码控制:建议的工具和实践? - Git-Based Source Control in the Enterprise: Suggested Tools and Practices? 使用git来管理公共项目的补丁版本? - Use git to managed a patched version of a public project? Ruby On Rails — 安装基于 git 的 gem 'not ckecked' 问题 - Ruby On Rails — installing git-based gems 'not ckecked out' problem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM