summaryrefslogtreecommitdiff
path: root/plugins/svd/build.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-02-14 00:07:53 -0500
committerMason Reed <mason@vector35.com>2025-02-24 20:11:57 -0500
commitfb8eb1501b7f4b8eaefcb26131230ba42083c153 (patch)
tree9eb5f090b0e31e4e49d4afc9e8220b323e7f7a98 /plugins/svd/build.rs
parentddfdfe03426fa6ed1d73f3114e8f71ac0c54bef7 (diff)
Add SVD Loader Plugin
Diffstat (limited to 'plugins/svd/build.rs')
-rw-r--r--plugins/svd/build.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/plugins/svd/build.rs b/plugins/svd/build.rs
new file mode 100644
index 00000000..637f4779
--- /dev/null
+++ b/plugins/svd/build.rs
@@ -0,0 +1,34 @@
+use std::path::PathBuf;
+
+fn main() {
+ let link_path = std::env::var_os("DEP_BINARYNINJACORE_PATH")
+ .expect("DEP_BINARYNINJACORE_PATH not specified");
+
+ println!("cargo::rustc-link-lib=dylib=binaryninjacore");
+ println!("cargo::rustc-link-search={}", link_path.to_str().unwrap());
+
+ #[cfg(not(target_os = "windows"))]
+ {
+ println!(
+ "cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}",
+ link_path.to_string_lossy()
+ );
+ }
+
+ let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR specified");
+ let out_dir_path = PathBuf::from(out_dir);
+
+ // Copy all binaries to OUT_DIR for unit tests.
+ let bin_dir: PathBuf = "fixtures/".into();
+ if let Ok(entries) = std::fs::read_dir(bin_dir) {
+ for entry in entries {
+ let entry = entry.unwrap();
+ let path = entry.path();
+ if path.is_file() {
+ let file_name = path.file_name().unwrap();
+ let dest_path = out_dir_path.join(file_name);
+ std::fs::copy(&path, &dest_path).expect("failed to copy binary to OUT_DIR");
+ }
+ }
+ }
+}