Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dash-spv-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ env_logger = "0.10"
dashcore-test-utils = { path = "../test-utils" }

[build-dependencies]
cbindgen = "0.26"
cbindgen = "0.29"
2 changes: 1 addition & 1 deletion dash-spv-ffi/FFI_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ Sets whether to relay transactions (currently a no-op) # Safety - `config` must
#### `dash_spv_ffi_config_set_restrict_to_configured_peers`

```c
dash_spv_ffi_config_set_restrict_to_configured_peers(config: *mut FFIClientConfig, restrict: bool,) -> i32
dash_spv_ffi_config_set_restrict_to_configured_peers(config: *mut FFIClientConfig, restrict_peers: bool,) -> i32
```

**Description:**
Expand Down
23 changes: 15 additions & 8 deletions dash-spv-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ fn main() {

std::fs::create_dir_all(&output_path).unwrap();

let config = cbindgen::Config::default();
// Ensure the build script reruns when header-relevant files change
println!("cargo:rerun-if-changed=cbindgen.toml");
println!("cargo:rerun-if-changed=src");

cbindgen::Builder::new()
.with_crate(crate_dir)
.with_config(config)
.with_language(cbindgen::Language::C)
.generate()
.expect("Unable to generate bindings")
.write_to_file(output_path.join("dash_spv_ffi.h"));
let config = cbindgen::Config::from_file("cbindgen.toml").unwrap_or_default();

match cbindgen::Builder::new().with_crate(&crate_dir).with_config(config).generate() {
Ok(bindings) => {
bindings.write_to_file(output_path.join("dash_spv_ffi.h"));
println!("cargo:warning=Generated C header at {:?}", output_path);
}
Err(e) => {
// Fail the build to avoid shipping stale headers
panic!("Failed to generate C header via cbindgen: {}", e);
}
}
}
8 changes: 6 additions & 2 deletions dash-spv-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ cpp_compat = true
[export]
include = ["FFI"]
exclude = ["Option_BlockCallback", "Option_TransactionCallback", "Option_BalanceCallback"]
prefix = "dash_spv_ffi_"
prefix = ""

[export.body]
# Forward-declare FFIClientConfig to avoid aliasing to internal ClientConfig in C headers
"FFIClientConfig" = ""

[export.rename]
"FFIValidationMode" = "DashSpvValidationMode"
Expand All @@ -32,4 +36,4 @@ parse_deps = false
include = []

[macro_expansion]
bitflags = false
bitflags = false
Loading
Loading