Skip to content

Commit db6f6bf

Browse files
authored
Merge pull request #60 from evilsocket/copilot/add-android-ios-to-matrix
2 parents e72f0f6 + eeac13f commit db6f6bf

6 files changed

Lines changed: 125 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,114 @@ jobs:
4747
- name: Protocol tests
4848
run: cargo test -p cake-core --test protocol
4949

50+
build-android:
51+
name: Build (Android aarch64)
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: read
55+
env:
56+
ANDROID_NDK_VERSION: r27c
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Install Rust
61+
uses: dtolnay/rust-toolchain@stable
62+
with:
63+
targets: aarch64-linux-android
64+
components: clippy
65+
66+
- name: Set up Android NDK ${{ env.ANDROID_NDK_VERSION }}
67+
id: setup-ndk
68+
uses: nttld/setup-ndk@v1
69+
with:
70+
ndk-version: ${{ env.ANDROID_NDK_VERSION }}
71+
add-to-path: false
72+
73+
- name: Cache cargo registry & build
74+
uses: actions/cache@v4
75+
with:
76+
path: |
77+
~/.cargo/registry
78+
~/.cargo/git
79+
target
80+
key: android-cargo-${{ hashFiles('**/Cargo.lock') }}
81+
restore-keys: android-cargo-
82+
83+
- name: Cache cargo-ndk binary
84+
id: cache-cargo-ndk
85+
uses: actions/cache@v4
86+
with:
87+
path: ~/.cargo/bin/cargo-ndk
88+
key: cargo-ndk-bin-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
89+
90+
- name: Install cargo-ndk
91+
if: steps.cache-cargo-ndk.outputs.cache-hit != 'true'
92+
run: cargo install cargo-ndk --locked
93+
94+
- name: Build cake-mobile (Android aarch64)
95+
env:
96+
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
97+
run: cargo ndk -t aarch64-linux-android build -p cake-mobile
98+
99+
- name: Clippy (cake-core + cake-mobile, Android)
100+
env:
101+
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
102+
run: cargo ndk -t aarch64-linux-android clippy -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5" -p cake-mobile -- -D warnings
103+
104+
- name: Compile tests (cake-core lib, Android)
105+
env:
106+
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
107+
run: cargo ndk -t aarch64-linux-android test -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts" --no-run
108+
109+
- name: Compile tests (cake-core unit, Android)
110+
env:
111+
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
112+
run: cargo ndk -t aarch64-linux-android test -p cake-core --test unit --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts" --no-run
113+
114+
- name: Compile tests (cake-core protocol, Android)
115+
env:
116+
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
117+
run: cargo ndk -t aarch64-linux-android test -p cake-core --test protocol --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts" --no-run
118+
119+
build-ios:
120+
name: Build (iOS arm64)
121+
runs-on: macos-latest
122+
permissions:
123+
contents: read
124+
steps:
125+
- uses: actions/checkout@v4
126+
127+
- name: Install Rust
128+
uses: dtolnay/rust-toolchain@stable
129+
with:
130+
targets: aarch64-apple-ios
131+
components: clippy
132+
133+
- name: Cache cargo registry & build
134+
uses: actions/cache@v4
135+
with:
136+
path: |
137+
~/.cargo/registry
138+
~/.cargo/git
139+
target
140+
key: ios-cargo-${{ hashFiles('**/Cargo.lock') }}
141+
restore-keys: ios-cargo-
142+
143+
- name: Build cake-mobile (iOS arm64)
144+
run: cargo build --target=aarch64-apple-ios -p cake-mobile --features metal
145+
146+
- name: Clippy (cake-core + cake-mobile, iOS)
147+
run: cargo clippy --target=aarch64-apple-ios -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5,metal" -p cake-mobile --features metal -- -D warnings
148+
149+
- name: Compile tests (cake-core lib, iOS)
150+
run: cargo test --target=aarch64-apple-ios -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts,metal" --no-run
151+
152+
- name: Compile tests (cake-core unit, iOS)
153+
run: cargo test --target=aarch64-apple-ios -p cake-core --test unit --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts,metal" --no-run
154+
155+
- name: Compile tests (cake-core protocol, iOS)
156+
run: cargo test --target=aarch64-apple-ios -p cake-core --test protocol --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts,metal" --no-run
157+
50158
clippy:
51159
name: Clippy
52160
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cake-core/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ bindgen_cuda = { version = "0.1.6", optional = true }
8686
tempfile = "3"
8787
divan = "0.1"
8888

