统一构建的好处/坏处?

2021-12-28 00:00:00 compilation c++ build-process

自从在一家新公司开始工作以来,我注意到他们在我们的大部分解决方案中使用了 unity cpp 文件,我想知道是否有人能够给我一个明确的理由来说明为什么以及如何加速构建过程?我原以为在 unity 文件中编辑一个 cpp 文件会强制重新编译所有文件.

Since starting at a new company I've noticed that they use unity cpp files for the majority of our solution, and I was wondering if anyone is able to give me a definitive reason as to why and how these speed up the build process? I would've thought that editing one cpp file in the unity files will force recompilation of all of them.

推荐答案

非常相似的问题和很好的答案在这里:#include 所有 .cpp 文件到一个编译单元?

Very similar question and good answers here: #include all .cpp files into a single compilation unit?

总结起来似乎是减少 I/O 开销是主要的好处.

The summary seems to be that less I/O overhead is the major benefit.

另请参阅Unity Builds 的魔力,链接在上面的问题也是如此.

See also The Magic Of Unity Builds as linked in the above question as well.

相关文章