@@ -14,17 +14,22 @@ use std::os;
14
14
use std:: io:: IoError ;
15
15
use syntax:: ast;
16
16
17
- pub struct RPathConfig < ' a > {
17
+ pub struct RPathConfig < F , G > where
18
+ F : FnOnce ( ) -> Path ,
19
+ G : FnMut ( & Path ) -> Result < Path , IoError > ,
20
+ {
18
21
pub used_crates : Vec < ( ast:: CrateNum , Option < Path > ) > ,
19
22
pub out_filename : Path ,
20
23
pub is_like_osx : bool ,
21
24
pub has_rpath : bool ,
22
- pub get_install_prefix_lib_path : || : ' a -> Path ,
23
- pub realpath: | & Path | : ' a -> Result < Path , IoError >
25
+ pub get_install_prefix_lib_path : F ,
26
+ pub realpath : G ,
24
27
}
25
28
26
- pub fn get_rpath_flags( config: RPathConfig ) -> Vec < String > {
27
-
29
+ pub fn get_rpath_flags < F , G > ( config : RPathConfig < F , G > ) -> Vec < String > where
30
+ F : FnOnce ( ) -> Path ,
31
+ G : FnMut ( & Path ) -> Result < Path , IoError > ,
32
+ {
28
33
// No rpath on windows
29
34
if !config. has_rpath {
30
35
return Vec :: new ( ) ;
@@ -52,8 +57,10 @@ fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
52
57
return ret;
53
58
}
54
59
55
- fn get_rpaths ( mut config : RPathConfig ,
56
- libs : & [ Path ] ) -> Vec < String > {
60
+ fn get_rpaths < F , G > ( mut config : RPathConfig < F , G > , libs : & [ Path ] ) -> Vec < String > where
61
+ F : FnOnce ( ) -> Path ,
62
+ G : FnMut ( & Path ) -> Result < Path , IoError > ,
63
+ {
57
64
debug ! ( "output: {}" , config. out_filename. display( ) ) ;
58
65
debug ! ( "libs:" ) ;
59
66
for libpath in libs. iter ( ) {
@@ -86,13 +93,18 @@ fn get_rpaths(mut config: RPathConfig,
86
93
return rpaths;
87
94
}
88
95
89
- fn get_rpaths_relative_to_output ( config : & mut RPathConfig ,
90
- libs : & [ Path ] ) -> Vec < String > {
96
+ fn get_rpaths_relative_to_output < F , G > ( config : & mut RPathConfig < F , G > ,
97
+ libs : & [ Path ] ) -> Vec < String > where
98
+ F : FnOnce ( ) -> Path ,
99
+ G : FnMut ( & Path ) -> Result < Path , IoError > ,
100
+ {
91
101
libs. iter ( ) . map ( |a| get_rpath_relative_to_output ( config, a) ) . collect ( )
92
102
}
93
103
94
- fn get_rpath_relative_to_output ( config : & mut RPathConfig ,
95
- lib : & Path ) -> String {
104
+ fn get_rpath_relative_to_output < F , G > ( config : & mut RPathConfig < F , G > , lib : & Path ) -> String where
105
+ F : FnOnce ( ) -> Path ,
106
+ G : FnMut ( & Path ) -> Result < Path , IoError > ,
107
+ {
96
108
use std:: os;
97
109
98
110
// Mac doesn't appear to support $ORIGIN
@@ -114,7 +126,10 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig,
114
126
relative. as_str( ) . expect( "non-utf8 component in path" ) )
115
127
}
116
128
117
- fn get_install_prefix_rpath ( config : RPathConfig ) -> String {
129
+ fn get_install_prefix_rpath < F , G > ( config : RPathConfig < F , G > ) -> String where
130
+ F : FnOnce ( ) -> Path ,
131
+ G : FnMut ( & Path ) -> Result < Path , IoError > ,
132
+ {
118
133
let path = ( config. get_install_prefix_lib_path ) ( ) ;
119
134
let path = os:: make_absolute ( & path) . unwrap ( ) ;
120
135
// FIXME (#9639): This needs to handle non-utf8 paths
0 commit comments