Skip to content

Commit 3855c54

Browse files
committed
compiletest: cleanup dylib name calculation
1 parent 11e5724 commit 3855c54

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/tools/compiletest/src/runtest.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -82,26 +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, aux_type: AuxType) -> Option<String> {
85+
fn get_lib_name(name: &str, aux_type: AuxType) -> Option<String> {
8686
match aux_type {
8787
AuxType::Bin => None,
8888
// In some cases (e.g. MUSL), we build a static
8989
// library, rather than a dynamic library.
9090
// In this case, the only path we can pass
9191
// with '--extern-meta' is the '.rlib' file
92-
AuxType::Lib => Some(format!("lib{}.rlib", lib)),
93-
AuxType::Dylib => Some(if cfg!(windows) {
94-
format!("{}.dll", lib)
95-
} else if cfg!(target_vendor = "apple") {
96-
format!("lib{}.dylib", lib)
97-
} else if cfg!(target_os = "aix") {
98-
format!("lib{}.a", lib)
99-
} else {
100-
format!("lib{}.so", lib)
101-
}),
92+
AuxType::Lib => Some(format!("lib{name}.rlib")),
93+
AuxType::Dylib => Some(dylib_name(name)),
10294
}
10395
}
10496

97+
fn dylib_name(name: &str) -> String {
98+
format!("{}{name}.{}", std::env::consts::DLL_PREFIX, std::env::consts::DLL_EXTENSION)
99+
}
100+
105101
pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
106102
match &*config.target {
107103
"arm-linux-androideabi"

0 commit comments

Comments
 (0)