Skip to content

Commit da69068

Browse files
Detect standalone android compiler with regex (#539)
* Detect standalone android compiler with regex * Remove regex dependency
1 parent a970b0a commit da69068

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/lib.rs

+27-3
Original file line numberDiff line numberDiff line change
@@ -2883,9 +2883,33 @@ static NEW_STANDALONE_ANDROID_COMPILERS: [&str; 4] = [
28832883
// So to construct proper command line check if
28842884
// `--target` argument would be passed or not to clang
28852885
fn android_clang_compiler_uses_target_arg_internally(clang_path: &Path) -> bool {
2886-
NEW_STANDALONE_ANDROID_COMPILERS
2887-
.iter()
2888-
.any(|x| Some(x.as_ref()) == clang_path.file_name())
2886+
if let Some(filename) = clang_path.file_name() {
2887+
if let Some(filename_str) = filename.to_str() {
2888+
filename_str.contains("android")
2889+
} else {
2890+
false
2891+
}
2892+
} else {
2893+
false
2894+
}
2895+
}
2896+
2897+
#[test]
2898+
fn test_android_clang_compiler_uses_target_arg_internally() {
2899+
for version in 16..21 {
2900+
assert!(android_clang_compiler_uses_target_arg_internally(
2901+
&PathBuf::from(format!("armv7a-linux-androideabi{}-clang", version))
2902+
));
2903+
assert!(android_clang_compiler_uses_target_arg_internally(
2904+
&PathBuf::from(format!("armv7a-linux-androideabi{}-clang++", version))
2905+
));
2906+
}
2907+
assert!(!android_clang_compiler_uses_target_arg_internally(
2908+
&PathBuf::from("clang")
2909+
));
2910+
assert!(!android_clang_compiler_uses_target_arg_internally(
2911+
&PathBuf::from("clang++")
2912+
));
28892913
}
28902914

28912915
fn autodetect_android_compiler(target: &str, host: &str, gnu: &str, clang: &str) -> String {

0 commit comments

Comments
 (0)