@@ -82,21 +82,22 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
82
82
}
83
83
84
84
/// The platform-specific library name
85
- fn get_lib_name ( lib : & str , dylib : bool ) -> String {
86
- // In some casess (e.g. MUSL), we build a static
87
- // library, rather than a dynamic library.
88
- // In this case, the only path we can pass
89
- // with '--extern-meta' is the '.rlib' file
90
- if !dylib {
91
- return format ! ( "lib{}.rlib" , lib) ;
92
- }
93
-
94
- if cfg ! ( windows) {
95
- format ! ( "{}.dll" , lib)
96
- } else if cfg ! ( target_os = "macos" ) {
97
- format ! ( "lib{}.dylib" , lib)
98
- } else {
99
- format ! ( "lib{}.so" , lib)
85
+ fn get_lib_name ( lib : & str , aux_type : AuxType ) -> String {
86
+ match aux_type {
87
+ // In some casess (e.g. MUSL), we build a static
88
+ // library, rather than a dynamic library.
89
+ // In this case, the only path we can pass
90
+ // with '--extern-meta' is the '.rlib' file
91
+ AuxType :: Lib => format ! ( "lib{}.rlib" , lib) ,
92
+ AuxType :: Dylib => {
93
+ if cfg ! ( windows) {
94
+ format ! ( "{}.dll" , lib)
95
+ } else if cfg ! ( target_os = "macos" ) {
96
+ format ! ( "lib{}.dylib" , lib)
97
+ } else {
98
+ format ! ( "lib{}.so" , lib)
99
+ }
100
+ }
100
101
}
101
102
}
102
103
@@ -2148,9 +2149,9 @@ impl<'test> TestCx<'test> {
2148
2149
}
2149
2150
2150
2151
for ( aux_name, aux_path) in & self . props . aux_crates {
2151
- let is_dylib = self . build_auxiliary ( of, & aux_path, & aux_dir) ;
2152
+ let aux_type = self . build_auxiliary ( of, & aux_path, & aux_dir) ;
2152
2153
let lib_name =
2153
- get_lib_name ( & aux_path. trim_end_matches ( ".rs" ) . replace ( '-' , "_" ) , is_dylib ) ;
2154
+ get_lib_name ( & aux_path. trim_end_matches ( ".rs" ) . replace ( '-' , "_" ) , aux_type ) ;
2154
2155
rustc. arg ( "--extern" ) . arg ( format ! ( "{}={}/{}" , aux_name, aux_dir. display( ) , lib_name) ) ;
2155
2156
}
2156
2157
}
@@ -2172,7 +2173,7 @@ impl<'test> TestCx<'test> {
2172
2173
/// Builds an aux dependency.
2173
2174
///
2174
2175
/// Returns whether or not it is a dylib.
2175
- fn build_auxiliary ( & self , of : & TestPaths , source_path : & str , aux_dir : & Path ) -> bool {
2176
+ fn build_auxiliary ( & self , of : & TestPaths , source_path : & str , aux_dir : & Path ) -> AuxType {
2176
2177
let aux_testpaths = self . compute_aux_test_paths ( of, source_path) ;
2177
2178
let aux_props = self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
2178
2179
let aux_output = TargetLocation :: ThisDirectory ( aux_dir. to_path_buf ( ) ) ;
@@ -2200,8 +2201,8 @@ impl<'test> TestCx<'test> {
2200
2201
}
2201
2202
aux_rustc. envs ( aux_props. rustc_env . clone ( ) ) ;
2202
2203
2203
- let ( dylib , crate_type) = if aux_props. no_prefer_dynamic {
2204
- ( true , None )
2204
+ let ( aux_type , crate_type) = if aux_props. no_prefer_dynamic {
2205
+ ( AuxType :: Dylib , None )
2205
2206
} else if self . config . target . contains ( "emscripten" )
2206
2207
|| ( self . config . target . contains ( "musl" )
2207
2208
&& !aux_props. force_host
@@ -2226,9 +2227,9 @@ impl<'test> TestCx<'test> {
2226
2227
// Coverage tests want static linking by default so that coverage
2227
2228
// mappings in auxiliary libraries can be merged into the final
2228
2229
// executable.
2229
- ( false , Some ( "lib" ) )
2230
+ ( AuxType :: Lib , Some ( "lib" ) )
2230
2231
} else {
2231
- ( true , Some ( "dylib" ) )
2232
+ ( AuxType :: Dylib , Some ( "dylib" ) )
2232
2233
} ;
2233
2234
2234
2235
if let Some ( crate_type) = crate_type {
@@ -2252,7 +2253,7 @@ impl<'test> TestCx<'test> {
2252
2253
& auxres,
2253
2254
) ;
2254
2255
}
2255
- dylib
2256
+ aux_type
2256
2257
}
2257
2258
2258
2259
fn read2_abbreviated ( & self , child : Child ) -> ( Output , Truncated ) {
@@ -4910,3 +4911,8 @@ enum LinkToAux {
4910
4911
Yes ,
4911
4912
No ,
4912
4913
}
4914
+
4915
+ enum AuxType {
4916
+ Lib ,
4917
+ Dylib ,
4918
+ }
0 commit comments