commit 606b94e00d5386f9c2ee2a4a7b723c394117181f
parent 5517c12a04f0726a04c482fae1a77e8e4970b5bc
Author: William Casarin <jb55@jb55.com>
Date: Sat, 30 Dec 2023 11:41:26 -0800
add bindgen feature
This allows us to conditionally regenerate bindings using --features bindgen
Diffstat:
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
@@ -12,6 +12,10 @@ repository = "https://github.com/damus-io/nostrdb-rs/"
[build-dependencies]
cc = "1.0"
+bindgen = "0.69.1"
+
+[features]
+bindgen = []
[dependencies]
env_logger = "0.10.1"
@@ -21,4 +25,3 @@ log = "0.4.20"
[dev-dependencies]
hex = "0.4.3"
-#bindgen = "0.69.1" // re-enable when we update bindings
diff --git a/build.rs b/build.rs
@@ -86,11 +86,11 @@ fn main() {
// Re-run the build script if any of the C files or headers change
for file in &[
- "nostrdb/nostrdb.c",
- "nostrdb/sha256.c",
- "nostrdb/bech32.c",
- "nostrdb/nostrdb.h",
- "nostrdb/sha256.h",
+ "nostrdb/src/nostrdb.c",
+ "nostrdb/src/sha256.c",
+ "nostrdb/src/bech32.c",
+ "nostrdb/src/nostrdb.h",
+ "nostrdb/src/sha256.h",
] {
println!("cargo:rerun-if-changed={}", file);
}
@@ -107,14 +107,15 @@ fn main() {
// I don't want to complicate the build with it.
//
- /*
- let bindings = bindgen::Builder::default()
- .header("nostrdb/nostrdb.h")
- .generate()
- .expect("Unable to generate bindings");
+ #[cfg(feature = "bindgen")]
+ {
+ let bindings = bindgen::Builder::default()
+ .header("nostrdb/src/nostrdb.h")
+ .generate()
+ .expect("Unable to generate bindings");
- bindings
- .write_to_file("src/bindings.rs")
- .expect("Couldn't write bindings!");
- */
+ bindings
+ .write_to_file("src/bindings.rs")
+ .expect("Couldn't write bindings!");
+ }
}