Skip to content

Commit

Permalink
now tracking the build (#11)
Browse files Browse the repository at this point in the history
Here we track the `target` directory so it does not matter where the target is, the core will still be able to build no matter where the target is
  • Loading branch information
maxwellflitton authored Jan 5, 2024
1 parent 9a69328 commit 7e8fe0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion modules/utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "surrealml-core"
version = "0.0.4"
version = "0.0.5"
edition = "2021"
build = "./build.rs"
description = "The core machine learning library for SurrealML that enables SurrealDB to store and load ML models"
Expand Down
17 changes: 11 additions & 6 deletions modules/utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ use std::fs;

fn main() -> std::io::Result<()> {

let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
let out_path = Path::new(&out_dir);
let build_dir = out_path
.ancestors() // This gives an iterator over all ancestors of the path
.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 @@ -17,12 +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 = Path::new("target").join(profile).join(target_lib);

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 7e8fe0a

Please sign in to comment.