将Visual Studio C ++构建的中间文件移动到另一台机器上

时间:2019-02-19 15:09:48

标签: 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的构建工件以实现简单的增量构建的信息,但实际上我什么都没发现。

有可能吗?有人尝试过吗?

1 个答案:

答案 0 :(得分:2)

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

最大的缺点是,当我们转到CMake时,将像在我们的自定义构建中一样,要重现层次结构,这是一场艰苦的战斗。

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