简体   繁体   English

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

[英]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
  • the documentation files such as AUTHORS , NEWS etc. 文档文件,例如AUTHORSNEWS等。
  • 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提出的“准备安装”版本的问题,有些人在项目的根目录中包含了一个名为bootstrapautogen.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. 因此,当您考虑自动工具链时,我建议将所有生成的文件版本化到配置文件,因为它们通常是一次性生成操作。

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 stored those ones 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. 立即开始进行配置和编译。

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.

相关问题 我是否应该在版本控制下保留通过alembic生成的数据库迁移脚本 - Should I keep DB migration scripts generated via alembic under version control 如何对不应推送到远程存储库的控制文件进行版本控制? - How to version control files which shouldn't be pushed to a remote repository? 我应该在版本控制中忽略Visual Studio 2017创建的哪些文件? - Which files created by Visual Studio 2017 should I ignore in version control? Sencha Touch 2的版本控制中应包含哪些文件/文件夹 - Which files/folder should be in version control for Sencha Touch 2 我应该将版本控制(git)与项目分开吗? - Should I keep my version control (git) separate from project? 我应该将哪个fuelphp文件夹添加到自己的版本控制中? - which fuelphp folder should I add to my own version control? Autotools输出脚本和Makefile是否应包含在存储库中? - Should Autotools output scripts and Makefiles be included in a repository? 我应该在版本控制中存储 Xcode 项目的哪些文件? - What files of an Xcode project should I store in version control? 我应该保留哪些ReSharper文件以及我应该在源代码管理中忽略哪些文件? - What ReSharper files should I keep and what files should I ignore in Source Control? Chef:我应该将“ syntaxcache”文件签入版本控制吗? - Chef: should I be checking “syntaxcache” files into version control?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM