Skip to content

Commit 6c1663f

Browse files
committed
docs: add English docs as default language; move Chinese to docs/zh + README.zh-CN
- README.md and docs/ are now English (international default) - Chinese moved to README.zh-CN.md and docs/zh/, content unchanged - Language switch links (English | 简体中文) at the top of both READMEs and both docs indices - Fixed parent-relative links in docs/zh (one level deeper) and the README install anchor in docs/00 - Added missing 06-workspace entry to both docs indices - Existing docs/*.md links from src/, skills, and CHANGELOG keep resolving (English now lives at the original paths)
1 parent dc530f4 commit 6c1663f

18 files changed

Lines changed: 2139 additions & 617 deletions

README.md

Lines changed: 130 additions & 128 deletions
Large diffs are not rendered by default.

README.zh-CN.md

Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
# mcpp
2+
3+
> 一个 现代C++ 模块化构建工具 — 纯 C++23 模块编写,已实现自举
4+
5+
[English](README.md) | **简体中文**
6+
7+
[![Release](https://img.shields.io/github/v/release/mcpp-community/mcpp)](https://github.com/mcpp-community/mcpp/releases)
8+
[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)
9+
[![Module](https://img.shields.io/badge/module-ok-green.svg)](https://en.cppreference.com/w/cpp/language/modules)
10+
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE)
11+
12+
| [文档](docs/zh/) · [快速开始](docs/zh/00-getting-started.md) · [mcpp.toml 指南](docs/zh/05-mcpp-toml.md) · [示例项目](docs/zh/01-examples.md) · [工具链管理](docs/zh/03-toolchains.md) |
13+
|:---:|
14+
| [包索引 mcpp-index](https://github.com/mcpp-community/mcpp-index) · [模块化库 mcpplibs](https://github.com/mcpplibs) · [社区论坛](https://forum.d2learn.org/category/20) · [Issues](https://github.com/mcpp-community/mcpp/issues) · [Releases](https://github.com/mcpp-community/mcpp/releases) |
15+
| [![ci-linux](https://github.com/mcpp-community/mcpp/actions/workflows/ci-linux.yml/badge.svg?branch=main)](https://github.com/mcpp-community/mcpp/actions/workflows/ci-linux.yml) [![ci-macos](https://github.com/mcpp-community/mcpp/actions/workflows/ci-macos.yml/badge.svg?branch=main)](https://github.com/mcpp-community/mcpp/actions/workflows/ci-macos.yml) [![ci-windows](https://github.com/mcpp-community/mcpp/actions/workflows/ci-windows.yml/badge.svg?branch=main)](https://github.com/mcpp-community/mcpp/actions/workflows/ci-windows.yml) |
16+
17+
<p align="center">
18+
<img src="https://github.com/user-attachments/assets/6c85896e-9a37-4f62-acfb-d37a4eae2363" alt="mcpp demo" width="720">
19+
</p>
20+
21+
## 核心特性
22+
23+
- **C++23 模块原生支持**`import std` 自动处理,文件级增量构建,模块依赖自动分析,零手动配置
24+
- **纯模块化自举** — mcpp 自身由 43+ 个 C++23 模块组成,用自己构建自己,模块系统经实战验证
25+
- **开箱即用** — 一条命令安装,内置 GCC 16 / LLVM 20 工具链,自动下载到隔离沙盒,不污染系统
26+
- **集成依赖管理** — SemVer 约束解析、锁文件、跨项目 BMI 缓存、自定义包索引
27+
- **多包工作空间** — Workspace 统一锁文件与版本管理,适合大型项目
28+
29+
## 为什么选择 mcpp
30+
31+
mcpp 专门为 **C++23 模块化开发** 打造。如果你想在项目中使用 `import std`、模块接口单元(`.cppm`)、模块分区等现代 C++ 特性,mcpp 在 Linux 和 macOS ARM64 上能为你提供便捷且友好的开发体验:
32+
33+
- **默认模块化**`mcpp new` 创建的项目模板直接使用 C++23 模块,`import std` 开箱即用
34+
- **文件级增量构建** — 基于 P1689 dyndep 的三层优化(前端脏检查 + 逐文件扫描 + BMI restat),只重编真正变化的模块
35+
- **一键创建 & 构建**`mcpp new hello && cd hello && mcpp build`,工具链自动安装,无需手动配置编译器和构建系统
36+
- **模块化生态**[mcpplibs](https://github.com/mcpplibs) 提供一系列可直接 `import` 的 C++ 模块化库,支持自定义包索引
37+
38+
> [!NOTE]
39+
> **早期版本** — mcpp 仍在积极开发中,接口和行为可能在后续版本调整。
40+
> 欢迎对现代 C++ 模块化构建工具感兴趣的开发者[参与贡献](#参与贡献)
41+
> 问题 / 反馈 / 想法欢迎在 [issues](https://github.com/mcpp-community/mcpp/issues) 留言。
42+
43+
## 快速开始
44+
45+
### 安装
46+
47+
**方式一:使用 xlings 安装(推荐)**
48+
49+
```bash
50+
xlings install mcpp -y
51+
```
52+
53+
<details>
54+
<summary>还没有 xlings?点击查看安装命令</summary>
55+
56+
**Linux / macOS**
57+
```bash
58+
curl -fsSL https://d2learn.org/xlings-install.sh | bash
59+
```
60+
61+
**Windows — PowerShell**
62+
```powershell
63+
irm https://d2learn.org/xlings-install.ps1.txt | iex
64+
```
65+
66+
> xlings 详情 → [xlings.d2learn.org](https://xlings.d2learn.org)
67+
68+
</details>
69+
70+
**方式二:一键安装脚本**
71+
72+
```bash
73+
curl -fsSL https://github.com/mcpp-community/mcpp/releases/latest/download/install.sh | bash
74+
```
75+
76+
安装到 `~/.mcpp/`,自动加进 shell PATH。删除 `~/.mcpp` 即可干净卸载。
77+
78+
**方式三:让 AI 助手帮你安装**
79+
80+
将以下提示词复制给你的 AI 编码助手(Claude Code / Cursor / Copilot 等):
81+
82+
```
83+
阅读 https://github.com/mcpp-community/mcpp 的 README,
84+
帮我安装 mcpp 并创建一个 C++23 模块项目,构建并运行。
85+
项目的 .agents/skills/mcpp-usage/SKILL.md 有详细的使用指南。
86+
```
87+
88+
### 创建项目 & 构建运行
89+
90+
```bash
91+
mcpp new hello
92+
cd hello
93+
mcpp build
94+
mcpp run
95+
```
96+
97+
> 注:首次构建会初始化环境并获取工具链,可能需要一些时间。
98+
99+
### 项目结构
100+
101+
```
102+
hello/
103+
├── mcpp.toml ← 工程描述
104+
└── src/
105+
└── main.cpp ← import std; 直接可用
106+
```
107+
108+
```toml
109+
# mcpp.toml
110+
[package]
111+
name = "hello"
112+
113+
[targets.hello]
114+
kind = "bin"
115+
main = "src/main.cpp"
116+
```
117+
118+
### 使用模块化库
119+
120+
`mcpp.toml` 中添加两行依赖,即可引用 [mcpplibs](https://github.com/mcpplibs) 社区模块化库:
121+
122+
```toml
123+
[dependencies]
124+
cmdline = "0.0.2"
125+
```
126+
127+
然后在代码中直接 `import`
128+
129+
```cpp
130+
import mcpplibs.cmdline;
131+
```
132+
133+
> 更多依赖配置方式(版本约束、命名空间、Git 引用、本地路径等)参见 [mcpp.toml 指南 — 依赖管理](docs/zh/05-mcpp-toml.md)
134+
135+
## 功能概览
136+
137+
<details>
138+
<summary><b>构建系统</b></summary>
139+
140+
- C++20/23 模块原生支持(接口单元、实现单元、模块分区)
141+
- `import std` / `import std.compat` 全自动预编译与缓存
142+
- 三层增量优化:前端脏检查 + 逐文件 P1689 dyndep + BMI copy-if-different restat
143+
- 指纹化 BMI 缓存:按编译器/标志/标准库哈希,跨项目共享
144+
- Ninja 后端:自动生成 build.ninja,并行编译
145+
- compile_commands.json 自动生成(clangd / ccls 即用)
146+
- C 语言一等支持:`.c` 文件自动检测,混合 C/C++ 项目
147+
- 用户自定义 cflags / cxxflags / ldflags / c_standard
148+
149+
</details>
150+
151+
<details>
152+
<summary><b>工具链管理</b></summary>
153+
154+
- 内置 GCC 16.1.0 + LLVM/Clang 20.1.7,一键安装
155+
- musl-gcc 全静态工具链(默认)
156+
- 多版本共存:`mcpp toolchain install gcc 16` / `mcpp toolchain install llvm 20`
157+
- 隔离沙盒:所有工具链在 `~/.mcpp/registry/`,不影响系统
158+
- 按平台指定:`linux = "gcc@16"`, `macos = "llvm@20"`
159+
- GCC + Clang 编译管线平权(`BmiTraits` 抽象层驱动)
160+
161+
</details>
162+
163+
<details>
164+
<summary><b>包管理与依赖</b></summary>
165+
166+
- SemVer 约束解析:`^``~`、范围、精确版本
167+
- 三级解析:约束合并 → 多版本 mangling 回退 → 精确匹配
168+
- 锁文件 mcpp.lock(v2 格式:索引快照 + 命名空间)
169+
- 命名空间系统:`[dependencies.myteam] foo = "1.0"`
170+
- 自定义包索引:`[indices] acme = "git@..."` / `{ path = "..." }`
171+
- 项目级索引隔离(`.mcpp/` 目录,不污染全局)
172+
- 依赖来源:索引 / Git / 本地路径
173+
174+
</details>
175+
176+
<details>
177+
<summary><b>工作空间</b></summary>
178+
179+
- `[workspace] members = ["libs/*", "apps/*"]`
180+
- 统一锁文件 + 统一 target 目录
181+
- 版本集中管理:`[workspace.dependencies]` + `.workspace = true`
182+
- 选择性构建:`mcpp build -p member-name`
183+
- 配置继承:工具链、构建标志、索引从根级联到成员
184+
185+
</details>
186+
187+
<details>
188+
<summary><b>打包与发布</b></summary>
189+
190+
- `mcpp pack`:三种 Linux 发布模式 — static(musl全静态)/ bundle-project / bundle-all
191+
- musl 全静态二进制:单文件可分发,无 glibc 依赖(Linux x86_64)
192+
- `mcpp publish`:生成 xpkg.lua + 发布到包索引
193+
- 自动 patchelf 修正 RPATH(Linux)
194+
195+
</details>
196+
197+
<details>
198+
<summary><b>开发体验</b></summary>
199+
200+
- `mcpp new` — 创建模块化项目;`--template <pkg>[@ver][:<tmpl>]` 使用**库自带模板**(如 `--template imgui`),`--list-templates <pkg>` 列举
201+
- `mcpp run [-- args]` — 构建并运行
202+
- `mcpp test [-- args]` — 自动发现并运行测试
203+
- `mcpp search` — 搜索包索引
204+
- `mcpp add / remove / update` — 依赖管理
205+
- `mcpp explain E0001` — 错误码详细解释
206+
- `mcpp self doctor` — 环境自诊断
207+
208+
</details>
209+
210+
## 平台支持
211+
212+
| OS / arch | GCC (glibc) | GCC (musl) | Clang / LLVM | MSVC |
213+
|------------------|:-----------:|:----------:|:------------:|:----:|
214+
| Linux x86_64 ||*默认* |||
215+
| Linux aarch64 | 🔄 | 🔄 | 🔄 ||
216+
| macOS arm64 |||*默认* ||
217+
| macOS x86_64 ||| 🔄 ||
218+
| Windows x86_64 ||| ✅ ¹ *默认* | 🔄 |
219+
220+
✅ 已支持 | 🔄 计划中
221+
222+
> *默认*:Linux 默认工具链为 musl-gcc,release 二进制走 musl 全静态;
223+
> macOS ARM64 / Windows x86_64 默认工具链均为 LLVM/Clang。
224+
>
225+
> ¹ Windows 上 Clang/LLVM 当前依赖系统已安装 **MSVC BuildTools 或 Visual Studio**
226+
> (提供 UCRT、Windows SDK、MSVC STL)。零-MSVC 依赖的 `llvm-mingw` 路线在规划中
227+
> ([讨论](https://github.com/mcpp-community/mcpp/issues))。
228+
229+
## 文档
230+
231+
- [快速开始](docs/zh/00-getting-started.md) — 5 分钟完成 install → new → build → run
232+
- [示例项目](docs/zh/01-examples.md)
233+
- [发布打包](docs/zh/02-pack-and-release.md)
234+
- [工具链管理](docs/zh/03-toolchains.md)
235+
- [从源码构建](docs/zh/04-build-from-source.md)
236+
- [mcpp.toml 指南](docs/zh/05-mcpp-toml.md)
237+
- [工作空间](docs/zh/06-workspace.md)
238+
239+
任意命令的完整选项可通过 `mcpp <cmd> --help` 查阅。
240+
241+
**AI 辅助学习**:你可以将以下提示词发给 AI 编码助手,让它帮你快速了解 mcpp:
242+
243+
```
244+
阅读 https://github.com/mcpp-community/mcpp 仓库的
245+
.agents/skills/mcpp-usage/SKILL.md 和 docs/ 目录下的文档,
246+
告诉我如何用 mcpp 创建一个带依赖的 C++23 模块项目。
247+
```
248+
249+
## 参与贡献
250+
251+
欢迎通过 Issue 和 PR 参与项目开发。项目接受开发者使用 AI Agent 参与开发与贡献。
252+
253+
**基本流程**
254+
255+
1. 创建 Issue — Bug 修复、新功能、优化等,先在 [issues](https://github.com/mcpp-community/mcpp/issues) 创建讨论
256+
2. 实现改动 — Fork 仓库,创建分支,实现并验证(`mcpp build` + E2E 测试)
257+
3. 提交 PR — 使用 `gh pr create`,确保 CI 通过
258+
4. CI 必须通过 — CI 不通过的 PR 不会被合入
259+
260+
**提交信息规范**`feat:` / `fix:` / `test:` / `docs:` / `refactor:` 前缀
261+
262+
**AI Agent 贡献**:项目的 [`.agents/skills/mcpp-contributing/SKILL.md`](.agents/skills/mcpp-contributing/SKILL.md) 提供了完整的 Agent 贡献流程和项目结构说明。将以下提示词发给 AI 助手即可:
263+
264+
```
265+
阅读 https://github.com/mcpp-community/mcpp 仓库的
266+
.agents/skills/mcpp-contributing/SKILL.md,
267+
按照指南帮我给 mcpp 项目提交一个贡献。
268+
```
269+
270+
## 社区 & 生态
271+
272+
- [社区论坛](https://forum.d2learn.org/category/20) — 交流群 (Q: 1067245099)
273+
- [mcpp-index](https://github.com/mcpp-community/mcpp-index) — 默认包索引
274+
- [mcpplibs](https://github.com/mcpplibs) — 模块化 C++ 库集合
275+
276+
### 致谢
277+
278+
项目依赖和灵感来源:
279+
280+
- [xlings](https://github.com/d2learn/xlings) — 工具链 / 包管理底座
281+
- [mcpplibs.cmdline](https://github.com/mcpplibs/cmdline) — CLI 框架
282+
- [ninja](https://github.com/ninja-build/ninja) — 底层构建引擎
283+
- [xmake](https://github.com/xmake-io/xmake) — 跨平台构建工具
284+
- [cargo](https://github.com/rust-lang/cargo) — Rust 包管理器

0 commit comments

Comments
 (0)