[英]Which files generated by Autotools should I keep in version control repository?
I am new to autotools and I am working on a C project. 我是Autotool的新手,正在从事C项目。 I want to add my project to a git repository.
我想将我的项目添加到git存储库中。 Which files generated by the autotools I need to track in my version control system and which should be ignored?
我需要在版本控制系统中跟踪由自动工具生成的哪些文件,应该忽略哪些文件?
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
AUTHORS
, NEWS
etc. AUTHORS
, NEWS
等。 Makefile.am
in subdirectories Makefile.am
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. 为了解决Scharron提出的“准备安装”版本的问题,有些人在项目的根目录中包含了一个名为
bootstrap
或autogen.sh
的脚本,当您检出新副本时,该脚本会运行一次。 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: 对于一个简单的项目,您的
autogen.sh
实际上只需要包含一行:
autoreconf --install || exit 1
although some people prefer to run ./configure
automatically at the end of autogen.sh
. 尽管有些人喜欢在
autogen.sh
的末尾自动运行./configure
。
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 Makefile
s 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. VonC关于带有
configure
文件来生成Makefile
的C项目的说法对于源代码分发 (键入make dist
时获得的.tar.gz
文件)是正确的,但对于从版本控制中新签出的副本则不一定如此。
Note: I agree with ptomato 'ss answer , and leave this answer as Community Wiki. 注意:我同意ptomato的回答 ,并将此答案保留为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. 对于开发目的,ptomato的答案更有意义。
All the C projects generally comes with a configure file able to generate the actual Makefile used for the compilation. 通常,所有C项目都带有一个配置文件,该文件能够生成用于编译的实际Makefile。
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. 因此,当您考虑自动工具链时,我建议将所有生成的文件版本化到配置文件,因为它们通常是一次性生成操作。
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 stored those ones especially if the other reader from that project can: 因此,尽管通常不应该对任何生成的文件进行版本控制,但是可以存储这些文件,特别是如果该项目的其他阅读器可以:
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.
但是,如果要在存储库中添加“准备安装”版本(=标记),则我建议保留配置文件和Makefile文件。 They are the one needed for an install, that should work without autotools.
它们是安装所需要的,不需要自动工具就可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.