@@ -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 cases (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 cases (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
@@ -2107,9 +2108,9 @@ impl<'test> TestCx<'test> {
2107
2108
}
2108
2109
2109
2110
for ( aux_name, aux_path) in & self . props . aux_crates {
2110
- let is_dylib = self . build_auxiliary ( of, & aux_path, & aux_dir) ;
2111
+ let aux_type = self . build_auxiliary ( of, & aux_path, & aux_dir) ;
2111
2112
let lib_name =
2112
- get_lib_name ( & aux_path. trim_end_matches ( ".rs" ) . replace ( '-' , "_" ) , is_dylib ) ;
2113
+ get_lib_name ( & aux_path. trim_end_matches ( ".rs" ) . replace ( '-' , "_" ) , aux_type ) ;
2113
2114
rustc. arg ( "--extern" ) . arg ( format ! ( "{}={}/{}" , aux_name, aux_dir. display( ) , lib_name) ) ;
2114
2115
}
2115
2116
}
@@ -2131,7 +2132,7 @@ impl<'test> TestCx<'test> {
2131
2132
/// Builds an aux dependency.
2132
2133
///
2133
2134
/// Returns whether or not it is a dylib.
2134
- fn build_auxiliary ( & self , of : & TestPaths , source_path : & str , aux_dir : & Path ) -> bool {
2135
+ fn build_auxiliary ( & self , of : & TestPaths , source_path : & str , aux_dir : & Path ) -> AuxType {
2135
2136
let aux_testpaths = self . compute_aux_test_paths ( of, source_path) ;
2136
2137
let aux_props = self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
2137
2138
let aux_output = TargetLocation :: ThisDirectory ( aux_dir. to_path_buf ( ) ) ;
@@ -2159,8 +2160,8 @@ impl<'test> TestCx<'test> {
2159
2160
}
2160
2161
aux_rustc. envs ( aux_props. rustc_env . clone ( ) ) ;
2161
2162
2162
- let ( dylib , crate_type) = if aux_props. no_prefer_dynamic {
2163
- ( true , None )
2163
+ let ( aux_type , crate_type) = if aux_props. no_prefer_dynamic {
2164
+ ( AuxType :: Dylib , None )
2164
2165
} else if self . config . target . contains ( "emscripten" )
2165
2166
|| ( self . config . target . contains ( "musl" )
2166
2167
&& !aux_props. force_host
@@ -2185,9 +2186,9 @@ impl<'test> TestCx<'test> {
2185
2186
// Coverage tests want static linking by default so that coverage
2186
2187
// mappings in auxiliary libraries can be merged into the final
2187
2188
// executable.
2188
- ( false , Some ( "lib" ) )
2189
+ ( AuxType :: Lib , Some ( "lib" ) )
2189
2190
} else {
2190
- ( true , Some ( "dylib" ) )
2191
+ ( AuxType :: Dylib , Some ( "dylib" ) )
2191
2192
} ;
2192
2193
2193
2194
if let Some ( crate_type) = crate_type {
@@ -2211,7 +2212,7 @@ impl<'test> TestCx<'test> {
2211
2212
& auxres,
2212
2213
) ;
2213
2214
}
2214
- dylib
2215
+ aux_type
2215
2216
}
2216
2217
2217
2218
fn read2_abbreviated ( & self , child : Child ) -> ( Output , Truncated ) {
@@ -4826,3 +4827,8 @@ enum LinkToAux {
4826
4827
Yes ,
4827
4828
No ,
4828
4829
}
4830
+
4831
+ enum AuxType {
4832
+ Lib ,
4833
+ Dylib ,
4834
+ }
0 commit comments