Files
tsl-devkit/docs/cpp/toolchain.md
T
csh ac794a6a70 Squashed 'docs/standards/playbook/' changes from e504a68..b529012
b529012  test(tests): avoid hardcoded missing path
07583c8 🐛 fix(tests): make doc link check awk-portable
6244aa3 🔧 chore(ci): relax gitattributes check
31dd0c5 🐛 fix(scripts): require existing project root
15d4d63 🔧 chore(ci): install python3-pip
90c6313 🔧 chore(ci): run tests in a single job
d84eff0 🔧 chore(ci): make actions base url configurable
395598d 🔧 chore(ci): fix yaml step names
4ae2733  feat(sync_standards): auto-detect existing languages
e97fb00  feat(sync_standards): default gitattributes to append
da0ef2b  test: add automated tests and ci workflow
99bef30 🎨 style(markdown): format all markdown files with prettier
7e96bc8 ♻️ refactor(tsl): split function.md into 44 modular files
0d6b2a0 📝 docs(readme): add quick decision table and TL;DR for distribution methods
3b2188f 🎨 style(markdown): format markdown files with prettier
41fc43b 📝 docs(tsl): document {Unit.}Type source annotation
3dceaf7 📝 docs(tsl): clarify tsf-only top-level rules and type annotations
3a63829 📝 docs(skills): add create-plan skill
f02a707 🐛 fix(scripts): escape markdown backticks in vendor_playbook
064aa92 🐛 fix(scripts): correct bat scripts
4881feb 🔧 chore(gitattributes): enforce crlf for bat files
1fa3e2a 🐛 fix(scripts): escape parentheses in sync_standards output
3958cad 📝 docs(vendor_playbook): mention ci templates
9d059cf  feat(templates): add gitea ci example
a52bb24 📝 docs(codex_skills): normalize markdown formatting
cc8ad4c 📝 docs(skills): slim commit-message
2a98e15 🐛 fix(skills): quote YAML descriptions
8f78d22 🐛 fix(sync_standards): generate minimal AGENTS.md
5547665  feat(skills): add commit-message suggestion skill
3fe8bd7 🔧 chore(sync_standards): create AGENTS.md on sync
283d311  feat(playbook): add syntax book and codex skills tooling
5b97ed5 📝 docs(tsl): clarify syntax references
27e0700  feat(skills): add pdf/docx/pptx/xlsx wrapper workflows
5551363  feat(skills): add debugging and bulk refactor workflows
1d4f548  feat(skills): add built-in workflow skills
c0895dd 📝 docs(skills): add anthropics document-skills integration
cf9f80d 🔧 chore(playbook): add Claude Code skills guide and align python templates

git-subtree-dir: docs/standards/playbook
git-subtree-split: b529012c59c5d67c3073884d7b617763647417fd
2026-01-08 15:56:36 +08:00

3.5 KiB
Raw Blame History

C++ 工具链与验证命令(模板)

本文件提供一份通用占位模板,用于在不同 C++ 项目中快速补齐“工具链与如何验证”的关键上下文。

1. 工具链(必填)

1.1 编译器与标准

  • C++ 标准:C++23(含 Modules
  • 编译器:
    • 目标平台:Windows(通过 Linux 交叉编译)
    • 主机平台:Linux
    • 工具链:clang <版本>(交叉编译;具体 clang 可执行路径由 Conan profile 配置)
    • 目标三元组(示例):x86_64-w64-mingw32 / aarch64-w64-mingw32

1.2 构建系统

  • CMake>= 4.0
  • 生成器:
    • LinuxNinja

1.3 依赖管理(Conan,推荐)

若项目使用 Conan 管理三方依赖,建议:

  • Conan2.x(本 Playbook 假设 Conan 2;不保证 Conan 1 的兼容性)
  • 使用 conanfile.txt + CMakeDeps + CMakeToolchain + cmake_layout(参考 tsl-devkit/lsp-server/conanfile.txt)。
  • 通过 conan install 生成工具链与(可选)CMake Presets,再用 cmake --preset ... 构建。

1.4 格式化(必选)

  • clang-format<项目自选并固定版本>
  • 兼容性策略:
    • .clang-format 是唯一真相(推荐使用 templates/cpp/.clang-format 落地到项目根目录)。
    • 不同版本的 clang-format 可能对同一配置产生不同输出;项目应在 CI/开发环境中固定版本,避免格式漂移。
    • CI 推荐用 clang-format --dry-run --Werror <files...> 做格式校验。

1.5 静态检查(暂不启用)

  • clang-tidy:暂不启用(若未来启用,写明版本、配置文件与运行命令)

2. 验证命令(必填:把占位符替换成真实命令)

2.1 最小构建(必须能跑)

  • Conan 生成(推荐,示例):
    • CONAN_HOME=/tmp/conan-home conan install . -pr:b=conan/profiles/linux-x86_64-clang -pr:h=conan/profiles/windows-x86_64-clang-cross -of build/windows-x86_64-clang-cross --build=missing
  • 配置(示例):
    • cmake --preset conan-release
  • 构建(示例):
    • cmake --build --preset conan-release -j 8

2.2 运行冒烟(建议)

  • build/<app_or_tool> <args>
  • 或:cmake --build build -t run_smoke(如项目提供自定义 target

2.3 格式化检查(建议)

  • clang-format -i <files...>(本地)
  • clang-format --dry-run --Werror <files...>CI

2.4 失败处理约定(必填)

  • 只修复与本次改动直接相关的失败;无关失败记录并隔离。
  • 若某步骤无法执行(缺环境/缺权限),必须写出原因与替代验证(例如手动检查清单/最小复现工程)。

3. Presets(可选但强烈推荐)

参考 tsl-devkit 的做法:

  • CMakeUserPresets.json 纳入版本控制,并 include Conan 生成的 build/.../generators/CMakePresets.json
  • 优点:统一 Windows/Linux/macOS 构建入口;Agent 也更容易用固定命令验证。

本 Playbook 约定:

  • 强制统一 preset 名称conan-release / conan-debug(项目必须提供这两个 preset;实现方式不限:可由 Conan 生成,也可由项目自建 CMakePresets.json 适配)。
  • CMakeUserPresets.json 不是强制标准,仅作为一种推荐落地方式(模板见 templates/cpp/CMakeUserPresets.json)。

不在本 Playbook 中强制规定工具链分发方式(例如某种特定打包形态);只要求把交叉编译所需的 compiler_executables、triplet、system_name 等写进 Conan profile,保证命令可复现。