跳过内容

统一构建系统

WebKit 构建系统结构概述。

概述

为了减少编译时间(在满载的 2018 年 15 英寸 MacBook Pro 上曾耗时 40 多分钟),我们将多个 C++ 翻译单元(.cpp 文件)打包并作为单个翻译单元进行编译。这是一种被称为统一源统一构建的常见技术。

统一源在 WebKitBuild/X/DerivedSources 下生成,其中 X 是构建配置的名称,例如 DebugRelease-iphonesimulator。例如,WebKitBuild/Debug/DerivedSources/WebCore/unified-sources/UnifiedSource116.cpp 可能如下所示

#include "dom/Document.cpp"
#include "dom/DocumentEventQueue.cpp"
#include "dom/DocumentFragment.cpp"
#include "dom/DocumentMarkerController.cpp"
#include "dom/DocumentParser.cpp"
#include "dom/DocumentSharedObjectPool.cpp"
#include "dom/DocumentStorageAccess.cpp"
#include "dom/DocumentType.cpp"

统一源构建失败

由于统一源的存在,添加新文件可能会在某些平台上导致新的构建失败。这发生在以下情况:如果 UnifiedSource1.cpp 包含 a.cppb.cppc.cpp,那么 a.cpp 中的 #include 可能会拉入 c.cpp 所需的某些头文件。当您添加 b2.cpp 并且 c.cpp 移动到 UnifiedSource2.cpp 时,c.cpp 不再能“意外地”从 a.cpp 满足其头文件依赖项中受益。发生这种情况时,您需要像最初就应该做的那样,向 c.cpp 添加新的 #include