c++ - 将 Visual Studio C++ 构建的中间文件移动到另一台计算机

标签 c++ visual-studio precompiled-headers build-server incremental-build

我们正在寻找一种方法来加速本地 C++ 构建。我们心里有一个简单的想法。我们定期在构建服务器上构建我们的解决方案。这种构建是增量的:当我们推送新的更改时,仅重建解决方案的必要部分。快捷、方便。

如果我们将 VS 生成的所有中间文件从构建服务器复制到本地计算机会怎样?理想情况下,VS 应该在这些中间文件之上生成增量构建。快捷、方便。

问题是,我们的构建服务器和本地计算机使用不同的解决方案路径。这对于增量构建来说效果不佳。

我在测试项目中尝试过的内容: 1. 将所有中间文件从构建服务器复制到本地计算机 2.将所有中间文件的时间戳更新为当前时间 3. 将所有 *.tlog 文件中的所有路径从服务器特定更改为本地特定

第一印象很好:VS 报告该项目是最新的,无需构建,是的!但是,如果我更改单个文件,VS 会尝试使用已有的预编译头来重建它。我有很多这样的错误:

1>e:\dev\prod3\shared\sdk\src\common\tblockalloc.h(18): error C2995: 'BlockManagerSPtr GetBlockManager(void)': function template has already been defined (compiling source file Requests.cpp)
1>d:\agent-home\xml-data\build-dir\ama-actd-job1\shared\sdk\src\common\tblockalloc.h(15): note: see declaration of 'GetBlockManager' (compiling source file Requests.cpp)

似乎令人困惑的是,相同的符号出现在具有不同路径的标题中。

好的,我尝试简单地替换 PCH 文件中的路径,就像替换 .tlog 文件一样。但即使我不更改任何文件,VS 也会立即认为该项目已过时。这令人惊讶,因为我认为它不会查看文件本身,而只会观察它们的时间戳。不管怎样,它然后吐出了大量这样的错误:

1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4652: compiler option 'StdCall(/Gz)' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4652: compiler option 'CDecl(/Gd)' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4652: compiler option 'general PM representation(/vm[smv])' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4652: compiler option 'support for new floating-point model (/FP)' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4652: compiler option 'vtordisp(/vd[012])' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4652: compiler option 'DLL library (/MD)' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4652: compiler option 'Debug static MT library (/MTd)' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4653: compiler option 'Optimizations (one or more of /Oawstgp[y]) or debug checks (one or more of /GZ, /RTCcsu)' inconsistent with precompiled header; current command-line option ignored
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): warning C4653: compiler option 'For loop scope conformance (/Zc:forScope)' inconsistent with precompiled header; current command-line option ignored
1>e:\dev\prod3\shared\app.restserver\src\constants.cpp(1): error C2855: command-line option '/Zc:threadSafeInit' inconsistent with precompiled header

看起来我不喜欢乱搞 PCH。

所以现在我有点陷入困境。我希望找到一些有关如何重用 Visual Studio 的构建工件来实现轻松增量构建的信息,但实际上我什么也没找到。

这可能吗?有人试过吗?

最佳答案

我们有类似的东西。我们只有 VS 解决方案的相对路径,然后我们还存储具有正确时间戳的(空/伪造).tlog 文件。我们只存储库,而不存储中间目标文件,因此当有人更改库的文件时,我认为我们会重建完整的库。但是我们对预编译头没有任何问题,它们是最新的,并且我们有相同的标志,所以我认为您的构建服务器和本地构建之间有不同的设置。我们没有这个问题,因为 VS 标志来 self 们的 Makefile,所以一切都是一致的。

最大的缺点是,当我们转向 CMake 时,我们将面临一场艰苦的战斗来重现层次结构,就像我们为自定义构建所做的那样。

那么也许您应该使用现成的产品,例如 Incredibuild。

关于c++ - 将 Visual Studio C++ 构建的中间文件移动到另一台计算机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54769385/

相关文章:

c++ - 如何直接在 bool 上下文中评估对象?

c++ - 这个关系不等于定义明确的表达式吗?

html - 有没有办法在 Bootstrap 的预编译库中编辑 .scss 文件?

c++ - 我什么时候想在 visual studio 中关闭 "precompiled header"?

c++ - 如何将具有一定数量单词的 vector<string> 的输出读取到一行?

c++ - Visual Studio : What exactly are lib files (used for)?

c# - 在 Microsoft Visual Studio 调试器中更改日期时间

c++ - 预编译头设计问题

centos 上的 c++ automake 预编译 header 支持

c++ - 无分支内存管理器?