89+
# Build OpenSSL from source when cross-compiling tests for Android (no system OpenSSL available)
90+
[target.'cfg(target_os = "android")'.dev-dependencies]
91+
openssl = { version = "0.10", features = ["vendored"] }
92+
8993
[[bench]]
9094
name = "benchmarks"
9195
harness = false

cake-core/src/cake/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ impl Context {
420420

421421
// AudioModel workers need a VarBuilder and config to load transformer layers.
422422
// Parse config.json for the LM backbone and create VarBuilder from safetensors.
423+
#[cfg(feature = "vibevoice")]
423424
if args.model_type == ModelType::AudioModel
424425
&& matches!(args.mode, Mode::Worker)
425426
&& var_builder.is_none()

cake-core/src/cake/sharding/discovery.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,13 @@ pub fn advertise_worker(
494494
fn get_broadcast_addresses() -> Vec<Ipv4Addr> {
495495
let mut addrs = Vec::new();
496496

497-
// On Unix, use libc::getifaddrs to enumerate interfaces without spawning a subprocess.
497+
// On Unix (excluding Android), use libc::getifaddrs to enumerate interfaces without
498+
// spawning a subprocess. getifaddrs is not available below Android API 24, and Android
499+
// is a mobile-client platform where broadcast discovery is not needed.
498500
// The broadcast address field differs by platform:
499-
// Linux: ifa_ifu (union of ifa_broadaddr / ifa_dstaddr)
501+
// Linux: ifa_ifu (union of ifa_broadaddr / ifa_dstaddr)
500502
// macOS / iOS: ifa_dstaddr
501-
#[cfg(unix)]
503+
#[cfg(all(unix, not(target_os = "android")))]
502504
{
503505
let mut ifaddrs_ptr: *mut libc::ifaddrs = std::ptr::null_mut();
504506
if unsafe { libc::getifaddrs(&mut ifaddrs_ptr) } == 0 {
@@ -511,9 +513,9 @@ fn get_broadcast_addresses() -> Vec<Ipv4Addr> {
511513
&& (ifa.ifa_flags & libc::IFF_BROADCAST as libc::c_uint) != 0
512514
{
513515
// Get the broadcast address pointer (platform-specific field name).
514-
#[cfg(any(target_os = "linux", target_os = "android"))]
516+
#[cfg(target_os = "linux")]
515517
let brd_ptr = ifa.ifa_ifu;
516-
#[cfg(not(any(target_os = "linux", target_os = "android")))]
518+
#[cfg(not(target_os = "linux"))]
517519
let brd_ptr = ifa.ifa_dstaddr;
518520

519521
if !brd_ptr.is_null() {

cake-mobile/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
//! Exposes UniFFI functions callable from Kotlin (via JNI on Android) or Swift/ObjC (via static lib on iOS).
33
uniffi::setup_scaffolding!("cake_mobile");
44

5-
use std::sync::{Mutex, OnceLock};
5+
use std::sync::Mutex;
6+
#[cfg(not(target_os = "android"))]
7+
use std::sync::OnceLock;
68

79
use cake_core::{
810
cake::{self, Context, Mode, Topology, Worker},
@@ -111,6 +113,7 @@ fn get_cache_dir() -> std::path::PathBuf {
111113
// Logging
112114
// ---------------------------------------------------------------------------
113115

116+
#[cfg(not(target_os = "android"))]
114117
static LOG_PATH: OnceLock<std::path::PathBuf> = OnceLock::new();
115118

116119
fn log_mobile(msg: &str) {

0 commit comments

Comments
 (0)