Skip to content

Commit 7c7cfe3

Browse files
authored
0.24.0: dist-apk packs on Windows and macOS hosts as on Linux (#58)
* 0.24.0: dist-apk packs on Windows and macOS hosts as on Linux The member ran its tools through POSIX launchers and four /bin/sh helpers, which a Windows host cannot start. d8, apksigner, bundletool, the Kotlin compiler and coursier now run from their jars on the JDK's java, with the command each tool's own launcher runs; aapt2, zipalign and the JDK tools are named with the host's executable suffix; a class path is joined with the host's separator; and the four helpers are one Java source file, DistApk.java, which that java runs as a single-file program. One command line on every host, so the Linux fixtures exercise what a Windows host runs. CI packs tests/apk-consumer at level 0 and level 1 on the macOS and Windows rows, checking the signature, the archive's entries, aapt2's reading of it and the activity in the dex. * 0.24.0: the apk-consumer fixture copies its generated file with cmd.exe on a Windows host Its generator action was gen.sh, a shell script a Windows host cannot start as an action's program; there the same copy is cmd.exe's copy.
1 parent 68382d2 commit 7c7cfe3

8 files changed

Lines changed: 390 additions & 169 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,20 +2602,58 @@ jobs:
26022602
|| { echo "FAIL: mcpp run exited $rc with the project's entries, and the program exits 7"; exit 1; }
26032603
echo "ok: the simulator bundle carries the project's entries, and the simulator ran it and returned 7"
26042604
2605-
# NO dist-apk STEP ON THIS HOST, AND THE REASON IS THE ENGINE. The NDK,
2606-
# the build tools, the platform, the JDK, the Kotlin compiler and coursier
2607-
# all publish a macOS table, and `tests/apk-consumer` was packed here once
2608-
# (0.11.0's first run): `mcpp build --target x86_64-linux-android` failed
2609-
# at the application's own link with
2610-
#
2611-
# ld64.lld: error: unknown argument '-soname'
2612-
#
2613-
# before any dist-apk step ran. On a macOS host mcpp 2026.9.14.2 composes
2614-
# the link line in its macOS branch, which states the target triple only
2615-
# for an Apple row, so `-fuse-ld=lld` picks the Mach-O flavour
2616-
# (mcpp-community/mcpp#647, E3). The steps return when an engine links
2617-
# that row; the Windows NDK has no libc++ module surface, so that host
2618-
# has no Android row at all.
2605+
# dist-apk ON A HOST THAT IS NOT LINUX (0.24.0). Every tool the member
2606+
# runs is a native program (`aapt2`, `zipalign`) or a jar on the JDK's
2607+
# `java`, and its helper is a Java source file, so no step needs a shell
2608+
# and a Windows host packs what a Linux host does. On Windows the NDK's
2609+
# libc++ module sources come from `xim:android-ndk-libcxx-modules`,
2610+
# which `xim:android-ndk`'s windows entry depends on. The criteria are the
2611+
# level-0 step's on the Linux job, plus a level-1 package whose dex holds
2612+
# the activity: that is the helper's `run-and-stamp`, `run-d8` and
2613+
# `copy-then-jar` all having run.
2614+
- name: dist-apk packs a signed APK on this host, level 0 and level 1
2615+
if: ${{ !cancelled() }}
2616+
working-directory: tests/apk-consumer
2617+
shell: bash
2618+
run: |
2619+
set -e
2620+
T=x86_64-linux-android
2621+
check() { # <apk> <entry>...
2622+
apk="$1"; shift
2623+
"$JDK/bin/java" -jar "$BT/lib/apksigner.jar" verify --print-certs "$apk" > verify.log 2>&1 || true
2624+
grep -q 'CN=Android Debug' verify.log \
2625+
|| { cat verify.log; echo "FAIL: $apk is not signed with the debug key"; exit 1; }
2626+
"$JDK/bin/jar" tf "$apk" | tr -d '\r' > listing.log
2627+
for f in "$@"; do
2628+
grep -qxF "$f" listing.log || { cat listing.log; echo "FAIL: $apk does not list $f"; exit 1; }
2629+
done
2630+
"$BT/aapt2" dump badging "$apk" 2>/dev/null | tr -d '\r' > badging.log || true
2631+
grep -q "^package: name='" badging.log \
2632+
|| { cat badging.log; echo "FAIL: aapt2 could not read $apk"; exit 1; }
2633+
}
2634+
2635+
unset APK_CONSUMER_LEVEL1
2636+
"$MCPP" build --target "$T"
2637+
"$MCPP" pack --pkg-format apk --target "$T" | tee pack.log
2638+
BT=$(find "$MCPP_HOME/registry/data/xpkgs/xim-x-android-build-tools" -mindepth 1 -maxdepth 1 -type d | head -1)
2639+
JDK=$(find "$MCPP_HOME/registry/data/xpkgs/xim-x-jdk-temurin" -mindepth 1 -maxdepth 1 -type d | head -1)
2640+
apk=$(find target -name 'apk-consumer.apk' | head -1)
2641+
test -n "$apk" || { cat pack.log; echo "FAIL: no apk-consumer.apk"; exit 1; }
2642+
check "$apk" "lib/x86_64/libapk-consumer.so" "assets/mcpp-run.json" \
2643+
"AndroidManifest.xml" "assets/generated/res.bin"
2644+
echo "ok: level 0 -- a signed, aapt2-readable APK with the native library and the deployed asset"
2645+
2646+
export APK_CONSUMER_LEVEL1=1
2647+
"$MCPP" pack --pkg-format apk --target "$T" | tee pack1.log
2648+
apk=$(find target -name 'apk-consumer.apk' | head -1)
2649+
check "$apk" "classes.dex" "lib/x86_64/libapk-consumer.so"
2650+
"$BT/dexdump" -l plain "$(find target -name classes.dex -path '*dist-apk*' | head -1)" > dexdump.log 2>&1 \
2651+
|| { cat dexdump.log; echo "FAIL: dexdump could not read the dex"; exit 1; }
2652+
for c in MainActivity GeneratedHelper; do
2653+
grep -q "org.mcpp.apkconsumer.$c;" dexdump.log \
2654+
|| { echo "FAIL: the dex does not hold org.mcpp.apkconsumer.$c"; exit 1; }
2655+
done
2656+
echo "ok: level 1 -- javac, d8 and the helper ran on this host, and the dex holds the activity and the generated class"
26192657
26202658
- name: the rule declared its own compiler
26212659
working-directory: tests/spirv-consumer

‎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.1", features = ["rules-spirv"], host-module = true }
12+
plugins = { version = "0.24.0", features = ["rules-spirv"], host-module = true }
1313
```
1414

1515
```cpp

0 commit comments

Comments
 (0)