Skip to content

feat(build): build.mcpp 补全 — 环境契约 + cross 下运行 + 依赖包执行 (0.0.95)#222

Merged
Sunrisepeak merged 1 commit into
mainfrom
feat/build-mcpp-completion
Jul 17, 2026
Merged

feat(build): build.mcpp 补全 — 环境契约 + cross 下运行 + 依赖包执行 (0.0.95)#222
Sunrisepeak merged 1 commit into
mainfrom
feat/build-mcpp-completion

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

概要

G1–G9 方案的 PR-C(终 PR,叠在 #221 之上;A→B→C 依次合入后自动 retarget)。携带版本 bump 0.0.95——本 PR 合入 = 触发 0.0.95 发布链(release.yml → publish-ecosystem → fresh-install → bootstrap pin)。

内容(G3 + G2)

G3 — 环境契约 + cross 下运行

  • 注入 MCPP_TARGET / MCPP_HOST / MCPP_PROFILE / MCPP_OUT_DIR / MCPP_MANIFEST_DIR / MCPP_FEATURE_<NAME> / MCPP_FEATURES(仅子进程);typed import mcpp; 模块补对应读取端 target()/host()/profile()/out_dir()/manifest_dir()/has_feature()
  • 契约值无条件折入重跑键(cache 新增 ctx 行)——换 target/profile/开关 feature 必重跑,不依赖作者写 rerun-if-env-changed;旧格式缓存自动失效一次
  • cross --target 不再跳过:宿主工具链按同一 spec 词汇独立解析(不注入 target 轴),懒解析、仅当 build.mcpp 存在;程序在宿主编译运行,看到 MCPP_TARGET = 交叉三元组
  • 三处重复的 feature 闭包收敛为单一 feature_closure;--features 解析共享化

G2 — 依赖包 build.mcpp(Cargo build.rs 模型)

  • 时机:该依赖 feature 激活后、modgraph 扫描前;作用域照 Cargo:cfg/flags 只进该包自身 TU(镜像进 privateBuild,与 MCPP_FEATURE_ 宏同款),link-lib/link-search 达终链
  • 产物全部项目本地化:<project>/target/.build-mcpp/deps/<pkg>@<ver>/;registry 共享包根绝不写入(e2e 以 find 快照锁零写入);相对 generated=MCPP_OUT_DIR 为基,scanner 支持绝对路径字面源条目
  • 信任模型显式声明(docs):构建依赖 = 执行其 build.mcpp,与 build.rs 同级
  • 顺修潜在盲区:generated= 此前只推 bc.sources 而 scanner 走 modules.sources 镜像(靠默认 glob 兜住)——现在双推

测试

  • e2e 110:契约值断言(host 三元组/profile)、同构建不重跑、--features/--release 触发重跑且程序观察到新值
  • e2e 111:dep 作用域(define 不泄漏消费者 TU,#error 双向锁)、OUT_DIR 生成源入编译、dep 根目录 find 快照零写入
  • e2e 112(requires mingw-cross):cross 下真跑、MCPP_TARGET=x86_64-windows-gnu 烙进生成源、PE 产物 wine 真跑验证
  • 全量:单测 35/35,e2e 112 过 / 3 失败(22/54/62 既有环境性)/ 5 跳;release.yml 冒烟会断言 --version == mcpp.toml == 0.0.95

合入后

走一次发布链:tag → release.yml 四平台 → publish-ecosystem(镜像 xlings-res 双端 + xim-pkgindex bump PR)→ fresh-install 验证 → workspace bootstrap pin bump;随后 mcpp-index 侧解锁项见设计文档 §4.4。

@Sunrisepeak
Sunrisepeak force-pushed the feat/declarative-manifest branch 2 times, most recently from 5eb3162 to 7582cd9 Compare July 17, 2026 12:06
@Sunrisepeak
Sunrisepeak force-pushed the feat/build-mcpp-completion branch from 4b1a62a to 5e1bce9 Compare July 17, 2026 12:07
@Sunrisepeak
Sunrisepeak force-pushed the feat/declarative-manifest branch from 7582cd9 to f10b2eb Compare July 17, 2026 12:27
@Sunrisepeak
Sunrisepeak force-pushed the feat/build-mcpp-completion branch from 5e1bce9 to 4436403 Compare July 17, 2026 12:27
@Sunrisepeak
Sunrisepeak changed the base branch from feat/declarative-manifest to main July 17, 2026 12:45
设计: .agents/docs/2026-07-17-asm-sources-and-general-build-capabilities-design.md (PR-C)

G3 环境契约 + cross:
- 注入 MCPP_TARGET/HOST/PROFILE/OUT_DIR/MANIFEST_DIR/MCPP_FEATURE_<NAME>/
  MCPP_FEATURES(仅子进程,capture_exec env);契约值无条件折入重跑键
  (cache 新增 ctx 行,旧缓存缺行自动失效一次)
- cross --target 不再跳过:宿主工具链按同一 spec 词汇独立解析(不注入
  target 轴),懒解析且仅当存在 build.mcpp;typed `import mcpp;` 模块补
  读取端 target()/host()/profile()/out_dir()/manifest_dir()/has_feature()
- feature 闭包收敛为单一 feature_closure 实现(原三处重复);profile 名提升
  为 effectiveProfile 供契约使用;--features 解析共享 parse_feature_request

G2 依赖包 build.mcpp(Cargo build.rs 模型):
- 时机:feature 激活后、modgraph 扫描前;作用域照 Cargo:cfg/flags 只进该包
  自身 TU(镜像进 privateBuild,与 MCPP_FEATURE_ 宏同款),link 指令补传终链
  (BFS 传播已过,追加新尾部)
- 产物全部项目本地化:target/.build-mcpp/deps/<pkg>@<ver>/,registry 包根
  绝不写入;相对 generated= 以 OUT_DIR 为基;scanner 支持绝对路径字面源条目
- 顺修潜在盲区:generated= 只推 bc.sources,scanner 走 modules.sources 镜像
  ——现在双推(此前靠默认 glob 兜住)

版本 bump 0.0.95(mcpp.toml + fingerprint.cppm 同步);docs/07 中英补契约与
依赖节;e2e 110(契约值/缓存/feature+profile 重跑)/111(dep 作用域/终链/
registry 零写入)/112(cross + wine 全环);单测 35/35,e2e 112 过(3 失败
均既有环境性 22/54/62)
@Sunrisepeak
Sunrisepeak force-pushed the feat/build-mcpp-completion branch from 4436403 to 8e3fd3a Compare July 17, 2026 12:46
@Sunrisepeak
Sunrisepeak merged commit 33f0acd into main Jul 17, 2026
7 checks passed
@Sunrisepeak
Sunrisepeak deleted the feat/build-mcpp-completion branch July 17, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant