我应该将 Autotools 生成的哪些文件保留在版本控制存储库中?

发布于 2024-09-10 07:48:48 字数 89 浏览 6 评论 0原文

我是 autotools 的新手,正在开发一个 C 项目。我想将我的项目添加到 git 存储库。我需要在版本控制系统中跟踪哪些由自动工具生成的文件,哪些应该被忽略?

I am new to autotools and I am working on a C project. I want to add my project to a git repository. Which files generated by the autotools I need to track in my version control system and which should be ignored?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一口甜 2024-09-17 07:48:48

您不应将任何未经手工编辑的文件置于版本控制之下。这意味着版本控制系统应该忽略任何生成的文件。我基本上只将以下内容置于版本控制之下:

  • configure.ac
  • Makefile.am
  • 文档文件,例如 AUTHORSNEWS
  • 子目录中的 Makefile.am

为了解决 Scharron 提出的“准备安装”版本的问题,有些人在项目的根目录,称为 bootstrapautogen.sh,当您签出新副本时运行一次。您可以在我的一个项目中看到一个示例 在这里。对于更简单的项目,您的 autogen.sh 实际上只需要包含一行:

autoreconf --install || exit 1

尽管有些人更喜欢在 autogen 末尾自动运行 ./configure .sh。

为什么不在版本控制中跟踪所有生成的文件?因为它们的内容取决于您构建的机器、生成它们的自动工具的版本以及月相。任何时候任何这些更改,生成的自动工具文件都会更改,并且您的提交中将收到大量垃圾。

此外,任何为了构建代码而从版本控制中检查代码的人都应该安装适当的开发工具,因此您真的不需要担心人们因为缺少自动工具而遇到麻烦。

VonC 所说的关于带有 configure 文件来生成 Makefile 的 C 项目对于源代码发行版.tar .gz 文件,当您键入 make dist 时获得的文件),但不一定用于从版本控制中新鲜检出的副本。

You should not keep any files under version control that are not hand-edited. That means any generated file should be ignored by the version control system. I basically put only the following under version control:

  • configure.ac
  • Makefile.am
  • the documentation files such as AUTHORS, NEWS etc.
  • Makefile.am in subdirectories

To address the point of having a "ready-to-install" version brought up by Scharron, some people include a script in the project's root directory, called bootstrap or autogen.sh, that you run once when you check a fresh copy out. You can see an example in one of my projects here. For a simpler project, your autogen.sh really only needs to consist of one line:

autoreconf --install || exit 1

although some people prefer to run ./configure automatically at the end of autogen.sh.

Why not track all the generated files in version control? Because their contents depend on the machine you are building on, the version of autotools you generated them with, and the phase of the moon. Any time any of these changes, the generated autotools files will change, and you will get a lot of junk in your commits.

Also, anyone who checks your code out of version control in order to build it should be expected to have proper development tools installed, so you really don't need to worry about people running into trouble because of missing autotools.

What VonC says about C projects coming with a configure file to generate the Makefiles is true for source code distributions (the .tar.gz file that you get when you type make dist) but not necessarily for freshly checked out copies from version control.

前事休说 2024-09-17 07:48:48

注意:我同意 ptomato答案,并将此答案保留为社区 Wiki。
这对于源代码分发是有意义的,但您的项目可能不是这样。
出于开发目的,ptomato的答案更有意义。


所有 C 项目通常都附带一个配置文件,能够生成用于编译的实际 Makefile。

因此,当您考虑自动工具链时,我建议对配置文件之前生成的所有文件进行版本控制,因为它们通常是一次性生成操作。

http://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Autoconf.svg/309px-Autoconf。 svg.png

这意味着任何拥有您的版本项目副本的人都可以立即开始:

./configure
make
make install

因此,虽然通常是这样,但您不应该对任何生成的文件进行版本控制,您可以存储这些文件,特别是如果其他读者来自该文件项目可以:

  • 受益于不重新生成这些文件(以获得相同的结果)
  • 立即开始配置和编译。

上面流程图中的ed是什么?!

Note: I agree with ptomato's answer, and leave this answer as Community Wiki.
It makes sense for source code distributions, but your project may not be one.
For development purpose, ptomato's answer makes more sense.


All the C projects generally come with a configure file able to generate the actual Makefile used for the compilation.

So when you consider the autotool chain, I would recommend versioning all files generated up to the configure file, as they are normally a one-time generation operation.

http://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Autoconf.svg/309px-Autoconf.svg.png

That means anyone with a checked out copy of your version project can immediately start:

./configure
make
make install

So, while it is generally true, you shouldn't version any generated files, you could store those, especially if the other reader from that project can:

  • benefit from not re-generating those files (for an identical result)
  • start immediately to configure and compile.

What is ed in the above flow chart?! ????

The ed in the flow chart is likely a placeholder for the text editor used to modify or create the configure.ac and Makefile.am files.
In the context of Autotools, these files are written by a developer to specify the configuration and build instructions for the software. ed is actually one of the standard text editors in Unix and Unix-like systems and represents the concept of editing these files manually.

In a graphical representation of the Autotools workflow, showing an editor like ed emphasizes that the configure.ac and Makefile.am files are typically handcrafted rather than generated by the Autotools themselves.
autoscan can be used to generate a preliminary configure.ac, which is then edited by a developer using a text editor (ed in this case) to fine-tune the configuration process.

ぃ弥猫深巷。 2024-09-17 07:48:48

一般来说,您不应该在存储库中保留任何生成的文件(否则您会看到更改并且必须提交它们/还原它们)。
但是,如果您想将“准备安装”版本添加(=标记)到您的存储库,我建议保留配置和 Makefile 文件。它们是安装所需的,无需自动工具即可工作。

Generally, you should not keep any generated files on a repository (else you would see changes and have to commit them / revert them).
However, if you want to have "ready-to-install" version added (= tagged) to your repository, I would recommand to keep configure and Makefile files. They are the one needed for an install, that should work without autotools.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文