From 8a7d6ad4ba953c3ebcf2b23332604e163de7e451 Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Fri, 24 Oct 2025 19:28:14 +1100 Subject: [PATCH] lets you run the binary from anywhere --- build.rs | 11 +++++++++++ crates/g3-cli/build.rs | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 build.rs create mode 100644 crates/g3-cli/build.rs diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..da1c455 --- /dev/null +++ b/build.rs @@ -0,0 +1,11 @@ +use std::env; + +fn main() { + // Only add rpaths on macOS + if env::var("CARGO_CFG_TARGET_OS").unwrap() == "macos" { + // Add rpath so libVisionBridge.dylib can be found at runtime + // @executable_path means "relative to the executable" + println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path"); + println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path"); + } +} diff --git a/crates/g3-cli/build.rs b/crates/g3-cli/build.rs new file mode 100644 index 0000000..da1c455 --- /dev/null +++ b/crates/g3-cli/build.rs @@ -0,0 +1,11 @@ +use std::env; + +fn main() { + // Only add rpaths on macOS + if env::var("CARGO_CFG_TARGET_OS").unwrap() == "macos" { + // Add rpath so libVisionBridge.dylib can be found at runtime + // @executable_path means "relative to the executable" + println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path"); + println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path"); + } +}