Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/rs-platform-wallet-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ once_cell = "1.19"
parking_lot = { version = "0.12", features = ["send_guard"] }
lazy_static = "1.4"

# Core dependencies (for Network type)
dashcore = { workspace = true }
key-wallet = { workspace = true }
key-wallet-ffi = { workspace = true }

[dev-dependencies]
tempfile = "3.8"
dpp = { path = "../rs-dpp", features = ["fixtures-and-mocks"] }

[build-dependencies]
cbindgen = "0.27"

[features]
default = []
mocks = []
32 changes: 32 additions & 0 deletions packages/rs-platform-wallet-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::path::Path;
use std::{env, fs};

fn main() {
let crate_name = env::var("CARGO_PKG_NAME").unwrap();
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let out_dir = env::var("OUT_DIR").unwrap();

println!("cargo:rerun-if-changed=cbindgen.toml");
println!("cargo:rerun-if-changed=src/");

let target_dir = Path::new(&out_dir)
.ancestors()
.nth(3) // This line moves up to the target/<PROFILE> directory
.expect("Failed to find target dir");

let include_dir = target_dir.join("include").join(&crate_name);

fs::create_dir_all(&include_dir).unwrap();

let output_path = include_dir.join(format!("{}.h", &crate_name));

let config_path = Path::new(&crate_dir).join("cbindgen.toml");
let config = cbindgen::Config::from_file(&config_path).expect("Failed to read cbindgen.toml");

cbindgen::Builder::new()
.with_crate(&crate_dir)
.with_config(config)
.generate()
.expect("Unable to generate bindings")
.write_to_file(&output_path);
}
7 changes: 1 addition & 6 deletions packages/rs-platform-wallet-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include_version = true
namespaces = []
using_namespaces = []
sys_includes = ["stdint.h", "stdbool.h"]
includes = []
includes = ["../key-wallet-ffi/key-wallet-ffi.h"]
no_includes = false
cpp_compat = true
documentation = true
Expand All @@ -22,11 +22,6 @@ exclude = []
prefix = ""
item_types = ["enums", "structs", "unions", "typedefs", "opaque", "functions"]

[export.rename]
"Handle" = "platform_wallet_handle_t"
"PlatformWalletFFIError" = "platform_wallet_error_t"
"PlatformWalletFFIResult" = "platform_wallet_result_t"

[fn]
args = "horizontal"
rename_args = "snake_case"
Expand Down
Loading
Loading