Skip to content

Commit

Permalink
fix: missing build.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Nov 22, 2024
1 parent 8b58d52 commit d0ebb14
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/ports/rs_port2/crates/metacall-bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
!build.rs
29 changes: 29 additions & 0 deletions source/ports/rs_port2/crates/metacall-bindings/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::env;

fn main() {
// When running tests from CMake
if let Ok(val) = env::var("PROJECT_OUTPUT_DIR") {
// Link search path to build folder
println!("cargo:rustc-link-search=native={val}");

// Link against correct version of metacall
match env::var("CMAKE_BUILD_TYPE") {
Ok(val) => {
if val == "Debug" {
// Try to link the debug version when running tests
println!("cargo:rustc-link-lib=dylib=metacalld");
} else {
println!("cargo:rustc-link-lib=dylib=metacall");
}
}
Err(_) => {
println!("cargo:rustc-link-lib=dylib=metacall");
}
}
} else {
// When building from Cargo
println!("cargo:rustc-link-lib=dylib=metacall")
}
}


0 comments on commit d0ebb14

Please sign in to comment.