Skip to content

Commit 7fe6df5

Browse files
pblazejclaude
andcommitted
fix(uniffi): repair Android package build and release-tag checkout
- build-android-*: cargo-make's `extend` replaces the parent env map rather than merging it, so `env = { TARGET = ... }` silently dropped ANDROID_RELEASE_FLAG and RUSTFLAGS — `--profile release` produced debug .so files and android-copy-jniLibs found nothing in target/*/release. Derive the flag from CARGO_MAKE_PROFILE in the script instead. - android-bindgen-kotlin: TARGET leaks across cargo-make tasks, so bindgen-kotlin's `build` dependency cross-compiled for Android with the host linker ("cannot find -llog"). Pin TARGET back to the host triple and keep symbols, which library-mode bindgen needs on Linux. - Raise both size gates to measured values: ios-arm64 is 1088 KiB and arm64-v8a 1174 KiB, having grown past the limits set in #1171 when the data-track UniFFI surface landed in #1034. - Check out inputs.tag_name in both reusable workflows; workflow_dispatch was building the dispatch ref (main) rather than the requested tag. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 2220142 commit 7fe6df5

3 files changed

Lines changed: 32 additions & 8 deletions

File tree

.github/workflows/uniffi-android.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
steps:
3434
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3535
with:
36+
# Build the tagged source, not the dispatch ref (which defaults to main).
37+
ref: ${{ inputs.tag_name }}
3638
submodules: recursive
3739

3840
- name: Setup Rust toolchain

.github/workflows/uniffi-swift.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
steps:
4343
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
4444
with:
45+
# Build the tagged source, not the dispatch ref (which defaults to main).
46+
ref: ${{ inputs.tag_name }}
4547
submodules: recursive
4648

4749
- uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0

livekit-uniffi/Makefile.toml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,23 @@ ANDROID_AAR_BASENAME = "livekit-uniffi-android-release"
6464
extend = "android-shared"
6565
install_crate = { crate_name = "cargo-ndk", binary = "cargo-ndk", test_arg = "--help" }
6666
script_runner = "@shell"
67+
# The profile switch lives in the script, not in [tasks.build-android.env]: the
68+
# per-arch tasks below set `env = { TARGET = ... }`, and cargo-make's `extend`
69+
# *replaces* the env map instead of merging it — anything declared here would be
70+
# silently dropped, producing a debug .so under `--profile release`.
6771
script = """
6872
echo "TARGET: ${TARGET}"
6973
rustup target add "${TARGET}"
70-
cargo ndk --target "${TARGET}" build ${ANDROID_RELEASE_FLAG}
71-
"""
7274
73-
[tasks.build-android.env]
74-
ANDROID_RELEASE_FLAG = { value = "--release", condition = { profiles = ["release"] } }
75-
RUSTFLAGS = { value = "-C force-unwind-tables=no", condition = { profiles = ["release"] } }
75+
release_flag=""
76+
if [ "${CARGO_MAKE_PROFILE}" = "release" ]; then
77+
release_flag="--release"
78+
# panic = "abort" in release, so unwind tables are dead weight.
79+
export RUSTFLAGS="-C force-unwind-tables=no"
80+
fi
81+
82+
cargo ndk --target "${TARGET}" build ${release_flag}
83+
"""
7684

7785
# MARK: - Build, specific platforms
7886

@@ -378,7 +386,7 @@ echo
378386
# are ~2× larger by construction (two archs in one Mach-O) and shouldn't be
379387
# the metric. Override the limit per release with SPM_SIZE_LIMIT_BYTES.
380388
[tasks.swift-check-size.env]
381-
SPM_SIZE_LIMIT_BYTES = { value = "723467", condition = { env_not_set = ["SPM_SIZE_LIMIT_BYTES"] } }
389+
SPM_SIZE_LIMIT_BYTES = { value = "1179648", condition = { env_not_set = ["SPM_SIZE_LIMIT_BYTES"] } }
382390

383391
[tasks.swift-check-size]
384392
private = true
@@ -541,7 +549,7 @@ run_task = "swift-package-flow"
541549
# during assemble; the raw target/ artifact is larger and not what ships).
542550
# Override the limit per release with ANDROID_SIZE_LIMIT_BYTES.
543551
[tasks.android-check-size.env]
544-
ANDROID_SIZE_LIMIT_BYTES = { value = "877918", condition = { env_not_set = ["ANDROID_SIZE_LIMIT_BYTES"] } }
552+
ANDROID_SIZE_LIMIT_BYTES = { value = "1310720", condition = { env_not_set = ["ANDROID_SIZE_LIMIT_BYTES"] } }
545553

546554
[tasks.android-check-size]
547555
extend = "android-shared"
@@ -612,11 +620,23 @@ cp "${aar}" "${out_dir}/"
612620
echo "AAR: ${out_dir}/${ANDROID_AAR_BASENAME}.aar"
613621
"""
614622

623+
# Library-mode bindgen reads UNIFFI_META_* symbols from a cdylib, so it needs a
624+
# *host* one — but cargo-make env vars leak across tasks, so the TARGET set by
625+
# the preceding per-arch Android builds would otherwise make `build` cross-
626+
# compile (with the host linker: "cannot find -llog"). Pin TARGET back to the
627+
# host, and keep symbols: the release profile's `strip = "symbols"` removes the
628+
# metadata on Linux. Same wrapper pattern as `bindgen-dart` — a task's own env
629+
# only applies once its dependencies run, hence run_task.
630+
[tasks.android-bindgen-kotlin]
631+
private = true
632+
env = { TARGET = "${CARGO_MAKE_RUST_TARGET_TRIPLE}", CARGO_PROFILE_RELEASE_STRIP = "false" }
633+
run_task = "bindgen-kotlin"
634+
615635
[tasks.android-package-flow]
616636
private = true
617637
dependencies = [
618638
"build-android-platforms",
619-
"bindgen-kotlin",
639+
"android-bindgen-kotlin",
620640
"android-copy-jniLibs",
621641
"android-assemble",
622642
"android-check-size",

0 commit comments

Comments
 (0)