【发布时间】:2019-02-19 15:09:47
【问题描述】:
我们正在寻找一种方法来加快本地 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)
在不同路径的标题中出现相同的符号似乎很困惑。
好的,我尝试像替换 .tlog 文件一样简单地替换 PCH 文件中的路径。但是即使我不更改任何文件,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 的构建工件来实现简单的增量构建的信息,但我实际上发现 什么都没有。
有可能吗?有人试过吗?
【问题讨论】:
-
我不想在有人回答后将其标记为重复,但谷歌搜索“ccache visual studio”导致stackoverflow.com/questions/1860331/…导致stashed.io/home
-
该死,这不是我搜索它的方式。非常感谢您的链接!
标签: c++ visual-studio precompiled-headers build-server incremental-build