{"id":49744157,"url":"https://github.com/mcpp-community/mcpp","last_synced_at":"2026-05-30T02:01:28.250Z","repository":{"id":356541731,"uuid":"1230511039","full_name":"mcpp-community/mcpp","owner":"mcpp-community","description":"一个 现代C++ 模块化构建工具 — 纯 C++23 模块编写(已实现自举) - 模块化 + 依赖/工具链管理 + 包索引 + 打包发布","archived":false,"fork":false,"pushed_at":"2026-05-24T03:02:42.000Z","size":1204,"stargazers_count":21,"open_issues_count":3,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-24T03:13:18.318Z","etag":null,"topics":["build-tool","cpp","cpp23","mcpp","toolchain"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcpp-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-06T04:16:35.000Z","updated_at":"2026-05-24T01:45:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mcpp-community/mcpp","commit_stats":null,"previous_names":["mcpp-community/mcpp"],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/mcpp-community/mcpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpp-community%2Fmcpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpp-community%2Fmcpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpp-community%2Fmcpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpp-community%2Fmcpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcpp-community","download_url":"https://codeload.github.com/mcpp-community/mcpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpp-community%2Fmcpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33677261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-tool","cpp","cpp23","mcpp","toolchain"],"created_at":"2026-05-10T00:30:28.719Z","updated_at":"2026-05-30T02:01:28.237Z","avatar_url":"https://github.com/mcpp-community.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mcpp\n\n\u003e 一个 现代C++ 模块化构建工具 — 纯 C++23 模块编写，已实现自举\n\n[![Release](https://img.shields.io/github/v/release/mcpp-community/mcpp)](https://github.com/mcpp-community/mcpp/releases)\n[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)\n[![Module](https://img.shields.io/badge/module-ok-green.svg)](https://en.cppreference.com/w/cpp/language/modules)\n[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE)\n\n| [文档](docs/) · [快速开始](docs/00-getting-started.md) · [mcpp.toml 指南](docs/05-mcpp-toml.md) · [示例项目](docs/01-examples.md) · [工具链管理](docs/03-toolchains.md) |\n|:---:|\n| [包索引 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) |\n| [![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) |\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/6c85896e-9a37-4f62-acfb-d37a4eae2363\" alt=\"mcpp demo\" width=\"720\"\u003e\n\u003c/p\u003e\n\n## 核心特性\n\n- **C++23 模块原生支持** — `import std` 自动处理，文件级增量构建，模块依赖自动分析，零手动配置\n- **纯模块化自举** — mcpp 自身由 43+ 个 C++23 模块组成，用自己构建自己，模块系统经实战验证\n- **开箱即用** — 一条命令安装，内置 GCC 16 / LLVM 20 工具链，自动下载到隔离沙盒，不污染系统\n- **集成依赖管理** — SemVer 约束解析、锁文件、跨项目 BMI 缓存、自定义包索引\n- **多包工作空间** — Workspace 统一锁文件与版本管理，适合大型项目\n\n## 为什么选择 mcpp\n\nmcpp 专门为 **C++23 模块化开发** 打造。如果你想在项目中使用 `import std`、模块接口单元（`.cppm`）、模块分区等现代 C++ 特性，mcpp 在 Linux 和 macOS ARM64 上能为你提供便捷且友好的开发体验：\n\n- **默认模块化** — `mcpp new` 创建的项目模板直接使用 C++23 模块，`import std` 开箱即用\n- **文件级增量构建** — 基于 P1689 dyndep 的三层优化（前端脏检查 + 逐文件扫描 + BMI restat），只重编真正变化的模块\n- **一键创建 \u0026 构建** — `mcpp new hello \u0026\u0026 cd hello \u0026\u0026 mcpp build`，工具链自动安装，无需手动配置编译器和构建系统\n- **模块化生态** — [mcpplibs](https://github.com/mcpplibs) 提供一系列可直接 `import` 的 C++ 模块化库，支持自定义包索引\n\n\u003e [!NOTE]\n\u003e **早期版本** — mcpp 仍在积极开发中，接口和行为可能在后续版本调整。\n\u003e 欢迎对现代 C++ 模块化构建工具感兴趣的开发者[参与贡献](#参与贡献)。\n\u003e 问题 / 反馈 / 想法欢迎在 [issues](https://github.com/mcpp-community/mcpp/issues) 留言。\n\n## 快速开始\n\n### 安装\n\n**方式一：使用 xlings 安装（推荐）**\n\n```bash\nxlings install mcpp -y\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e还没有 xlings？点击查看安装命令\u003c/summary\u003e\n\n**Linux / macOS**\n```bash\ncurl -fsSL https://d2learn.org/xlings-install.sh | bash\n```\n\n**Windows — PowerShell**\n```powershell\nirm https://d2learn.org/xlings-install.ps1.txt | iex\n```\n\n\u003e xlings 详情 → [xlings.d2learn.org](https://xlings.d2learn.org)\n\n\u003c/details\u003e\n\n**方式二：一键安装脚本**\n\n```bash\ncurl -fsSL https://github.com/mcpp-community/mcpp/releases/latest/download/install.sh | bash\n```\n\n安装到 `~/.mcpp/`，自动加进 shell PATH。删除 `~/.mcpp` 即可干净卸载。\n\n**方式三：让 AI 助手帮你安装**\n\n将以下提示词复制给你的 AI 编码助手（Claude Code / Cursor / Copilot 等）：\n\n```\n阅读 https://github.com/mcpp-community/mcpp 的 README，\n帮我安装 mcpp 并创建一个 C++23 模块项目，构建并运行。\n项目的 .agents/skills/mcpp-usage/SKILL.md 有详细的使用指南。\n```\n\n### 创建项目 \u0026 构建运行\n\n```bash\nmcpp new hello\ncd hello\nmcpp build\nmcpp run\n```\n\n\u003e 注：首次构建会初始化环境并获取工具链，可能需要一些时间。\n\n### 项目结构\n\n```\nhello/\n├── mcpp.toml             ← 工程描述\n└── src/\n    └── main.cpp          ← import std; 直接可用\n```\n\n```toml\n# mcpp.toml\n[package]\nname = \"hello\"\n\n[targets.hello]\nkind = \"bin\"\nmain = \"src/main.cpp\"\n```\n\n### 使用模块化库\n\n在 `mcpp.toml` 中添加两行依赖，即可引用 [mcpplibs](https://github.com/mcpplibs) 社区模块化库：\n\n```toml\n[dependencies]\ncmdline = \"0.0.2\"\n```\n\n然后在代码中直接 `import`：\n\n```cpp\nimport mcpplibs.cmdline;\n```\n\n\u003e 更多依赖配置方式（版本约束、命名空间、Git 引用、本地路径等）参见 [mcpp.toml 指南 — 依赖管理](docs/05-mcpp-toml.md)。\n\n## 功能概览\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e构建系统\u003c/b\u003e\u003c/summary\u003e\n\n- C++20/23 模块原生支持（接口单元、实现单元、模块分区）\n- `import std` / `import std.compat` 全自动预编译与缓存\n- 三层增量优化：前端脏检查 + 逐文件 P1689 dyndep + BMI copy-if-different restat\n- 指纹化 BMI 缓存：按编译器/标志/标准库哈希，跨项目共享\n- Ninja 后端：自动生成 build.ninja，并行编译\n- compile_commands.json 自动生成（clangd / ccls 即用）\n- C 语言一等支持：`.c` 文件自动检测，混合 C/C++ 项目\n- 用户自定义 cflags / cxxflags / c_standard\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e工具链管理\u003c/b\u003e\u003c/summary\u003e\n\n- 内置 GCC 16.1.0 + LLVM/Clang 20.1.7，一键安装\n- musl-gcc 全静态工具链（默认）\n- 多版本共存：`mcpp toolchain install gcc 16` / `mcpp toolchain install llvm 20`\n- 隔离沙盒：所有工具链在 `~/.mcpp/registry/`，不影响系统\n- 按平台指定：`linux = \"gcc@16\"`, `macos = \"llvm@20\"`\n- GCC + Clang 编译管线平权（`BmiTraits` 抽象层驱动）\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e包管理与依赖\u003c/b\u003e\u003c/summary\u003e\n\n- SemVer 约束解析：`^`、`~`、范围、精确版本\n- 三级解析：约束合并 → 多版本 mangling 回退 → 精确匹配\n- 锁文件 mcpp.lock（v2 格式：索引快照 + 命名空间）\n- 命名空间系统：`[dependencies.myteam] foo = \"1.0\"`\n- 自定义包索引：`[indices] acme = \"git@...\"` / `{ path = \"...\" }`\n- 项目级索引隔离（`.mcpp/` 目录，不污染全局）\n- 依赖来源：索引 / Git / 本地路径\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e工作空间\u003c/b\u003e\u003c/summary\u003e\n\n- `[workspace] members = [\"libs/*\", \"apps/*\"]`\n- 统一锁文件 + 统一 target 目录\n- 版本集中管理：`[workspace.dependencies]` + `.workspace = true`\n- 选择性构建：`mcpp build -p member-name`\n- 配置继承：工具链、构建标志、索引从根级联到成员\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e打包与发布\u003c/b\u003e\u003c/summary\u003e\n\n- `mcpp pack`：三种 Linux 发布模式 — static（musl全静态）/ bundle-project / bundle-all\n- musl 全静态二进制：单文件可分发，无 glibc 依赖（Linux x86_64）\n- `mcpp publish`：生成 xpkg.lua + 发布到包索引\n- 自动 patchelf 修正 RPATH（Linux）\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e开发体验\u003c/b\u003e\u003c/summary\u003e\n\n- `mcpp new` — 创建模块化项目模板\n- `mcpp run [-- args]` — 构建并运行\n- `mcpp test [-- args]` — 自动发现并运行测试\n- `mcpp search` — 搜索包索引\n- `mcpp add / remove / update` — 依赖管理\n- `mcpp explain E0001` — 错误码详细解释\n- `mcpp self doctor` — 环境自诊断\n\n\u003c/details\u003e\n\n## 平台支持\n\n| OS / arch        | GCC (glibc) | GCC (musl) | Clang / LLVM | MSVC |\n|------------------|:-----------:|:----------:|:------------:|:----:|\n| Linux x86_64     | ✅ | ✅ *默认* | ✅ | — |\n| Linux aarch64    | 🔄 | 🔄 | 🔄 | — |\n| macOS arm64      | — | — | ✅ *默认* | — |\n| macOS x86_64     | — | — | 🔄 | — |\n| Windows x86_64   | — | — | ✅ ¹ *默认* | 🔄 |\n\n✅ 已支持 ｜ 🔄 计划中\n\n\u003e *默认*：Linux 默认工具链为 musl-gcc,release 二进制走 musl 全静态；\n\u003e macOS ARM64 / Windows x86_64 默认工具链均为 LLVM/Clang。\n\u003e\n\u003e ¹ Windows 上 Clang/LLVM 当前依赖系统已安装 **MSVC BuildTools 或 Visual Studio**\n\u003e （提供 UCRT、Windows SDK、MSVC STL）。零-MSVC 依赖的 `llvm-mingw` 路线在规划中\n\u003e ([讨论](https://github.com/mcpp-community/mcpp/issues))。\n\n## 文档\n\n- [快速开始](docs/00-getting-started.md) — 5 分钟完成 install → new → build → run\n- [示例项目](docs/01-examples.md)\n- [发布打包](docs/02-pack-and-release.md)\n- [工具链管理](docs/03-toolchains.md)\n- [从源码构建](docs/04-build-from-source.md)\n- [mcpp.toml 指南](docs/05-mcpp-toml.md)\n- [工作空间](docs/06-workspace.md)\n\n任意命令的完整选项可通过 `mcpp \u003ccmd\u003e --help` 查阅。\n\n**AI 辅助学习**：你可以将以下提示词发给 AI 编码助手，让它帮你快速了解 mcpp：\n\n```\n阅读 https://github.com/mcpp-community/mcpp 仓库的\n.agents/skills/mcpp-usage/SKILL.md 和 docs/ 目录下的文档，\n告诉我如何用 mcpp 创建一个带依赖的 C++23 模块项目。\n```\n\n## 参与贡献\n\n欢迎通过 Issue 和 PR 参与项目开发。项目接受开发者使用 AI Agent 参与开发与贡献。\n\n**基本流程**\n\n1. 创建 Issue — Bug 修复、新功能、优化等，先在 [issues](https://github.com/mcpp-community/mcpp/issues) 创建讨论\n2. 实现改动 — Fork 仓库，创建分支，实现并验证（`mcpp build` + E2E 测试）\n3. 提交 PR — 使用 `gh pr create`，确保 CI 通过\n4. CI 必须通过 — CI 不通过的 PR 不会被合入\n\n**提交信息规范**：`feat:` / `fix:` / `test:` / `docs:` / `refactor:` 前缀\n\n**AI Agent 贡献**：项目的 [`.agents/skills/mcpp-contributing/SKILL.md`](.agents/skills/mcpp-contributing/SKILL.md) 提供了完整的 Agent 贡献流程和项目结构说明。将以下提示词发给 AI 助手即可：\n\n```\n阅读 https://github.com/mcpp-community/mcpp 仓库的\n.agents/skills/mcpp-contributing/SKILL.md，\n按照指南帮我给 mcpp 项目提交一个贡献。\n```\n\n## 社区 \u0026 生态\n\n- [社区论坛](https://forum.d2learn.org/category/20) — 交流群 (Q: 1067245099)\n- [mcpp-index](https://github.com/mcpp-community/mcpp-index) — 默认包索引\n- [mcpplibs](https://github.com/mcpplibs) — 模块化 C++ 库集合\n\n### 致谢\n\n项目依赖和灵感来源：\n\n- [xlings](https://github.com/d2learn/xlings) — 工具链 / 包管理底座\n- [mcpplibs.cmdline](https://github.com/mcpplibs/cmdline) — CLI 框架\n- [ninja](https://github.com/ninja-build/ninja) — 底层构建引擎\n- [xmake](https://github.com/xmake-io/xmake) — 跨平台构建工具\n- [cargo](https://github.com/rust-lang/cargo) — Rust 包管理器\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcpp-community%2Fmcpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcpp-community%2Fmcpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcpp-community%2Fmcpp/lists"}