@@ -3,8 +3,20 @@ extern crate bindgen;
3
3
use std:: env;
4
4
use std:: path:: PathBuf ;
5
5
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
+ }
7
18
19
+ fn main ( ) {
8
20
// Tell cargo to look for shared libraries in the specified directory
9
21
let lib_path = PathBuf :: from ( env:: current_dir ( ) . unwrap ( ) ) ;
10
22
println ! ( "cargo:rustc-link-search={}" , lib_path. display( ) ) ;
@@ -14,6 +26,8 @@ fn main() {
14
26
println ! ( "cargo:rustc-link-lib=secp256k1" ) ;
15
27
println ! ( "cargo:rustc-link-lib=sodium" ) ;
16
28
29
+ let ignored_macros = IgnoreMacros ( "IPPORT_RESERVED" . to_string ( ) ) ;
30
+
17
31
// The bindgen::Builder is the main entry point
18
32
// to bindgen, and lets you build up options for
19
33
// the resulting bindings.
@@ -25,6 +39,7 @@ fn main() {
25
39
. clang_arg ( "-Ideps/secp256k1/include" )
26
40
. clang_arg ( "-Ideps/libsodium/src/libsodium/include" )
27
41
. header ( "deps/secp256k1/include/secp256k1.h" )
42
+ . parse_callbacks ( Box :: new ( ignored_macros) )
28
43
. trust_clang_mangling ( false )
29
44
// Finish the builder and generate the bindings.
30
45
. generate ( )
0 commit comments