@@ -3,8 +3,20 @@ extern crate bindgen;
33use std:: env;
44use std:: path:: PathBuf ;
55
6- fn main ( ) {
6+ #[ derive( Debug ) ]
7+ struct IgnoreMacros ( String ) ;
8+
9+ impl bindgen:: callbacks:: ParseCallbacks for IgnoreMacros {
10+ fn will_parse_macro ( & self , name : & str ) -> bindgen:: callbacks:: MacroParsingBehavior {
11+ if name == self . 0 {
12+ bindgen:: callbacks:: MacroParsingBehavior :: Ignore
13+ } else {
14+ bindgen:: callbacks:: MacroParsingBehavior :: Default
15+ }
16+ }
17+ }
718
19+ fn main ( ) {
820 // Tell cargo to look for shared libraries in the specified directory
921 let lib_path = PathBuf :: from ( env:: current_dir ( ) . unwrap ( ) ) ;
1022 println ! ( "cargo:rustc-link-search={}" , lib_path. display( ) ) ;
@@ -14,6 +26,8 @@ fn main() {
1426 println ! ( "cargo:rustc-link-lib=secp256k1" ) ;
1527 println ! ( "cargo:rustc-link-lib=sodium" ) ;
1628
29+ let ignored_macros = IgnoreMacros ( "IPPORT_RESERVED" . to_string ( ) ) ;
30+
1731 // The bindgen::Builder is the main entry point
1832 // to bindgen, and lets you build up options for
1933 // the resulting bindings.
@@ -25,6 +39,7 @@ fn main() {
2539 . clang_arg ( "-Ideps/secp256k1/include" )
2640 . clang_arg ( "-Ideps/libsodium/src/libsodium/include" )
2741 . header ( "deps/secp256k1/include/secp256k1.h" )
42+ . parse_callbacks ( Box :: new ( ignored_macros) )
2843 . trust_clang_mangling ( false )
2944 // Finish the builder and generate the bindings.
3045 . generate ( )
0 commit comments