Skip to content

Commit f1bec00

Browse files
0.1.1: mcpp.tools.embed, and the decorative markers removed (#2)
* chore: 0.1.1 removes the decorative markers from the rule sources The rules moved here from the mcpp examples carried the warning and star markers the sweep removed everywhere else. A consumer compiles these files, so the version moves with them: mcpp.toml, mcpp::plugins::version and the README example all read 0.1.1. No behaviour changes; the edits remove a marker and the space it occupied. * feat: mcpp.tools.embed, the first member of the tools half A rule states how a translation unit is compiled by a compiler mcpp does not drive; it submits an action and the engine schedules it. A tool states something a build program needs that no compiler performs, and does it while build.mcpp runs. `mcpp.tools.embed` writes a data file into a header the program compiles in, as a byte array or a 32-bit word array, with the same reason mcpp.rules.spirv gives for emitting a header rather than a file beside the binary: the program's correctness stops depending on its working directory and `mcpp pack` has nothing further to collect. It does not rewrite an unchanged header. Writing identical bytes would still move the mtime and rebuild every translation unit that includes it, which is what makes the tool safe to call unconditionally from a build program. The fixture activates `tools-embed` alone, so it also asserts that a feature adds exactly its own unit: the manifest names no rule and the build program imports none. Its second run is the measurement the engine fix in mcpp 2026.9.5.4 exists for -- editing the data file must reach the binary -- which is why the workflow pins that version. * docs: the README lists the tools member and its floor --------- Co-authored-by: speak-agent <x.d2learn.org@gmail.com>
1 parent be6d7ce commit f1bec00

14 files changed

Lines changed: 287 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
# The mcpp release the consumers build with. Raising it is what admits a
1111
# member that relies on a newer engine; the README states each member's floor.
12-
MCPP_VERSION: 2026.9.5.3
12+
MCPP_VERSION: 2026.9.5.4
1313

1414
jobs:
1515
consumers:
@@ -47,6 +47,21 @@ jobs:
4747
"$MCPP" run | tee run.log
4848
grep -q '^magic=07230203' run.log
4949
50+
# A tool, not a rule: the header is written while the build program runs,
51+
# so there is no action to schedule. The second build is the measurement
52+
# that matters -- editing the data file must reach the binary, which is
53+
# the fast-path comparison mcpp 2026.9.5.4 added and the reason this job
54+
# pins that version.
55+
- name: tools-embed through a consumer
56+
working-directory: tests/embed-consumer
57+
run: |
58+
"$MCPP" run | tee run.log
59+
grep -q '^size=33 sum=3189 text=mcpp.tools.embed fixture payload' run.log
60+
printf 'changed\n' > data/message.txt
61+
"$MCPP" run | tee run2.log
62+
grep -q '^size=8 ' run2.log
63+
git checkout -- data/message.txt
64+
5065
# Compiles the device unit on a machine with no GPU: the clang route
5166
# produces sm_89 code from the payload toolkit. Running it needs a
5267
# device, so the run is of the CPU variant, which the same seam serves.

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
target/
2-
.mcpp/
3-
mcpp.lock
42
compile_commands.json
3+
mcpp.lock
4+
.mcpp/
5+
*.log

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ imports each one from `build.mcpp` under the module name the member declares.
66

77
```toml
88
[dependencies.mcpp]
9-
plugins = { version = "0.1.0", features = ["rules-spirv"], host-module = true }
9+
plugins = { version = "0.1.1", features = ["rules-spirv"], host-module = true }
1010
```
1111

1212
```cpp
@@ -40,10 +40,12 @@ engine's own module family and is not used here.
4040
|---|---|---|---|
4141
| `rules-cuda` | `mcpp.rules.cuda` | 2026.9.5.2 | the toolkit named in `[xlings.workspace]` (`xim:cuda-nvcc`, `xim:cuda-cudart`, and `xim:libcurand` for the clang route, whose wrapper includes a cuRAND header unconditionally), `[build] accel = "cuda…"`, a constrained glob for `*.cu`; the clang route with an LLVM toolchain, the nvcc route with a GCC one |
4242
| `rules-spirv` | `mcpp.rules.spirv` | 2026.9.5.3 | `xim:glslang` in `[xlings.workspace]`, `[build] accel = "vulkan1.2"`, a constrained glob for the shader stages; emits one header per shader through a `role = "source"` action |
43+
| `tools-embed` | `mcpp.tools.embed` | 2026.9.5.4 | nothing beyond mcpp: it reads a file and writes a header while the build program runs. The floor is the release whose fast path compares a declared file input, without which an edit to the data does not reach the binary |
4344

4445
The floor is the mcpp release whose engine carries what the member relies on:
4546
`rules-spirv` needs the device-source table that classifies shader extensions,
46-
which 2026.9.5.3 introduced. The index descriptor states the floor; a project
47+
which 2026.9.5.3 introduced, and `tools-embed` needs the fast path to compare a
48+
declared file input, which 2026.9.5.4 introduced. The index descriptor states the floor; a project
4749
on an older mcpp is refused at resolution rather than at the first shader.
4850

4951
## How the engine sees this package

mcpp.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "plugins"
33
namespace = "mcpp"
4-
version = "0.1.0"
4+
version = "0.1.1"
55
description = "Official mcpp build plugins: rule packages under mcpp.rules.*, build-time utilities under mcpp.tools.*, each member selected by a feature"
66
license = "Apache-2.0"
77
authors = ["mcpp-community"]
@@ -23,6 +23,7 @@ sources = ["src/plugins.cppm"]
2323
default = []
2424
rules-cuda = { sources = ["rules/cuda.cppm"] }
2525
rules-spirv = { sources = ["rules/spirv.cppm"] }
26+
tools-embed = { sources = ["tools/embed.cppm"] }
2627

2728
[targets.plugins]
2829
kind = "lib"

rules/cuda.cppm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct options {
5454
// Header search paths for the island. Relative entries resolve against the
5555
// package root; an ABSOLUTE entry is passed through unchanged.
5656
//
57-
// THE ABSOLUTE FORM IS FOR A DEPENDENCY'S HEADERS. A device compiler is
57+
// THE ABSOLUTE FORM IS FOR A DEPENDENCY'S HEADERS. A device compiler is
5858
// a separate driver and inherits nothing from the C++ side's include
5959
// configuration, so a package whose device code includes a dependency's
6060
// header -- ggml's CUDA backend includes `cublas_v2.h` -- has to name that
@@ -322,7 +322,7 @@ inline bounds read_bounds(std::string_view headerPath) {
322322
// Does the C library this build compiles against declare the C23 functions
323323
// `cospi`, `sinpi` and `rsqrt`?
324324
//
325-
// ⚠️ Measured 2026-09-05 against glibc 2.44. Toolkit 12.9's
325+
// Measured 2026-09-05 against glibc 2.44. Toolkit 12.9's
326326
// `crt/math_functions.h` declares those same names for the host WITHOUT
327327
// `noexcept`; glibc declares them WITH it, and since C++17 that is part of the
328328
// function type. nvcc's front end stops with six `exception specification is
@@ -470,7 +470,7 @@ inline std::vector<edge> plan(std::span<const std::string> sources, options opt
470470
}
471471
front = { driver_cc, "-x", "cuda", "-std=c++17", "-O2", "-fPIC",
472472
"--cuda-path=" + tk->nvcc_root, "-Wno-unknown-cuda-version",
473-
// ⚠️ NVIDIA'S HEADER REFUSES libc++, AND THE REFUSAL IS
473+
// NVIDIA'S HEADER REFUSES libc++, AND THE REFUSAL IS
474474
// ABOUT nvcc RATHER THAN ABOUT THIS COMPILER.
475475
//
476476
// crt/host_defines.h:67: error: "libc++ is not supported

rules/spirv.cppm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ inline std::string run_and_capture(const std::string& cmd) {
162162
return text;
163163
}
164164

165-
// ⚠️ THE OPTIMISER IS OPTIONAL AND ITS ABSENCE IS NOT A BUILD ERROR.
165+
// THE OPTIMISER IS OPTIONAL AND ITS ABSENCE IS NOT A BUILD ERROR.
166166
//
167167
// glslang links spirv-opt only when built with `ENABLE_OPT`, and the payload
168168
// this ecosystem publishes today is not:
@@ -236,7 +236,7 @@ inline std::string symbol_of(std::string_view stem, std::string_view stage) {
236236
return s;
237237
}
238238

239-
// ⚠️ NEWLINE-SEPARATED, not `;`. A path may contain a semicolon and cannot
239+
// NEWLINE-SEPARATED, not `;`. A path may contain a semicolon and cannot
240240
// contain a newline, which is why the engine chose it — and why a splitter
241241
// that guesses wrong still works for exactly one shader and silently produces
242242
// one impossible path for two.
@@ -305,7 +305,7 @@ inline bool compile(std::span<const std::string> shaders, options opt = {}) {
305305
const auto input = std::filesystem::path(src).is_absolute()
306306
? src : root + "/" + src;
307307

308-
// ⚠️ `id` and `description` are raw pointers the action reads at
308+
// `id` and `description` are raw pointers the action reads at
309309
// `submit()`; `arg`/`input`/`output` copy, these two do not. Held in
310310
// named strings for the life of the statement that submits.
311311
const std::string id = "spirv:" + src;

src/plugins.cppm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import std;
1111

1212
export namespace mcpp::plugins {
1313

14-
inline constexpr std::string_view version = "0.1.0";
14+
inline constexpr std::string_view version = "0.1.1";
1515

1616
} // namespace mcpp::plugins

tests/cuda-consumer/mcpp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ include_dirs = ["include"]
6464
# The CUDA runtime is linked STATICALLY, and only when a device build asks for
6565
# it. Linking the redistributable half in leaves exactly one host dependency,
6666
# libcuda.so.1, which the driver owns and the sentinel package reaches.
67-
# NO ABSOLUTE PATHS: the rule package puts the payload's library directory on
67+
# NO ABSOLUTE PATHS: the rule package puts the payload's library directory on
6868
# the link line from `mcpp::xpkg_dir`, so this manifest names libraries only.
6969
[target.'cfg(accelerator = "cuda")'.build]
7070
ldflags = ["-lcudart_static", "-lrt", "-lpthread", "-ldl"]

tests/embed-consumer/build.mcpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import std;
2+
import mcpp;
3+
import mcpp.tools.embed;
4+
5+
int main() {
6+
mcpp::tools::embed::options opt;
7+
opt.name_space = "fixture";
8+
opt.null_terminate = true;
9+
return mcpp::tools::embed::file("data/message.txt", opt) ? 0 : 1;
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mcpp.tools.embed fixture payload

0 commit comments

Comments
 (0)