Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellflitton authored Jan 5, 2024
2 parents c676076 + 9a69328 commit cb0c715
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
31 changes: 31 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use std::path::Path;
use std::env;


fn main() {
let target_lib = match env::var("CARGO_CFG_TARGET_OS").unwrap() {
ref s if s.contains("linux") => "libonnxruntime.so",
ref s if s.contains("macos") => "libonnxruntime.dylib",
ref s if s.contains("windows") => "onnxruntime.dll",
// ref s if s.contains("android") => "android", => not building for android
_ => panic!("Unsupported target os")
};
let profile = match env::var("PROFILE").unwrap() {
ref s if s.contains("release") => "release",
ref s if s.contains("debug") => "debug",
_ => panic!("Unsupported profile")
};

// remove ./modules/utils/target folder if there
let _ = std::fs::remove_dir_all(Path::new("modules").join("utils").join("target")).unwrap_or(());

// create the target module folder for the utils module
let _ = std::fs::create_dir(Path::new("modules").join("utils").join("target"));
let _ = std::fs::create_dir(Path::new("modules").join("utils").join("target").join(profile));

// copy target folder to modules/utils/target profile for the utils modules
std::fs::copy(
Path::new("target").join(profile).join(target_lib),
Path::new("modules").join("utils").join("target").join(profile).join(target_lib)
).unwrap();
}
8 changes: 2 additions & 6 deletions modules/utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fn main() -> std::io::Result<()> {
.nth(3) // 'nth(3)' gets the fourth ancestor (counting from 0), which should be the debug directory
.expect("Failed to find debug directory");


match std::env::var("ONNXRUNTIME_LIB_PATH") {
Ok(_) => {
println!("cargo:rustc-cfg=onnx_runtime_env_var_set");
Expand All @@ -25,13 +24,10 @@ fn main() -> std::io::Result<()> {
// ref s if s.contains("android") => "android", => not building for android
_ => panic!("Unsupported target os")
};
// let profile = match env::var("PROFILE").unwrap() {
// ref s if s.contains("release") => "release",
// ref s if s.contains("debug") => "debug",
// _ => panic!("Unsupported profile")
// };

let lib_path = build_dir.join(target_lib);
let lib_path = lib_path.to_str().unwrap();

// put it next to the file of the embedding
let destination = Path::new(target_lib);
fs::copy(lib_path, destination)?;
Expand Down

0 comments on commit cb0c715

Please sign in to comment.