Skip to content

Commit 57853c4

Browse files
jfgoogChrisDenton
authored andcommittedMay 18, 2023
Be more stringent about handling Android NDK.
Wrapper scripts for the NDK have the format <target>-<clang>, so when checking to see if the filename contains "android" (which will be part of the target), split off the target part of the filename and only check that, instead of checking the entire filename. This is a very minor improvement, but it is more correct and does have a practical benefit for us on the Android toolchain team: Our build process for rustc uses wrapper scripts that include the target in their name, and the cc crate is misidentifying them as being from the NDK and causing our Windows build to fail without a workaround.
1 parent 57df37c commit 57853c4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎src/lib.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -3616,13 +3616,12 @@ static NEW_STANDALONE_ANDROID_COMPILERS: [&str; 4] = [
36163616
fn android_clang_compiler_uses_target_arg_internally(clang_path: &Path) -> bool {
36173617
if let Some(filename) = clang_path.file_name() {
36183618
if let Some(filename_str) = filename.to_str() {
3619-
filename_str.contains("android")
3620-
} else {
3621-
false
3619+
if let Some(idx) = filename_str.rfind("-") {
3620+
return filename_str.split_at(idx).0.contains("android");
3621+
}
36223622
}
3623-
} else {
3624-
false
36253623
}
3624+
false
36263625
}
36273626

36283627
#[test]
@@ -3635,6 +3634,9 @@ fn test_android_clang_compiler_uses_target_arg_internally() {
36353634
&PathBuf::from(format!("armv7a-linux-androideabi{}-clang++", version))
36363635
));
36373636
}
3637+
assert!(!android_clang_compiler_uses_target_arg_internally(
3638+
&PathBuf::from("clang-i686-linux-android")
3639+
));
36383640
assert!(!android_clang_compiler_uses_target_arg_internally(
36393641
&PathBuf::from("clang")
36403642
));

0 commit comments

Comments
 (0)