Skip to content

Commit 00258d1

Browse files
pblazejclaude
andauthored
fix(uniffi): repair Android package build and release-tag checkout (#1300)
- 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. ### Before you submit your PR Make sure the following is true before submitting your PR: - [ ] I have read the [contributing guidelines](https://github.com/livekit/rust-sdks/blob/main/CONTRIBUTING.md) and validated that this PR will be accepted. - [ ] I have read and followed the principles regarding breaking changes, testing, and code quality. ### PR description Describe the changes in this PR. Explain what the PR is meant to solve and how to reproduce the issue in the first place. ### Breaking changes If this PR introduces breaking changes, list them here and document the rationale for introducing such a change. ### MSRV If the PR modifies the crate's MSRV (Minimum Supported Rust Version), document it here. ### Testing Ideally, unit test the code you add, but ensure you're not repeating existing test cases. Use as many already written scaffolding, utilities as possible; write your own, when needed. If external services, APIs, tokens are required (e.g., running an LK server instance), provide the necessary information. Make sure your tests perform useful, context-aware assertions and do not simply emulate "happy paths". ### Async We want the project to be runtime-agnostic, so please reuse what's already in [livekit-runtime](https://github.com/livekit/rust-sdks/blob/main/livekit-runtime/) and feel free to add anything missing. It's ok to use Tokio directly, when writing unit tests, if necessary. When testing, do not use artificial delays for the state to "catch up"; instead, respect the event flow and subscribe properly using channels or other mechanisms. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 2220142 commit 00258d1

5 files changed

Lines changed: 37 additions & 13 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
livekit-uniffi: patch
3+
---
4+
5+
Fix the Android AAR build. Two cargo-make bugs kept `cargo make --profile release android-package` from ever producing a release artifact: the per-arch tasks' `env = { TARGET = ... }` replaced (rather than merged) the parent env map, dropping the `--release` flag, and the `TARGET` they set leaked into the Kotlin bindgen's host build, which then cross-compiled with the host linker. Also raise the Swift and Android size budgets to match the binaries as they stand since the data-track UniFFI surface landed, and check out the released tag rather than the dispatch ref when building the wrapper packages.

.github/actions/uniffi-deps/action.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@ runs:
55
- name: Install cargo-make
66
uses: taiki-e/install-action@682e7d9e49c5e653d371fc6adbda67653461378a # v2.82.4
77
with: { tool: cargo-make@0.37 }
8-
- name: Install tera-cli
9-
uses: taiki-e/install-action@682e7d9e49c5e653d371fc6adbda67653461378a # v2.82.4
10-
with: { tool: tera-cli@0.5.0 }
11-
# ^ This would be installed by the cargo-make file automatically, but this ensures
12-
# it is already available and downloads binary distribution (no need to build from source).

.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)