@@ -82,21 +82,22 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
8282}
8383
8484/// 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+ }
100101 }
101102}
102103
@@ -2107,9 +2108,9 @@ impl<'test> TestCx<'test> {
21072108 }
21082109
21092110 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) ;
21112112 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 ) ;
21132114 rustc. arg ( "--extern" ) . arg ( format ! ( "{}={}/{}" , aux_name, aux_dir. display( ) , lib_name) ) ;
21142115 }
21152116 }
@@ -2131,7 +2132,7 @@ impl<'test> TestCx<'test> {
21312132 /// Builds an aux dependency.
21322133 ///
21332134 /// 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 {
21352136 let aux_testpaths = self . compute_aux_test_paths ( of, source_path) ;
21362137 let aux_props = self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
21372138 let aux_output = TargetLocation :: ThisDirectory ( aux_dir. to_path_buf ( ) ) ;
@@ -2159,8 +2160,8 @@ impl<'test> TestCx<'test> {
21592160 }
21602161 aux_rustc. envs ( aux_props. rustc_env . clone ( ) ) ;
21612162
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 )
21642165 } else if self . config . target . contains ( "emscripten" )
21652166 || ( self . config . target . contains ( "musl" )
21662167 && !aux_props. force_host
@@ -2185,9 +2186,9 @@ impl<'test> TestCx<'test> {
21852186 // Coverage tests want static linking by default so that coverage
21862187 // mappings in auxiliary libraries can be merged into the final
21872188 // executable.
2188- ( false , Some ( "lib" ) )
2189+ ( AuxType :: Lib , Some ( "lib" ) )
21892190 } else {
2190- ( true , Some ( "dylib" ) )
2191+ ( AuxType :: Dylib , Some ( "dylib" ) )
21912192 } ;
21922193
21932194 if let Some ( crate_type) = crate_type {
@@ -2211,7 +2212,7 @@ impl<'test> TestCx<'test> {
22112212 & auxres,
22122213 ) ;
22132214 }
2214- dylib
2215+ aux_type
22152216 }
22162217
22172218 fn read2_abbreviated ( & self , child : Child ) -> ( Output , Truncated ) {
@@ -4826,3 +4827,8 @@ enum LinkToAux {
48264827 Yes ,
48274828 No ,
48284829}
4830+
4831+ enum AuxType {
4832+ Lib ,
4833+ Dylib ,
4834+ }
0 commit comments