Skip to content

Commit 4251b26

Browse files
committed
0.23.1: dist-apk takes a generated Java root as an action input
A Java or Kotlin root inside the build's output, which a build program generated, declared a re-run glob the engine's walk never enters, and every build warned that it could never re-run. Such a root is now an input of the javac action only. The level-1 fixture generates a third root and the feature check asserts its class and the absence of the warning.
1 parent 087c5f3 commit 4251b26

8 files changed

Lines changed: 32 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module name the member declares, and configures it there.
99

1010
```toml
1111
[build-dependencies.mcpp]
12-
plugins = { version = "0.23.0", features = ["rules-spirv"], host-module = true }
12+
plugins = { version = "0.23.1", features = ["rules-spirv"], host-module = true }
1313
```
1414

1515
```cpp

‎dist/apk.cppm‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ inline bool is_dir(const std::string& p) {
360360
// (`mcpp::manifest_dir()` composed with a subdirectory), so declaring the
361361
// glob with `root` itself, not this function's return value, was exactly
362362
// that defect.
363+
//
364+
// A root inside the build's output -- `mcpp::out_dir()`, or a directory the
365+
// glob walk never enters (`target`, `.mcpp`, `.git`) -- is GENERATED: the
366+
// build program that writes its files already runs on every build, and a glob
367+
// there can never match anything, which the engine reports as a warning. It is
368+
// answered as outside the project, so it is an action input and no glob.
363369
inline std::optional<std::string> root_in_project(const std::string& root) {
364370
std::error_code ec;
365371
const auto a = fs::weakly_canonical(root, ec);
@@ -368,6 +374,13 @@ inline std::optional<std::string> root_in_project(const std::string& root) {
368374
if (ec) return std::nullopt;
369375
const auto rel = a.lexically_relative(b).generic_string();
370376
if (rel.empty() || rel.starts_with("..")) return std::nullopt;
377+
const auto out = fs::weakly_canonical(std::string(mcpp::out_dir()), ec);
378+
if (!ec) {
379+
const auto inside = a.lexically_relative(out).generic_string();
380+
if (!inside.empty() && !inside.starts_with("..")) return std::nullopt;
381+
}
382+
const auto first = rel.substr(0, rel.find('/'));
383+
if (first == "target" || first == ".mcpp" || first == ".git") return std::nullopt;
371384
return rel;
372385
}
373386

‎docs/dist-apk.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Module `mcpp.dist.apk`; engine floor: 2026.10.1.3 from 0.19.0 (mcpp#755), whose protocol 15 states where a tool comes from and installs `xim:bundletool` only when a bundle asks for it; 2026.9.14.2 from 0.10.0, which stages the closure this member reads; before it 2026.9.13.1, raised alongside `dist-web` in the same 0.9.0 release: this member's own manifest-template and Java-array changes ask nothing new of the engine, but this collection publishes one package at one version, and this is the release CI verifies it under from here on.
88

9-
**Needs and behaviour.** `xim:android-build-tools`, `xim:android-platform` (versioned by API level, read back for `targetSdkVersion`), `xim:jdk-temurin` (`javac`/`jar`/`jarsigner`; `android-build-tools`' own runtime dependency provisions a JDK for its OWN wrappers only), `xim:android-debug-keystore`, `xim:bundletool` (0.10.0, for `--format aab`), all on the `cfg(env = "android")` axis. Generates `AndroidManifest.xml` and signs with the published Android debug key by default. Level 0 needs no Java (`hasCode="false"`, `android.app.NativeActivity`); `options::java_sources` adds `javac` + `d8` and a real `<activity>`. `options::manifest_template` renders a project manifest with six tokens substituted verbatim; `{{application_id}}` and `{{activity}}` are required always and `{{lib_name}}` at level 0, each refused by name at plan time when missing (naming `assets/mcpp-run.json`, which `adb-run` reads them from too) or when the template names an unknown token; empty renders 0.8.0's manifest byte-identically. From 0.9.3 the manifest template gains `{{version_name}}` / `{{version_code}}` (the package version, and `major * 1000000 + minor * 1000 + patch`). `options::resources` is a project's own `res/`, linked as the application's base resources from 0.9.1 (0.9.0 linked it as an aapt2 overlay, which refuses every resource the base does not already define -- a launcher icon could not be supplied). `options::java_sources` is an array: one `javac` over every root's `.java` files and one `d8` over the result, so a project's own sources and a path dependency's join without being merged into one directory first, and `rerun_if_changed_glob` is declared only for a root under `mcpp::manifest_dir()` -- a dependency root's files are already inputs of the `javac` action and its version is already in the build's fingerprint. Android only -- an `app` target is a shared object on this row (#622 A3). From 0.10.0, with mcpp 2026.9.14.2, the member reads the native closure the engine stages -- the application object, the graph's shared libraries and `libc++_shared.so` under `lib/` for one `--target`, `lib/<abi>/` for several -- and packs every ABI the tree carries into one APK; its own `NEEDED` walk and the stamp that lost a dependency's library on a second pack are gone. A stage manifest without `needs` lines comes from an engine below 2026.9.14.2 and is refused naming that floor, as is an incomplete closure, naming the unresolved libraries; every refusal is also a `mcpp::warning`, because the engine discards a build program's output when it exits 0. `--format aab` shares every step but the last three: `aapt2 link --proto-format` (with `--version-code` / `--version-name`, which bundletool requires), a base module in the layout bundletool reads, `bundletool build-bundle` from `xim:bundletool` (declared on the same axis), and `jarsigner` with the same keystore. CI packages both level 0 and level 1 and checks the archive (`mcpp::deploy`'d files under `assets/`), and on `tests/apk-consumer-shared` two packs in a row, a two-ABI APK (`aapt2` reports both, `apksigner` verifies it), an App Bundle (`bundletool validate`, `jarsigner -verify`, a universal APK from `bundletool build-apks`), a refusal's reason in `mcpp pack`'s output, and the floor refusal; the runner has no emulator or device, so the two rows that actually run were measured locally on 2026-09-12, through `adb-run`, against a KVM-accelerated x86_64 emulator and a physical arm64-v8a phone, both printing `1-2-3` and exiting 0. From 0.11.0: Kotlin sources (`dist-apk-kotlin`, which declares `xim:kotlin`), R classes, Android libraries from source, local AARs and JARs, a Maven graph through a lock file (`dist-apk-maven`, which declares `xim:coursier`), a manifest merge, and an unsigned package -- see [`dist-apk`: Kotlin, libraries and a Maven graph](#dist-apk-kotlin-libraries-and-a-maven-graph). From 0.11.1 the native libraries are packed as the Android Gradle plugin packs them: each is stripped with the build's own `llvm-strip --strip-unneeded` (the NDK's, beside the compiler `mcpp::toolchain_dir()` reports; `options::keep_debug_symbols` packs them as staged), and a manifest stating `android:extractNativeLibs="false"` gets them stored uncompressed on a 16 KB page, which loading them from the APK in place requires; CI checks both, and the symbol table `keep_debug_symbols` keeps. From 0.12.0 the engine's strip decision governs these libraries as well: under mcpp 2026.9.16.1, which publishes it to build programs as `MCPP_PACK_STRIP` and `MCPP_PACK_DEBUG_SYMBOLS_DIR`, that engine strips and separates the libraries it stages itself and the member packs them as staged, while the libraries the engine did not stage -- an archive's `jni/` libraries -- follow the same decision inside the member: `--no-strip` packs them as they are, and `--debug-symbols <dir>` separates each one's debug information into `<dir>/<abi>/<library>.debug` with `llvm-objcopy` before stripping it and linking the packed copy to that file (`.gnu_debuglink`). A library is stripped unless either `keep_debug_symbols` or the engine says to keep it, and under an older engine, which publishes neither variable, the member strips every library as before. Because that engine strips before the member reads the tree, `keep_debug_symbols` keeps only the member's own strip off and `--no-strip` is what ships the symbols of the libraries the graph built; the member warns when the option is set and the engine stripped. From 0.12.0 a library in the resolved graph contributes libraries and archives through `[package.metadata.dist-apk]`, ranked below the application's own -- see [A library states its contribution](#a-library-states-its-contribution-packagemetadatadist-apk)
9+
**Needs and behaviour.** `xim:android-build-tools`, `xim:android-platform` (versioned by API level, read back for `targetSdkVersion`), `xim:jdk-temurin` (`javac`/`jar`/`jarsigner`; `android-build-tools`' own runtime dependency provisions a JDK for its OWN wrappers only), `xim:android-debug-keystore`, `xim:bundletool` (0.10.0, for `--format aab`), all on the `cfg(env = "android")` axis. Generates `AndroidManifest.xml` and signs with the published Android debug key by default. Level 0 needs no Java (`hasCode="false"`, `android.app.NativeActivity`); `options::java_sources` adds `javac` + `d8` and a real `<activity>`. `options::manifest_template` renders a project manifest with six tokens substituted verbatim; `{{application_id}}` and `{{activity}}` are required always and `{{lib_name}}` at level 0, each refused by name at plan time when missing (naming `assets/mcpp-run.json`, which `adb-run` reads them from too) or when the template names an unknown token; empty renders 0.8.0's manifest byte-identically. From 0.9.3 the manifest template gains `{{version_name}}` / `{{version_code}}` (the package version, and `major * 1000000 + minor * 1000 + patch`). `options::resources` is a project's own `res/`, linked as the application's base resources from 0.9.1 (0.9.0 linked it as an aapt2 overlay, which refuses every resource the base does not already define -- a launcher icon could not be supplied). `options::java_sources` is an array: one `javac` over every root's `.java` files and one `d8` over the result, so a project's own sources and a path dependency's join without being merged into one directory first, and `rerun_if_changed_glob` is declared only for a root under `mcpp::manifest_dir()` -- a dependency root's files are already inputs of the `javac` action and its version is already in the build's fingerprint. Android only -- an `app` target is a shared object on this row (#622 A3). From 0.10.0, with mcpp 2026.9.14.2, the member reads the native closure the engine stages -- the application object, the graph's shared libraries and `libc++_shared.so` under `lib/` for one `--target`, `lib/<abi>/` for several -- and packs every ABI the tree carries into one APK; its own `NEEDED` walk and the stamp that lost a dependency's library on a second pack are gone. A stage manifest without `needs` lines comes from an engine below 2026.9.14.2 and is refused naming that floor, as is an incomplete closure, naming the unresolved libraries; every refusal is also a `mcpp::warning`, because the engine discards a build program's output when it exits 0. `--format aab` shares every step but the last three: `aapt2 link --proto-format` (with `--version-code` / `--version-name`, which bundletool requires), a base module in the layout bundletool reads, `bundletool build-bundle` from `xim:bundletool` (declared on the same axis), and `jarsigner` with the same keystore. CI packages both level 0 and level 1 and checks the archive (`mcpp::deploy`'d files under `assets/`), and on `tests/apk-consumer-shared` two packs in a row, a two-ABI APK (`aapt2` reports both, `apksigner` verifies it), an App Bundle (`bundletool validate`, `jarsigner -verify`, a universal APK from `bundletool build-apks`), a refusal's reason in `mcpp pack`'s output, and the floor refusal; the runner has no emulator or device, so the two rows that actually run were measured locally on 2026-09-12, through `adb-run`, against a KVM-accelerated x86_64 emulator and a physical arm64-v8a phone, both printing `1-2-3` and exiting 0. From 0.11.0: Kotlin sources (`dist-apk-kotlin`, which declares `xim:kotlin`), R classes, Android libraries from source, local AARs and JARs, a Maven graph through a lock file (`dist-apk-maven`, which declares `xim:coursier`), a manifest merge, and an unsigned package -- see [`dist-apk`: Kotlin, libraries and a Maven graph](#dist-apk-kotlin-libraries-and-a-maven-graph). From 0.11.1 the native libraries are packed as the Android Gradle plugin packs them: each is stripped with the build's own `llvm-strip --strip-unneeded` (the NDK's, beside the compiler `mcpp::toolchain_dir()` reports; `options::keep_debug_symbols` packs them as staged), and a manifest stating `android:extractNativeLibs="false"` gets them stored uncompressed on a 16 KB page, which loading them from the APK in place requires; CI checks both, and the symbol table `keep_debug_symbols` keeps. From 0.12.0 the engine's strip decision governs these libraries as well: under mcpp 2026.9.16.1, which publishes it to build programs as `MCPP_PACK_STRIP` and `MCPP_PACK_DEBUG_SYMBOLS_DIR`, that engine strips and separates the libraries it stages itself and the member packs them as staged, while the libraries the engine did not stage -- an archive's `jni/` libraries -- follow the same decision inside the member: `--no-strip` packs them as they are, and `--debug-symbols <dir>` separates each one's debug information into `<dir>/<abi>/<library>.debug` with `llvm-objcopy` before stripping it and linking the packed copy to that file (`.gnu_debuglink`). A library is stripped unless either `keep_debug_symbols` or the engine says to keep it, and under an older engine, which publishes neither variable, the member strips every library as before. Because that engine strips before the member reads the tree, `keep_debug_symbols` keeps only the member's own strip off and `--no-strip` is what ships the symbols of the libraries the graph built; the member warns when the option is set and the engine stripped. From 0.12.0 a library in the resolved graph contributes libraries and archives through `[package.metadata.dist-apk]`, ranked below the application's own -- see [A library states its contribution](#a-library-states-its-contribution-packagemetadatadist-apk). From 0.23.1 a Java or Kotlin root inside the build's output (`mcpp::out_dir()`, `target/`), which a build program generated, is an input of the `javac` action and declares no re-run glob, which could never match there
1010

1111
## `dist-apk`: Kotlin, libraries and a Maven graph
1212

‎docs/plugin-development.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mcpp-index refuses such a package.
5252

5353
```toml
5454
[build-dependencies.mcpp]
55-
plugins = { version = "0.23.0", features = ["plugins-core"], host-module = true, reexport = true }
55+
plugins = { version = "0.23.1", features = ["plugins-core"], host-module = true, reexport = true }
5656
```
5757

5858
`reexport = true` is needed when the plugin's consumers import L2 modules in

‎mcpp.toml‎

Lines changed: 1 addition & 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.23.0"
4+
version = "0.23.1"
55
# The first mcpp release that speaks protocol 17 (SPEC-013, mcpp#847): the
66
# platform's directives `mcpp.plugins.platform` states (`link_driver`,
77
# `link_input`, `artifact_name`, `seal`, `run_host`), the `platform` phase, and

‎src/plugins.cppm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export namespace mcpp::plugins {
4646
//
4747
// One package, one version: the number lives in mcpp.toml, and the CI step
4848
// `the collection states its own version` compares the two.
49-
inline constexpr std::string_view version = "0.23.0";
49+
inline constexpr std::string_view version = "0.23.1";
5050

5151
} // namespace mcpp::plugins
5252

‎tests/apk-consumer/build.mcpp‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ int main() {
5858
// directory, reached by an absolute path computed from
5959
// `mcpp::manifest_dir()` rather than a second package -- see
6060
// `tests/apk-consumer-external-java/`'s own header.
61-
opt.java_sources = { root + "/java", root + "/../apk-consumer-external-java" };
61+
// A third root this program GENERATES under its output directory, as a
62+
// framework's build rules generate an application shell: an action
63+
// input, never a re-run glob, which could not match anything there.
64+
const std::string generated = std::string(mcpp::out_dir()) + "/gen-java";
65+
std::filesystem::create_directories(generated + "/org/mcpp/apkconsumer");
66+
std::ofstream(generated + "/org/mcpp/apkconsumer/GeneratedHelper.java")
67+
<< "package org.mcpp.apkconsumer;\n\npublic class GeneratedHelper {\n"
68+
" public static String marker() { return \"generated\"; }\n}\n";
69+
opt.java_sources = { root + "/java", root + "/../apk-consumer-external-java", generated };
6270
}
6371

6472
// (i) Kotlin sources in a project that named `dist-apk` and not

‎tests/apk-consumer/check-apk-features.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ grep -q "org.mcpp.apkconsumer.MainActivity;" dexdump-e.log \
127127
|| fail "classes.dex does not contain MainActivity (the project's own root)" dexdump-e.log
128128
grep -q "org.mcpp.apkconsumer.ExternalHelper;" dexdump-e.log \
129129
|| fail "classes.dex does not contain ExternalHelper (the external root)" dexdump-e.log
130-
echo "ok: one classes.dex, carrying classes from both the project root and the external root"
130+
grep -q "org.mcpp.apkconsumer.GeneratedHelper;" dexdump-e.log \
131+
|| fail "classes.dex does not contain GeneratedHelper (the generated root)" dexdump-e.log
132+
! grep -q "can never re-run it" build-e.log pack-e.log \
133+
|| fail "a generated root was declared as a re-run glob" build-e.log pack-e.log
134+
echo "ok: one classes.dex, carrying classes from the project root, the external root and the generated root"
131135

132136
# ── (f) the re-run direction, both ways (§3.3's third bullet) ──────────────
133137
#

0 commit comments

Comments
 (0)