Skip to content

Commit 08a0d45

Browse files
committed
Workspace build graph: members' dependencies announced, the module-name limit documented
1 parent 687e154 commit 08a0d45

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎.agents/docs/2026-09-29-workspace-build-graph-design.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ left open, the answer is recorded here.
517517
| The lock | `<workspace>/mcpp.lock`. A plan of all members writes the whole record; a plan of some keeps the other entries, and `--locked` then reports no entry of another member as drift. A selected member's git dependencies are locked as a root's. | prepare/records.cpp |
518518
| Tests | `mcpp test` keeps one plan per member (`-p X` each), in the shared directory; the members' dev-dependencies are their own. | cmd_build.cppm |
519519
| Concurrency | Groups are planned in turn and built on threads with a static share of the jobs; the `.build_cache` write is one locked step. | cmd_build.cppm |
520+
| Module names across members | A graph has one module namespace (BMIs are found by name), so two members that each provide a module of one name are refused in one `--workspace` plan, as two `artifacts` programs are (#732, which tracks per-provider BMI names). Measured over the package index's 172 members: no module name is provided twice. | scanner |
520521

521522
Readings with the implementation (Linux, llvm 22.1.8):
522523

‎docs/07-workspace.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ member that several members use is compiled once.
438438
member order.
439439
- **No-op builds.** A command repeated with nothing changed is answered by one
440440
check per configuration, without planning.
441+
- **Module names.** Members built in one graph share one module namespace:
442+
two members that each provide a module of the same name cannot be built in
443+
one `--workspace` command; build each with `-p`.
441444

442445
## 6. Directory Layout
443446

‎docs/zh/07-workspace.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ mcpp test --workspace --workspace-timeout 1800 # whole fan-out (default 0 = no
405405
命令被拒绝。
406406
- **Hooks。** 每个被选成员的 `[hooks]` 按成员顺序在构建前后运行。
407407
- **无事可做的构建。** 在没有任何改动时重复执行的命令,每个配置只做一次检查,不重新规划。
408+
- **模块名。** 在同一张图中构建的成员共享一个模块命名空间:两个成员各自提供同名模块时,不能在
409+
同一条 `--workspace` 命令中构建;分别用 `-p` 构建。
408410

409411
## 6. 目录布局
410412

‎src/build/execute.cppm‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,22 @@ export int run_build_plan(BuildContext& ctx, bool verbose, bool no_cache,
941941
mcpp::ui::status("Compiling",
942942
std::format("{} v{} (.)",
943943
ctx.manifest.package.name, ctx.manifest.package.version));
944-
for (auto& [name, spec] : ctx.manifest.dependencies) {
944+
// The packages announced: the root's dependencies, and in a workspace
945+
// plan each member followed by the member's own dependencies (§15), as
946+
// the member's own build announced them.
947+
std::vector<std::pair<std::string, mcpp::manifest::DependencySpec>> announcedDeps;
948+
for (auto const& [name, spec] : ctx.manifest.dependencies) {
949+
announcedDeps.emplace_back(name, spec);
950+
if (!spec.workspaceMember) continue;
951+
for (auto const& m : ctx.workspaceMembers) {
952+
std::error_code e1, e2;
953+
if (std::filesystem::weakly_canonical(spec.path, e1)
954+
!= std::filesystem::weakly_canonical(m.root, e2))
955+
continue;
956+
for (auto const& [dn, ds] : m.manifest.dependencies) announcedDeps.emplace_back(dn, ds);
957+
}
958+
}
959+
for (auto& [name, spec] : announcedDeps) {
945960
if (announced.contains(name)) continue;
946961
announced.insert(name);
947962
// Two keys that resolved to one identity (#634, A2) are one package

0 commit comments

Comments
 (0)