Skip to content

Commit

Permalink
Os based lib import path string
Browse files Browse the repository at this point in the history
  • Loading branch information
Bandsberg authored and hannobraun committed Dec 17, 2021
1 parent aab78ec commit 6f8b538
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,27 @@ impl Model {
// TASK: Read up why those calls are unsafe. Make sure calling them is
// sound, and document why that is.
let shape = unsafe {
let lib = libloading::Library::new(format!(
"{}/target/debug/lib{}.so",
self.path(),
self.name(),
))?;
let lib = libloading::Library::new(
if cfg!(windows) {
format!(
"{}/target/debug/{}.dll",
self.path(),
self.name(),
)
} else if cfg!(target_os = "macos") {
format!(
"{}/target/debug/lib{}.dylib",
self.path(),
self.name(),
)
} else { //Unix
format!(
"{}/target/debug/lib{}.so",
self.path(),
self.name(),
)
}
)?;
let model: libloading::Symbol<ModelFn> = lib.get(b"model")?;
model(&arguments)
};
Expand Down

0 comments on commit 6f8b538

Please sign in to comment.