From 7f93b664d40cbc8f0d9622d78f1ab3d2b994661f Mon Sep 17 00:00:00 2001 From: Jackson Coxson Date: Mon, 24 Mar 2025 15:30:39 -0600 Subject: [PATCH] Automatically generate header with cbindgen --- ffi/Cargo.toml | 20 ++++++++++++++++++++ ffi/build.rs | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 ffi/Cargo.toml create mode 100644 ffi/build.rs diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml new file mode 100644 index 0000000..5efdeef --- /dev/null +++ b/ffi/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "idevice-ffi" +version = "0.1.0" +edition = "2024" + + +[dependencies] +idevice = { path = "../idevice", features = ["full"] } +log = "0.4.26" +simplelog = "0.12.2" +once_cell = "1.21.1" +tokio = { version = "1.44.1", features = ["full"] } +libc = "0.2.171" +openssl-sys = { version = "0.9", features = ["vendored"] } + +[build-dependencies] +cbindgen = "0.28.0" + +[lib] +crate-type = ["staticlib", "cdylib"] diff --git a/ffi/build.rs b/ffi/build.rs new file mode 100644 index 0000000..efb8dc2 --- /dev/null +++ b/ffi/build.rs @@ -0,0 +1,18 @@ +// Jackson Coxson + +use std::env; + +fn main() { + let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + + cbindgen::Builder::new() + .with_crate(crate_dir) + .with_header( + "// Jackson Coxson\n// Bindings to idevice - https://github.com/jkcoxson/idevice", + ) + .with_language(cbindgen::Language::C) + .with_sys_include("sys/socket.h") + .generate() + .expect("Unable to generate bindings") + .write_to_file("idevice.h"); +}