Refactor: Extract target::linux::create_targets_str

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-08-04 17:38:27 +10:00
parent 7997c73cb2
commit a686aca08c
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -139,12 +139,7 @@ mod linux {
// Glibc can only be dynamically linked.
// If we can run this binary, then it means that the target
// supports both glibc and musl.
Libc::Glibc => {
return vec![
create_target_str("gnu", abi),
create_target_str("musl", abi),
]
}
Libc::Glibc => return create_targets_str(&["gnu", "musl"], abi),
_ => (),
}
@ -164,10 +159,7 @@ mod linux {
};
if libc_version == "gnu" {
return vec![
create_target_str("gnu", abi),
create_target_str("musl", abi),
];
return create_targets_str(&["gnu", "musl"], abi);
}
}
@ -211,6 +203,13 @@ mod linux {
format!("{prefix}-{libc_version}{abi}")
}
fn create_targets_str(libc_versions: &[&str], abi: &str) -> Vec<String> {
libc_version
.iter()
.map(|libc_version| create_target_str(libc_version, abi))
.collect()
}
}
#[cfg(target_os = "macos")]