From 2351d50a288d0793defa31013ac55900cad039b5 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Tue, 30 Jun 2026 08:31:29 +0800 Subject: [PATCH 1/2] feat(workspace): add build-mcpp member (L3 build.mcpp consumer, mcpp>=0.0.78) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A workspace member that exercises the native build.mcpp build program: its build.mcpp generates src/generated.cpp and emits -DBUILT_BY_BUILD_MCPP; main.cpp asserts both. Dogfoods the L3 feature through the real pipeline. (held until mcpp 0.0.78 is released + indexed — CI downloads the released binary) --- .gitignore | 2 ++ mcpp.toml | 1 + tests/examples/build-mcpp/build.mcpp | 15 +++++++++++++++ tests/examples/build-mcpp/mcpp.toml | 11 +++++++++++ tests/examples/build-mcpp/src/main.cpp | 9 +++++++++ 5 files changed, 38 insertions(+) create mode 100644 tests/examples/build-mcpp/build.mcpp create mode 100644 tests/examples/build-mcpp/mcpp.toml create mode 100644 tests/examples/build-mcpp/src/main.cpp diff --git a/.gitignore b/.gitignore index ac234a8..d5807fa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ tests/examples/*/target/ tests/examples/*/.mcpp/ tests/examples/*/compile_commands.json tests/examples/*/mcpp.lock +# build.mcpp-generated source (regenerated each build by the build program) +tests/examples/build-mcpp/src/generated.cpp diff --git a/mcpp.toml b/mcpp.toml index 3a3fcb3..72ec50a 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -5,6 +5,7 @@ # .agents/docs/2026-06-29-mcpp-native-workspace-ci-design.md. [workspace] members = [ + "tests/examples/build-mcpp", "tests/examples/cjson", "tests/examples/eigen", "tests/examples/nlohmann.json", diff --git a/tests/examples/build-mcpp/build.mcpp b/tests/examples/build-mcpp/build.mcpp new file mode 100644 index 0000000..e1ffafa --- /dev/null +++ b/tests/examples/build-mcpp/build.mcpp @@ -0,0 +1,15 @@ +// Native build program. mcpp compiles this with the host toolchain and runs it +// before the main build; its stdout `mcpp:` directives augment the build. Here we +// generate a source file and define a macro that main.cpp asserts on. +#include +#include + +int main() { + std::ofstream("src/generated.cpp") + << "int answer() { return 42; }\n"; + + std::puts("mcpp:generated=src/generated.cpp"); + std::puts("mcpp:cxxflag=-DBUILT_BY_BUILD_MCPP=1"); + std::puts("mcpp:rerun-if-changed=build.mcpp"); + return 0; +} diff --git a/tests/examples/build-mcpp/mcpp.toml b/tests/examples/build-mcpp/mcpp.toml new file mode 100644 index 0000000..491e828 --- /dev/null +++ b/tests/examples/build-mcpp/mcpp.toml @@ -0,0 +1,11 @@ +# L3 build.mcpp consumer: a project-local native build program (mcpp >= 0.0.78) +# generates a source and emits a compile define, both consumed by main.cpp. No +# registry dependency — this member exercises the build.mcpp pipeline itself +# (Zig build.zig / Cargo build.rs analog, in C++). +[package] +name = "build-mcpp-example" +version = "0.1.0" + +[targets.build-mcpp-example] +kind = "bin" +main = "src/main.cpp" diff --git a/tests/examples/build-mcpp/src/main.cpp b/tests/examples/build-mcpp/src/main.cpp new file mode 100644 index 0000000..bebe07e --- /dev/null +++ b/tests/examples/build-mcpp/src/main.cpp @@ -0,0 +1,9 @@ +// Consumes both outputs of build.mcpp: the -DBUILT_BY_BUILD_MCPP define and the +// generated answer() function. Returns 0 only if both took effect. +#ifndef BUILT_BY_BUILD_MCPP +#error "build.mcpp cxxflag did not reach this translation unit" +#endif + +int answer(); // defined in the generated src/generated.cpp + +int main() { return answer() == 42 ? 0 : 1; } From c43aea141c41c28f40680f5f748c531ace1a81ca Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Tue, 30 Jun 2026 09:27:53 +0800 Subject: [PATCH 2/2] ci: bump mcpp 0.0.77 -> 0.0.78 for build-mcpp member --- .github/workflows/validate.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 4689926..1af8aa4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -11,9 +11,9 @@ on: workflow_dispatch: env: - # Bumped to 0.0.77: carries L1 platform-conditional deps/flags + [xlings] env, + # Bumped to 0.0.78: carries L3 build.mcpp native build program (build-mcpp member), # compat.openblas Windows recipe (bin/libopenblas.dll staged beside the .exe). - MCPP_VERSION: "0.0.77" + MCPP_VERSION: "0.0.78" jobs: lint: @@ -326,14 +326,14 @@ jobs: include: - platform: macos os: macos-15 - archive: mcpp-0.0.77-macosx-arm64.tar.gz - root: mcpp-0.0.77-macosx-arm64 + archive: mcpp-0.0.78-macosx-arm64.tar.gz + root: mcpp-0.0.78-macosx-arm64 mcpp: bin/mcpp xlings: registry/bin/xlings - platform: windows os: windows-latest - archive: mcpp-0.0.77-windows-x86_64.zip - root: mcpp-0.0.77-windows-x86_64 + archive: mcpp-0.0.78-windows-x86_64.zip + root: mcpp-0.0.78-windows-x86_64 mcpp: bin/mcpp.exe xlings: registry/bin/xlings.exe steps: