暂存文件

This commit is contained in:
huanglinhuan
2025-12-12 21:54:52 +08:00
parent 96fecf3c6f
commit 91ae52eeb3
13 changed files with 631 additions and 85 deletions

143
docs/BUILD_SYSTEM.md Normal file
View File

@@ -0,0 +1,143 @@
# DisplayFlow 构建系统说明
本文档详细说明 DisplayFlow 的构建系统配置。
## 1. 构建系统架构
DisplayFlow 使用 CMake 作为统一构建系统,采用模块化配置:
```
cmake/
├── Dependencies.cmake # 依赖管理
├── CompilerOptions.cmake # 编译器选项
├── Android.cmake # Android 平台配置
├── Windows.cmake # Windows 平台配置
└── Testing.cmake # 测试框架配置
```
## 2. 依赖管理
### 2.1 自动依赖下载
项目使用 CMake `FetchContent` 自动下载依赖:
- **FlatBuffers**: 自动从 GitHub 下载
- **Google Test**: 仅在 `BUILD_TESTS=ON` 时下载
### 2.2 系统依赖
可选使用系统已安装的依赖:
```bash
cmake .. -DUSE_SYSTEM_FLATBUFFERS=ON
```
### 2.3 vcpkg 支持
支持使用 vcpkg 管理依赖:
```bash
cmake .. -DCMAKE_TOOLCHAIN_FILE=[vcpkg]/scripts/buildsystems/vcpkg.cmake
```
## 3. 平台配置
### 3.1 Windows
- 自动检测 Visual Studio 版本
- 配置 Windows SDK
- 设置 Unicode 字符集
- 链接 DirectX 库
### 3.2 Android
- 配置 Android NDK
- 设置 Android API 级别
- 配置 ABIarm64-v8a, armeabi-v7a, x86, x86_64
- 链接 Android 系统库
## 4. 编译选项
### 4.1 C++ 标准
- 使用 C++17 标准
- 要求严格符合标准(`CMAKE_CXX_EXTENSIONS OFF`
### 4.2 警告级别
- **MSVC**: `/W4`(警告级别 4
- **GCC/Clang**: `-Wall -Wextra -Wpedantic`
### 4.3 优化选项
- **Debug**: 禁用优化,生成调试信息
- **Release**: 最高优化级别
## 5. 测试框架
### 5.1 Google Test
使用 Google Test 作为单元测试框架:
```cpp
#include <gtest/gtest.h>
TEST(MyTest, TestCase) {
EXPECT_EQ(1 + 1, 2);
}
```
### 5.2 运行测试
```bash
# 构建测试
cmake .. -DBUILD_TESTS=ON
cmake --build .
# 运行测试
ctest
```
## 6. 构建脚本
项目提供了便捷的构建脚本:
- `scripts/build.sh` (Linux/macOS)
- `scripts/build.bat` (Windows)
- `scripts/setup_dependencies.sh` (Linux/macOS)
- `scripts/setup_dependencies.bat` (Windows)
## 7. 输出目录结构
```
build/
├── bin/ # 可执行文件
├── lib/ # 库文件
└── tests/ # 测试输出
```
## 8. 常见配置
### 开发模式
```bash
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON
```
### 发布模式
```bash
cmake .. -DCMAKE_BUILD_TYPE=Release
```
### 启用所有功能
```bash
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=ON \
-DENABLE_VP8_CODEC=ON
```