feat(build): L3 build.mcpp — native imperative build program (v0.0.78)#190
Merged
Conversation
A project-local build.mcpp (C++, Zig build.zig / Cargo build.rs model) compiled with the host toolchain and run before the main build. It emits stdout mcpp: directives that augment the build; a declared-input cache re-runs it only when its source/inputs/env change (the documented fix for the .mcpp_ok blind spot). - src/build/build_program.cppm: new module — compile+run, directive parser (cxxflag/cflag/link-lib/link-search/cfg/generated/rerun-if-changed/ rerun-if-env-changed), declared-input cache, apply to buildConfig - prepare.cppm: invoke after toolchain detect + L1 cfg merge, before modgraph scan; skipped under cross --target (host build/run). -x c++ so the .mcpp extension compiles as C++ - tests/e2e/89_build_mcpp.sh: define+generated source reach the build; cache short-circuits unchanged re-run; changed env forces re-run - docs/07-build-mcpp.md (+zh): user guide; design doc + version bump 0.0.78 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CI e2e (fresh sandbox) failed compiling build.mcpp: a bare 'g++ file -o bin' can't find crt/libc without the toolchain sysroot wiring the main build adds (it works only on warm dev boxes). Pass the host subset from the resolved Toolchain (host_base_flags): GCC --sysroot (or glibc-payload -idirafter/-B/-L), binutils -B, link-runtime -L/-rpath; Clang trusts its .cfg. Mirrors flags.cppm's GCC branch (build.mcpp is host-only, so only native cases needed). Also move build.mcpp's binary + declared-input cache to target/.build-mcpp/ (per project direction: artifacts under target/, not the project tree). design doc: host-flags rationale + typed import mcpp; library direction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
build.mcpp— a project-local native imperative build program (Zigbuild.zig/ Cargobuild.rsmodel, but in C++, so no second language and it dogfoods mcpp). mcpp compiles it with the host toolchain and runs it before the main build; it emits stdoutmcpp:directives that augment the build.This completes the manifest-environment/platform design's L3 phase (after L1 cfg flags 0.0.74, L1b cfg deps 0.0.75, L-1
[xlings]env 0.0.77).Directives (Discipline 1 — structured output, not global mutation)
cxxflag/cflag/link-lib/link-search/cfg(→-D) /generated=<src>/rerun-if-changed=<path>/rerun-if-env-changed=<VAR>. Non-mcpp:lines are ignored. The program requests leaf build edges; it cannot add a registry dependency (the graph stays declarative inmcpp.toml).Declared-input cache (Discipline 2 — fixes the
.mcpp_okblind spot)The program is not re-run every build. Its directives + declared inputs are cached at
.mcpp/build.mcpp.cache; it re-runs only when the source, toolchain, a declaredrerun-if-changedfile, a declaredrerun-if-env-changedvar, or a missinggeneratedoutput says so. Applied directives flow intobuildConfig.{c,cxx,ld}flags→ fingerprint and generated sources → modgraph, so the main build stays correctly incremental.Constraints
[target.'cfg(...)']tables).--targetit is skipped with a warning (host-toolchain-for-cross is a follow-up).-x c++so the.mcppextension compiles as C++ (see design doc's forward note:.mcppas a first-class C++ extension inside mcpp projects).Files
src/build/build_program.cppm(new module), wired insrc/build/prepare.cppmafter toolchain detect + L1 cfg merge, before the modgraph scan.tests/e2e/89_build_mcpp.sh— define + generated source reach the build; cache short-circuits an unchanged re-run; a changed declared env forces re-run.docs/07-build-mcpp.md(+docs/zh/), indexed in both READMEs..agents/docs/2026-06-30-l3-build-mcpp-implementation-design.md; version → 0.0.78.Verified locally (mcpp 0.0.78)
89_build_mcpppasses; focused regression set (02 new/build/run, 04 incremental, 85/86 cfg flags/deps, 87 default-profile, 88 xlings env) all green.🤖 Generated with Claude Code