Skip to content

Commit

Permalink
feat: add iOS support to build script and distribution configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Dec 24, 2024
1 parent 4ba9632 commit 8315128
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 1 addition & 6 deletions crates/sherpa-rs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,6 @@ fn main() {
std::fs::copy("src/bindings.rs", out_dir.join("bindings.rs"))
.expect("Failed to copy bindings.rs");
} else {
let mut clang_target = target.clone();
if target.contains("android") {
clang_target = "armv8-linux-androideabi".to_string();
}
debug_log!("clang target: {}", clang_target);
let mut bindings_builder = bindgen::Builder::default()
.header("wrapper.h")
.clang_arg(format!("-I{}", sherpa_dst.display()))
Expand Down Expand Up @@ -387,7 +382,7 @@ fn main() {
}

// In Android, we need to set SHERPA_LIB_PATH to the cache directory sincie it has jniLibs
if target.contains("android") {
if target.contains("android") || target.contains("ios") {
env::set_var("SHERPA_LIB_PATH", cache_dir);
} else {
env::set_var("SHERPA_LIB_PATH", cache_dir.join(&dist.name));
Expand Down
8 changes: 6 additions & 2 deletions crates/sherpa-rs-sys/dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
},
"ios": {
"archive": "sherpa-onnx-{tag}-ios.tar.bz2",
"arch": {
"aarch64-apple-ios": "ios-arm64",
"aarch64-apple-ios-sim": "ios-arm64-simulator"
},
"libs": [
"build-ios/ios-onnxruntime/onnxruntime.xcframework",
"build-ios/sherpa-onnx.xcframework"
"build-ios/ios-onnxruntime/onnxruntime.xcframework/{arch}/libonnxruntime.a",
"build-ios/sherpa-onnx.xcframework/{arch}/libsherpa-onnx.a"
]
}
}
Expand Down
6 changes: 5 additions & 1 deletion crates/sherpa-rs-sys/src/download_binaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ impl DistTable {
// debug_log!("dist table: {:?}", self);
let target_dist = if target.contains("android") {
self.targets.get("android").unwrap()
} else if target.contains("ios") {
self.targets.get("ios").unwrap()
} else {
self.targets.get(target).unwrap()
self.targets
.get(target)
.expect(format!("Target {} not found", target).as_str())
};
debug_log!(
"raw target_dist: {:?}",
Expand Down

0 comments on commit 8315128

Please sign in to comment.