From 477394d83e96fecaddf6d9f903fe786317eee5ce Mon Sep 17 00:00:00 2001 From: EdisonJwa Date: Mon, 18 May 2026 14:48:16 +0800 Subject: [PATCH] fix(android,build): restore multi-ABI build via cmake-rs patch (DEC-032 exit) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes DEC-032. Restores the canonical Android ABI set {arm64-v8a, armeabi-v7a, x86_64} per SDD-073 item 4 / SDD-118 item 3. Root cause was the audiopus_sys + cmake-rs + NDK toolchain-file gap: cargo-ndk 4.x sets ANDROID_ABI / ANDROID_PLATFORM as env vars per invocation, but upstream cmake-rs 0.x does not forward them to the child cmake invocation as -D variables, so armeabi-v7a and x86_64 configure steps fell through to the toolchain-file default and failed to build. Fix: - Cargo.toml: add a workspace [patch.crates-io] stanza pinning the cmake crate to fork pr2502/cmake-rs @ commit bdad5edc569d82151922c5c6c4685b1563f12aa1 (branch android-build), which carries cmake-rs PR #257 (https://github.com/rust-lang/cmake-rs/pull/257). The patch is a 9-line addition that forwards ANDROID_ABI and ANDROID_PLATFORM from the env to the child cmake as -D variables. - Cargo.lock: regenerated by 'cargo update -p cmake'; the lone cmake entry now points at the fork rev. - apps/chanora_flutter/android/app/build.gradle.kts: restore abiFilters to {arm64-v8a, armeabi-v7a, x86_64}; remove the TODO(x86_64/armv7 follow-up) comment. - docs/governance/product-decision-register.md: mark DEC-032 as Resolved (2026-05-18) with the resolution mechanism, update the §3 / §7 rows, and append a 0.9.8.1 change-history entry. Verification (host: Linux): cargo update -p cmake -> pulled fork rev cargo check --workspace --all-targets -> PASS cargo test --workspace -> PASS (no regressions) cargo ndk --platform 28 -t arm64-v8a build -p chanora_bridge -> PASS cargo ndk --platform 28 -t armeabi-v7a build -p chanora_bridge -> PASS cargo ndk --platform 28 -t x86_64 build -p chanora_bridge -> PASS Upstream tracking: re-evaluate the [patch.crates-io] override once cmake-rs PR #257 merges and a fresh cmake release lands on crates.io; at that point switch to a plain dep bump and remove the override. --- Cargo.lock | 5 ++- Cargo.toml | 17 ++++++++++ .../android/app/build.gradle.kts | 17 +++++----- docs/governance/product-decision-register.md | 33 +++++++++++++++++-- 4 files changed, 58 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9481b8..96e2ee1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -587,9 +587,8 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +version = "0.1.54" +source = "git+https://github.com/pr2502/cmake-rs?rev=bdad5edc569d82151922c5c6c4685b1563f12aa1#bdad5edc569d82151922c5c6c4685b1563f12aa1" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index d9a60f2..fc62d55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,3 +62,20 @@ readme = "README.md" thiserror = "2" tracing = "0.1" serde = { version = "1", features = ["derive"] } + +# DEC-032 exit step: override the `cmake` crate with the fork carrying +# cmake-rs PR #257 (https://github.com/rust-lang/cmake-rs/pull/257). +# The patch forwards `ANDROID_ABI` and `ANDROID_PLATFORM` environment +# variables (set per-invocation by cargo-ndk >= 4.x and reinforced by +# our SDD-118 item 5 cleanEnv map) to the child `cmake` invocation as +# `-D` variables, so audiopus_sys's libopus CMake build picks up the +# correct per-ABI target on multi-ABI Android builds. Without it the +# child cmake falls through to the NDK toolchain file's default and +# armeabi-v7a / x86_64 fail to compile. +# +# Pinned by exact commit SHA (the `android-build` branch tip on +# pr2502/cmake-rs as of 2026-05-18) so the patch is reproducible. +# Re-evaluate and remove once PR #257 merges and a fresh `cmake` +# release lands on crates.io (current upstream is 0.7.2). +[patch.crates-io] +cmake = { git = "https://github.com/pr2502/cmake-rs", rev = "bdad5edc569d82151922c5c6c4685b1563f12aa1" } diff --git a/apps/chanora_flutter/android/app/build.gradle.kts b/apps/chanora_flutter/android/app/build.gradle.kts index d9bf909..9520b20 100644 --- a/apps/chanora_flutter/android/app/build.gradle.kts +++ b/apps/chanora_flutter/android/app/build.gradle.kts @@ -69,14 +69,15 @@ android { // Per-ABI delivery is handled by the AAB bundle splits below // (SDD-109 item 2) rather than a fat APK. ndk { - // TODO(x86_64/armv7 follow-up): temporarily limited to arm64-v8a only - // while the audiopus_sys + cmake-rs + NDK toolchain-file ANDROID_ABI - // propagation gap is investigated for x86_64 / armeabi-v7a. The - // smoke-test emulator is arm64-v8a; full-set Gradle build will be - // restored once the cmake-rs `-DANDROID_ABI=` propagation fix - // lands. See SDD-073 item 4 / SDD-118 item 3 for the canonical - // multi-ABI intent. - abiFilters += listOf("arm64-v8a") + // DEC-032 RESOLVED (2026-05-18): canonical three-ABI set + // restored after the audiopus_sys + cmake-rs + NDK toolchain-file + // ANDROID_ABI propagation gap was closed by the workspace + // [patch.crates-io] override pinning `cmake` to the fork + // carrying cmake-rs PR #257 (forwards ANDROID_ABI / + // ANDROID_PLATFORM as -D variables to the child cmake + // invocation). See Cargo.toml [patch.crates-io] block and + // docs/governance/product-decision-register.md DEC-032. + abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86_64") } } diff --git a/docs/governance/product-decision-register.md b/docs/governance/product-decision-register.md index 1ab9f6b..8015bd8 100644 --- a/docs/governance/product-decision-register.md +++ b/docs/governance/product-decision-register.md @@ -231,12 +231,38 @@ release but is not an open decision: |---|---| | Decision ID | DEC-032 | | Title | Temporary reduction of Android `abiFilters` to `arm64-v8a` only during P0 smoke-test cycle. | -| Status | **Active (temporary deviation)** | +| Status | **Resolved (canonical three-ABI set restored)** | | Owner | Build/Toolchain | | Restore-by | P0 release gate (must be restored before any P0 release upload). | | Date recorded | 2026-05-18 | +| Date resolved | 2026-05-18 | | Supersedes | None (temporary deviation from SDD-073 item 4 and SDD-118 item 3; does NOT supersede them). | +**Resolution (2026-05-18).** All four exit criteria below are met. +The propagation gap (criterion 1) is closed by a workspace +`[patch.crates-io]` stanza pinning the `cmake` crate to a fork +carrying cmake-rs PR #257 +(), which forwards the +`ANDROID_ABI` and `ANDROID_PLATFORM` environment variables (set per- +invocation by `cargo-ndk` 4.x and reinforced by the SDD-118 item 5 +cleanEnv map) to the child `cmake` invocation as `-D` variables. The +fork is pinned by exact commit SHA +(`bdad5edc569d82151922c5c6c4685b1563f12aa1` on `pr2502/cmake-rs`, +branch `android-build`) for reproducibility — see the +`[patch.crates-io]` block in the workspace root `Cargo.toml`. Per-ABI +`cargo ndk --platform 28 -t build -p chanora_bridge` now passes +cleanly for all three ABIs (criterion 2). `abiFilters` in +`apps/chanora_flutter/android/app/build.gradle.kts` is restored to +`{arm64-v8a, armeabi-v7a, x86_64}` and the `TODO(x86_64/armv7 +follow-up)` comment removed (criterion 3). The SDD-118 item 10 +release-inspection assertion exercises every staged `.so` (including +`libc++_shared.so` per SDD-118 item 6 extended) for all three ABIs +again — no code change required, that assertion is driven by the +restored `abiFilters` set (criterion 4). Upstream tracking: re- +evaluate the `[patch.crates-io]` override once PR #257 merges and a +fresh `cmake` crates.io release lands; at that point the patch +should be removed in favour of a plain dep bump. + **Context.** SDD-073 item 4 and SDD-118 item 3 mandate the canonical three-ABI set `{arm64-v8a, armeabi-v7a, x86_64}` for the Android AAB. `apps/chanora_flutter/android/app/build.gradle.kts:72-79` currently has @@ -314,7 +340,7 @@ reduced set while the cmake-rs propagation fix is in flight. | Decision ID | Decision | Recommended decision | Status | Owner | Why it matters | |---|---|---|---|---|---| -| DEC-032 | Android `abiFilters` set during P0 smoke-test cycle | Temporarily reduced to `arm64-v8a` only; restore to canonical three-ABI set `{arm64-v8a, armeabi-v7a, x86_64}` (per SDD-073 item 4 / SDD-118 item 3) before any P0 release upload | **Active (temporary deviation)** | Build/Toolchain | Affects who can install the AAB (armv7 + x86_64 currently blocked); P0 release gate cannot pass until restored; documents the SDD-073 / SDD-118 deviation site so it is not silently shipped. | +| DEC-032 | Android `abiFilters` set during P0 smoke-test cycle | Canonical three-ABI set `{arm64-v8a, armeabi-v7a, x86_64}` (per SDD-073 item 4 / SDD-118 item 3) restored 2026-05-18 after the `audiopus_sys` + `cmake-rs` + NDK toolchain-file `ANDROID_ABI` propagation gap was closed via a workspace `[patch.crates-io]` override pinning `cmake` to a fork carrying cmake-rs PR #257 | **Resolved** | Build/Toolchain | Multi-ABI install support restored; P0 release-gate ABI blocker cleared. Re-evaluate the `[patch.crates-io]` override once cmake-rs PR #257 merges and a fresh release lands. | **§5 row (impact matrix).** @@ -326,10 +352,11 @@ reduced set while the cmake-rs propagation fix is in flight. | Decision ID | Owner | Decision | Status | Date | Notes | |---|---|---|---|---|---| -| DEC-032 | Build/Toolchain | Temporary reduction of Android `abiFilters` to `arm64-v8a` only during P0 smoke-test cycle | Active (temporary deviation) | 2026-05-18 | Restore to canonical three-ABI set before any P0 release. Root cause: `audiopus_sys` + `cmake-rs` + NDK toolchain-file `ANDROID_ABI` propagation gap. Exit criteria (4 items) listed in DEC-032 detail entry. SDD-073 item 4 / SDD-118 item 3 unchanged. | +| DEC-032 | Build/Toolchain | Temporary reduction of Android `abiFilters` to `arm64-v8a` only during P0 smoke-test cycle | Resolved (2026-05-18) | 2026-05-18 | Canonical three-ABI set restored 2026-05-18. Root cause (`audiopus_sys` + `cmake-rs` + NDK toolchain-file `ANDROID_ABI` propagation gap) closed by a workspace `[patch.crates-io]` override pinning the `cmake` crate to fork `pr2502/cmake-rs` @ `bdad5edc569d82151922c5c6c4685b1563f12aa1` carrying cmake-rs PR #257 (forwards `ANDROID_ABI` / `ANDROID_PLATFORM` env vars as `-D` variables to the child cmake). All four exit criteria met. Follow-up: drop the `[patch.crates-io]` override once PR #257 merges and a fresh `cmake` release lands. SDD-073 item 4 / SDD-118 item 3 unchanged. | ### Change history | Version | Date | Description | |---|---|---| | 0.9.8 | 2026-05-18 | Added DEC-032: temporary reduction of Android `abiFilters` to `arm64-v8a` only during the P0 smoke-test cycle. Status: Active (temporary deviation) from SDD-073 item 4 / SDD-118 item 3, which both remain unchanged. Restore-by gate: any P0 release upload must restore the canonical three-ABI set `{arm64-v8a, armeabi-v7a, x86_64}` and satisfy the SDD-118 item 10 release-inspection assertion (including the `libc++_shared.so` co-staging per SDD-118 item 6 extended). Root cause: `audiopus_sys` + `cmake-rs` + NDK toolchain-file `ANDROID_ABI` propagation gap. Owner: Build/Toolchain. Cross-references: SDD-073 item 4, SDD-118 item 3 (+ item 6 extended, item 10), `apps/chanora_flutter/android/app/build.gradle.kts:72-79` (in-source TODO), audit task ses_1c7645e36ffeY007MaYPep4wqs, traceability matrix v0.9.9 addendum §D. No prior decision row mutates. | +| 0.9.8.1 | 2026-05-18 | DEC-032 **Resolved**: canonical three-ABI set `{arm64-v8a, armeabi-v7a, x86_64}` restored in `apps/chanora_flutter/android/app/build.gradle.kts`. Root cause closed by a workspace `[patch.crates-io]` stanza in the repo-root `Cargo.toml` pinning the `cmake` crate to fork `pr2502/cmake-rs` @ commit `bdad5edc569d82151922c5c6c4685b1563f12aa1` (branch `android-build`), which carries cmake-rs PR #257 forwarding the `ANDROID_ABI` and `ANDROID_PLATFORM` environment variables (set per invocation by `cargo-ndk` 4.x and reinforced by the SDD-118 item 5 cleanEnv map) to the child `cmake` invocation as `-D` variables. Verification (host: Linux): `cargo ndk --platform 28 -t arm64-v8a build -p chanora_bridge`, `... -t armeabi-v7a ...`, and `... -t x86_64 ...` all pass cleanly. `cargo check --workspace --all-targets` passes on the host target. SDD-073 item 4 / SDD-118 item 3 unchanged (canonical intent was always the three-ABI set). Follow-up: re-evaluate the `[patch.crates-io]` override once cmake-rs PR #257 merges and a fresh `cmake` release lands; at that point switch to a plain dep bump and remove the override. No prior decision row mutates. |