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
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions packages/rs-platform-wallet-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ zeroize = { version = "1", features = ["derive"] }
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);
}
53 changes: 0 additions & 53 deletions packages/rs-platform-wallet-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -1,78 +1,25 @@
# cbindgen configuration for Platform Wallet FFI

language = "C"
pragma_once = true
include_guard = "PLATFORM_WALLET_FFI_H"
autogen_warning = "/* This file is auto-generated. Do not modify manually. */"
include_version = true
namespaces = []
using_namespaces = []
sys_includes = ["stdint.h", "stdbool.h"]
includes = []
no_includes = false
cpp_compat = true
documentation = true
documentation_style = "c99"

# Forward-declare external Rust types referenced opaquely in this
# crate's FFI signatures. cbindgen cannot introspect external crates,
# so without this injection the generated header references `Sdk *`
# with no type declaration, causing the Swift build to fail with
# `unknown type name 'Sdk'`. The build_ios.sh post-processor expands
# these forward declarations into `typedef struct X { uint8_t _opaque; } X;`.
after_includes = """
typedef struct Sdk Sdk;
"""

[defines]

[export]
include = ["platform_wallet_*", "identity_manager_*", "managed_identity_*", "contact_request_*", "established_contact_*"]
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"
must_use = "PLATFORM_WALLET_WARN_UNUSED_RESULT"
prefix = ""
postfix = ""

[struct]
rename_fields = "snake_case"
derive_constructor = false
derive_eq = false
derive_neq = false
derive_lt = false
derive_lte = false
derive_gt = false
derive_gte = false

[enum]
rename_variants = "ScreamingSnakeCase"
add_sentinel = false
prefix_with_name = true
derive_helper_methods = false
derive_const_casts = false
derive_mut_casts = false
cast_assert_name = "assert"
must_use = "PLATFORM_WALLET_WARN_UNUSED_RESULT"

[const]
allow_static_const = true
allow_constexpr = false
sort_by = "name"

[macro_expansion]
bitflags = false

[parse]
parse_deps = false
include = []
exclude = []
Loading
Loading