Skip to content

Commit dc3e89c

Browse files
authored
feat(workspace): build-mcpp member (L3 build.mcpp consumer) (#58)
* feat(workspace): add build-mcpp member (L3 build.mcpp consumer, mcpp>=0.0.78) 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) * ci: bump mcpp 0.0.77 -> 0.0.78 for build-mcpp member
1 parent 1d33409 commit dc3e89c

6 files changed

Lines changed: 44 additions & 6 deletions

File tree

.github/workflows/validate.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ on:
1111
workflow_dispatch:
1212

1313
env:
14-
# Bumped to 0.0.77: carries L1 platform-conditional deps/flags + [xlings] env,
14+
# Bumped to 0.0.78: carries L3 build.mcpp native build program (build-mcpp member),
1515
# compat.openblas Windows recipe (bin/libopenblas.dll staged beside the .exe).
16-
MCPP_VERSION: "0.0.77"
16+
MCPP_VERSION: "0.0.78"
1717

1818
jobs:
1919
lint:
@@ -326,14 +326,14 @@ jobs:
326326
include:
327327
- platform: macos
328328
os: macos-15
329-
archive: mcpp-0.0.77-macosx-arm64.tar.gz
330-
root: mcpp-0.0.77-macosx-arm64
329+
archive: mcpp-0.0.78-macosx-arm64.tar.gz
330+
root: mcpp-0.0.78-macosx-arm64
331331
mcpp: bin/mcpp
332332
xlings: registry/bin/xlings
333333
- platform: windows
334334
os: windows-latest
335-
archive: mcpp-0.0.77-windows-x86_64.zip
336-
root: mcpp-0.0.77-windows-x86_64
335+
archive: mcpp-0.0.78-windows-x86_64.zip
336+
root: mcpp-0.0.78-windows-x86_64
337337
mcpp: bin/mcpp.exe
338338
xlings: registry/bin/xlings.exe
339339
steps:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ tests/examples/*/target/
44
tests/examples/*/.mcpp/
55
tests/examples/*/compile_commands.json
66
tests/examples/*/mcpp.lock
7+
# build.mcpp-generated source (regenerated each build by the build program)
8+
tests/examples/build-mcpp/src/generated.cpp

mcpp.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# .agents/docs/2026-06-29-mcpp-native-workspace-ci-design.md.
66
[workspace]
77
members = [
8+
"tests/examples/build-mcpp",
89
"tests/examples/cjson",
910
"tests/examples/eigen",
1011
"tests/examples/nlohmann.json",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Native build program. mcpp compiles this with the host toolchain and runs it
2+
// before the main build; its stdout `mcpp:` directives augment the build. Here we
3+
// generate a source file and define a macro that main.cpp asserts on.
4+
#include <cstdio>
5+
#include <fstream>
6+
7+
int main() {
8+
std::ofstream("src/generated.cpp")
9+
<< "int answer() { return 42; }\n";
10+
11+
std::puts("mcpp:generated=src/generated.cpp");
12+
std::puts("mcpp:cxxflag=-DBUILT_BY_BUILD_MCPP=1");
13+
std::puts("mcpp:rerun-if-changed=build.mcpp");
14+
return 0;
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# L3 build.mcpp consumer: a project-local native build program (mcpp >= 0.0.78)
2+
# generates a source and emits a compile define, both consumed by main.cpp. No
3+
# registry dependency — this member exercises the build.mcpp pipeline itself
4+
# (Zig build.zig / Cargo build.rs analog, in C++).
5+
[package]
6+
name = "build-mcpp-example"
7+
version = "0.1.0"
8+
9+
[targets.build-mcpp-example]
10+
kind = "bin"
11+
main = "src/main.cpp"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Consumes both outputs of build.mcpp: the -DBUILT_BY_BUILD_MCPP define and the
2+
// generated answer() function. Returns 0 only if both took effect.
3+
#ifndef BUILT_BY_BUILD_MCPP
4+
#error "build.mcpp cxxflag did not reach this translation unit"
5+
#endif
6+
7+
int answer(); // defined in the generated src/generated.cpp
8+
9+
int main() { return answer() == 42 ? 0 : 1; }

0 commit comments

Comments
 (0)