@@ -8,8 +8,6 @@ fn main() {
8
8
9
9
#[ cfg( feature = "static" ) ]
10
10
println ! ( "cargo:rerun-if-changed=/usr/lib/pacman/lib/pkgconfig" ) ;
11
- #[ cfg( feature = "static" ) ]
12
- println ! ( "cargo:rustc-link-search=/usr/lib/pacman/lib/" ) ;
13
11
println ! ( "cargo:rerun-if-env-changed=ALPM_LIB_DIR" ) ;
14
12
15
13
if cfg ! ( feature = "static" ) && Path :: new ( "/usr/lib/pacman/lib/pkgconfig" ) . exists ( ) {
@@ -20,31 +18,41 @@ fn main() {
20
18
println ! ( "cargo:rustc-link-search={}" , dir) ;
21
19
}
22
20
23
- pkg_config:: Config :: new ( )
21
+ #[ allow( dead_code) ]
22
+ let lib = pkg_config:: Config :: new ( )
24
23
. atleast_version ( "13.0.0" )
25
24
. statik ( cfg ! ( feature = "static" ) )
26
25
. probe ( "libalpm" )
27
26
. unwrap ( ) ;
28
27
29
28
#[ cfg( feature = "generate" ) ]
30
29
{
31
- println ! ( "cargo:rerun-if-env-changed=ALPM_INCLUDE_DIR" ) ;
32
-
33
30
let out_dir = env:: var_os ( "OUT_DIR" ) . unwrap ( ) ;
34
31
let dest_path = Path :: new ( & out_dir) . join ( "ffi_generated.rs" ) ;
35
32
36
- let alpm_dir = env:: var ( "ALPM_INCLUDE_DIR" ) ;
37
- let alpm_dir = match alpm_dir {
38
- Ok ( ref dir) => Path :: new ( dir) ,
39
- Err ( _) => Path :: new ( "/usr/include" ) ,
40
- } ;
33
+ let header = lib
34
+ . include_paths
35
+ . iter ( )
36
+ . map ( |i| i. join ( "alpm.h" ) )
37
+ . find ( |i| i. exists ( ) )
38
+ . expect ( "could not find alpm.h" ) ;
39
+ let mut include = lib
40
+ . include_paths
41
+ . iter ( )
42
+ . map ( |i| format ! ( "-I{}" , i. display( ) . to_string( ) ) )
43
+ . collect :: < Vec < _ > > ( ) ;
41
44
42
- let header = alpm_dir. join ( "alpm.h" ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
45
+ println ! ( "cargo:rerun-if-env-changed=ALPM_INCLUDE_DIR" ) ;
46
+ if let Ok ( path) = env:: var ( "ALPM_INCLUDE_DIR" ) {
47
+ include. clear ( ) ;
48
+ include. insert ( 0 , path) ;
49
+ }
43
50
44
51
let bindings = bindgen:: builder ( )
45
- . header ( header)
46
- . whitelist_type ( "(alpm|ALPM).*" )
47
- . whitelist_function ( "(alpm|ALPM).*" )
52
+ . clang_args ( & include)
53
+ . header ( header. display ( ) . to_string ( ) )
54
+ . allowlist_type ( "(alpm|ALPM).*" )
55
+ . allowlist_function ( "(alpm|ALPM).*" )
48
56
. rustified_enum ( "_alpm_[a-z_]+_t" )
49
57
. rustified_enum ( "alpm_download_event_type_t" )
50
58
. constified_enum_module ( "_alpm_siglevel_t" )
@@ -60,6 +68,13 @@ fn main() {
60
68
. opaque_type ( "alpm_pkg_t" )
61
69
. opaque_type ( "alpm_trans_t" )
62
70
. size_t_is_usize ( true )
71
+ . derive_eq ( true )
72
+ . derive_ord ( true )
73
+ . derive_copy ( true )
74
+ . derive_hash ( true )
75
+ . derive_debug ( true )
76
+ . derive_partialeq ( true )
77
+ . derive_debug ( true )
63
78
. generate ( )
64
79
. unwrap ( ) ;
65
80
0 commit comments