lnsocket

A minimal C library for connecting to the lightning network
git clone git://jb55.com/lnsocket
Log | Files | Refs | Submodules | README | LICENSE

commit 5080a331b88fcd3fc85938c89df5fe27af956e2e
parent 1d453b6089ee56bb6f9bf7798a006fbc59639ca7
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  7 Jul 2022 08:53:20 -0700

rust: fix build on nixos

Running into these issues: https://github.com/rust-lang/rust-bindgen/issues/687

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mbuild.rs | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/build.rs b/build.rs @@ -3,8 +3,20 @@ extern crate bindgen; use std::env; use std::path::PathBuf; -fn main() { +#[derive(Debug)] +struct IgnoreMacros(String); + +impl bindgen::callbacks::ParseCallbacks for IgnoreMacros { + fn will_parse_macro(&self, name: &str) -> bindgen::callbacks::MacroParsingBehavior { + if name == self.0 { + bindgen::callbacks::MacroParsingBehavior::Ignore + } else { + bindgen::callbacks::MacroParsingBehavior::Default + } + } +} +fn main() { // Tell cargo to look for shared libraries in the specified directory let lib_path = PathBuf::from(env::current_dir().unwrap()); println!("cargo:rustc-link-search={}", lib_path.display()); @@ -14,6 +26,8 @@ fn main() { println!("cargo:rustc-link-lib=secp256k1"); println!("cargo:rustc-link-lib=sodium"); + let ignored_macros = IgnoreMacros("IPPORT_RESERVED".to_string()); + // The bindgen::Builder is the main entry point // to bindgen, and lets you build up options for // the resulting bindings. @@ -25,6 +39,7 @@ fn main() { .clang_arg("-Ideps/secp256k1/include") .clang_arg("-Ideps/libsodium/src/libsodium/include") .header("deps/secp256k1/include/secp256k1.h") + .parse_callbacks(Box::new(ignored_macros)) .trust_clang_mangling(false) // Finish the builder and generate the bindings. .generate()