Skip to content

Commit

Permalink
Merge pull request #121 from garyhai/main
Browse files Browse the repository at this point in the history
Add iOS and Android support.
  • Loading branch information
decahedron1 authored Nov 23, 2023
2 parents dc309c0 + 5fc75f1 commit 0777acb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ort-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{

const ORT_ENV_STRATEGY: &str = "ORT_STRATEGY";
const ORT_ENV_SYSTEM_LIB_LOCATION: &str = "ORT_LIB_LOCATION";
const ORT_ENV_SYSTEM_LIB_PROFILE: &str = "ORT_LIB_PROFILE";
#[cfg(feature = "download-binaries")]
const ORT_EXTRACT_DIR: &str = "onnxruntime";

Expand Down Expand Up @@ -114,10 +115,10 @@ fn add_search_dir<P: AsRef<Path>>(base: P) {

fn static_link_prerequisites() {
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
if target_os == "macos" {
if target_os == "macos" || target_os == "ios" {
println!("cargo:rustc-link-lib=c++");
println!("cargo:rustc-link-lib=framework=Foundation");
} else if target_os == "linux" {
} else if target_os == "linux" || target_os == "android" {
println!("cargo:rustc-link-lib=stdc++");
}
}
Expand All @@ -131,11 +132,13 @@ fn system_strategy() -> (PathBuf, bool) {
if target_os.contains("windows") { format!("{}.lib", a) } else { format!("lib{}.a", a) }
};

let mut profile = String::new();
for i in ["Release", "RelWithDebInfo", "MinSizeRel", "Debug"] {
if lib_dir.join(i).exists() && lib_dir.join(i).join(platform_format_lib("onnxruntime_common")).exists() {
profile = String::from(i);
break;
let mut profile = env::var(ORT_ENV_SYSTEM_LIB_PROFILE).unwrap_or_default();
if profile.is_empty() {
for i in ["Release", "RelWithDebInfo", "MinSizeRel", "Debug"] {
if lib_dir.join(i).exists() && lib_dir.join(i).join(platform_format_lib("onnxruntime_common")).exists() {
profile = String::from(i);
break;
}
}
}

Expand Down Expand Up @@ -166,7 +169,7 @@ fn system_strategy() -> (PathBuf, bool) {
}
}

if extension_lib_dir.exists() {
if extension_lib_dir.exists() && extension_lib_dir.join(platform_format_lib("ortcustomops")).exists() {
add_search_dir(&extension_lib_dir);
println!("cargo:rustc-link-lib=static=ortcustomops");
println!("cargo:rustc-link-lib=static=ocos_operators");
Expand Down

0 comments on commit 0777acb

Please sign in to comment.