summaryrefslogtreecommitdiff
path: root/plugins/svd/demo
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-15 22:49:05 -0400
committerMason Reed <mason@vector35.com>2025-04-15 22:49:05 -0400
commit84eecdfdfd8b972cd9fcafb35da81ed62d9698f9 (patch)
tree5df22437916f11d22278b361a247fd554391f334 /plugins/svd/demo
parent2a2e7980cf78a96396a74e502aaefb04a25d7d1e (diff)
Include SVD loader in free version
Diffstat (limited to 'plugins/svd/demo')
-rw-r--r--plugins/svd/demo/Cargo.toml22
-rw-r--r--plugins/svd/demo/build.rs34
2 files changed, 56 insertions, 0 deletions
diff --git a/plugins/svd/demo/Cargo.toml b/plugins/svd/demo/Cargo.toml
new file mode 100644
index 00000000..0dffba6e
--- /dev/null
+++ b/plugins/svd/demo/Cargo.toml
@@ -0,0 +1,22 @@
+[package]
+name = "svd_ninja-static"
+version = "0.1.0"
+edition = "2021"
+license = "Apache-2.0"
+
+[lib]
+crate-type = ["staticlib", "lib"]
+path = "../src/lib.rs"
+
+[dependencies]
+binaryninja = { workspace = true, features = ["demo"]}
+binaryninjacore-sys.workspace = true
+svd-parser = { version = "0.14.8", features = ["expand"] }
+log = "0.4"
+serde_json = "1.0"
+
+[dev-dependencies]
+insta = { version = "1.42", features = ["yaml"] }
+
+[features]
+demo = [] \ No newline at end of file
diff --git a/plugins/svd/demo/build.rs b/plugins/svd/demo/build.rs
new file mode 100644
index 00000000..637f4779
--- /dev/null
+++ b/plugins/svd/demo/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");
+ }
+ }
+ }
+}