From aae8822c1590af25dc4b1d4a4897bd9d82145991 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 14:29:08 +0900 Subject: [PATCH 1/2] 0.25.0: tools-script, one mechanism for a step of more than one command An action whose work is more than one command is cmake -P over a script the member writes. The deps members did this through helpers private to mcpp.deps, dist-apk ran a Java helper of its own, and dist-apple ran /bin/sh scripts. The mechanism is now the member tools-script (mcpp.tools.script): the xim:cmake spec, bracket arguments, one command as execute_process that fails the script, and the script written only when it changes and declared with cmake as the action's inputs. It is an L3 member rather than part of plugins-core because the general library knows no foreign tool. mcpp.deps re-exports cmake_spec and bracket under its own names. dist-apk's javac, kotlinc, d8, libs and base-module steps and dist-apple's framework copy and disk-image staging are scripts; DistApk.java and the shell helpers are gone. Both members declare xim:cmake on request and take options::cmake. Rule 5 of the plugin conventions names the mechanism and refuses a shell script as an action's program. --- .github/workflows/ci.yml | 10 +- README.md | 3 +- deps/deps.cppm | 26 +- dist/apk.cppm | 390 ++++++++++------------------- dist/apple.cppm | 93 ++++--- docs/dist-apk.md | 10 +- docs/dist-apple.md | 2 +- docs/plugin-development.md | 4 +- docs/tools-script.md | 20 ++ mcpp.toml | 24 +- src/plugins.cppm | 2 +- tests/all-rules-compile/build.mcpp | 6 + tests/all-rules-compile/mcpp.toml | 2 +- tools/README.md | 5 +- tools/script.cppm | 97 +++++++ 15 files changed, 362 insertions(+), 332 deletions(-) create mode 100644 docs/tools-script.md create mode 100644 tools/script.cppm diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8ccd8c..33f341a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2604,13 +2604,13 @@ jobs: # dist-apk ON A HOST THAT IS NOT LINUX (0.24.0). Every tool the member # runs is a native program (`aapt2`, `zipalign`) or a jar on the JDK's - # `java`, and its helper is a Java source file, so no step needs a shell - # and a Windows host packs what a Linux host does. On Windows the NDK's + # `java`, and each step of more than one command is `cmake -P` over a + # script it writes (0.25.0, `tools-script`), so no step needs a shell and + # a Windows host packs what a Linux host does. On Windows the NDK's # libc++ module sources come from `xim:android-ndk-libcxx-modules`, # which `xim:android-ndk`'s windows entry depends on. The criteria are the # level-0 step's on the Linux job, plus a level-1 package whose dex holds - # the activity: that is the helper's `run-and-stamp`, `run-d8` and - # `copy-then-jar` all having run. + # the activity: that is the javac, d8 and libs scripts all having run. - name: dist-apk packs a signed APK on this host, level 0 and level 1 if: ${{ !cancelled() }} working-directory: tests/apk-consumer @@ -2653,7 +2653,7 @@ jobs: grep -q "org.mcpp.apkconsumer.$c;" dexdump.log \ || { echo "FAIL: the dex does not hold org.mcpp.apkconsumer.$c"; exit 1; } done - echo "ok: level 1 -- javac, d8 and the helper ran on this host, and the dex holds the activity and the generated class" + echo "ok: level 1 -- the javac, d8 and libs scripts ran on this host, and the dex holds the activity and the generated class" - name: the rule declared its own compiler working-directory: tests/spirv-consumer diff --git a/README.md b/README.md index 81dc845..9a221aa 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ module name the member declares, and configures it there. ```toml [build-dependencies.mcpp] -plugins = { version = "0.24.0", features = ["rules-spirv"], host-module = true } +plugins = { version = "0.25.0", features = ["rules-spirv"], host-module = true } ``` ```cpp @@ -75,6 +75,7 @@ mcpp 2026.11.7.1 or later; cross configuration requires CMake 3.19 or later. | `rules-sycl` | `mcpp.rules.sycl` | 2026.10.1.3 | Compiles SYCL (`*.sycl`) with DPC++. | [rules](docs/rules.md#rules-sycl) | | `tools-embed` | `mcpp.tools.embed` | 2026.9.5.4 | Writes a data file into a header the program compiles in. | [tools-embed](docs/tools-embed.md) | | `tools-island` | `mcpp.tools.island` | 2026.9.7.1 | Generates the `extern "C"` boundary and the C++ module of a code island. | [tools-island](docs/tools-island.md) | +| `tools-script` | `mcpp.tools.script` | 2026.10.1.3 | Runs an action whose work is more than one command as `cmake -P` over a script the member writes; implied by `deps`, `dist-apk` and `dist-apple`. | [tools-script](docs/tools-script.md) | | `dist-appimage` | `mcpp.dist.appimage` | 2026.10.1.3 | Turns the tree `mcpp pack` stages into an AppImage (Linux). | [dist](docs/dist.md#dist-appimage) | | `dist-deb` | `mcpp.dist.deb` | 2026.10.30.1 | Installs the staged tree under `/opt/` with a launcher, a desktop entry and an icon, as a Debian package (Linux targets). | [dist](docs/dist.md#dist-deb-and-dist-rpm) | | `dist-rpm` | `mcpp.dist.rpm` | 2026.10.30.1 | The same installation as an RPM package (Linux targets). | [dist](docs/dist.md#dist-deb-and-dist-rpm) | diff --git a/deps/deps.cppm b/deps/deps.cppm index 7a55971..c5a7ffc 100644 --- a/deps/deps.cppm +++ b/deps/deps.cppm @@ -39,16 +39,18 @@ import mcpp.plugins; export import mcpp.deps.compat; // The one resolver of a member's tools (0.19.0, mcpp#755). export import mcpp.plugins.tool; +// An action whose work is more than one command: `cmake -P` over a script the +// member writes (0.25.0, from this unit). +export import mcpp.tools.script; export namespace mcpp::deps { -// THE `cmake` deps-cmake AND deps-archive RUN (0.19.0, mcpp#755): the payload -// both features declare, in its two layouts (`bin/` and, on macOS, -// `CMake.app/Contents/bin`), found by the one resolver every member uses. -inline mcpp::plugins::tool::spec cmake_spec(std::string who) { - return { .who = std::move(who), .package = "cmake", .programs = {"cmake"}, - .bin_dirs = {"bin", "CMake.app/Contents/bin"}, .option = "options::cmake" }; -} +// THE `cmake` deps-cmake AND deps-archive RUN (0.19.0, mcpp#755), and the +// bracket argument their scripts quote every value with: since 0.25.0 the +// mechanism the members share, `mcpp.tools.script`, under the names these +// members have always used. +using mcpp::tools::script::cmake_spec; +using mcpp::tools::script::bracket; // Prints `message` and records it as a `mcpp::warning`, folded onto one line. // The engine discards a build program's output when it exits 0, so a note that @@ -70,16 +72,6 @@ inline void warn(const std::string& message) { mcpp::warning(folded.c_str()); } -// A CMake script this build program writes, for an action whose work is more -// than one command: `cmake -P