@@ -66,6 +66,7 @@ use std::path::{Path, PathBuf};
66
66
use std:: process:: { Child , Command , Stdio } ;
67
67
use std:: sync:: { Arc , Mutex } ;
68
68
use std:: thread:: { self , JoinHandle } ;
69
+ use regex:: Regex ;
69
70
70
71
// These modules are all glue to support reading the MSVC version from
71
72
// the registry and from COM interfaces
@@ -2839,9 +2840,18 @@ static NEW_STANDALONE_ANDROID_COMPILERS: [&str; 4] = [
2839
2840
// So to construct proper command line check if
2840
2841
// `--target` argument would be passed or not to clang
2841
2842
fn android_clang_compiler_uses_target_arg_internally ( clang_path : & Path ) -> bool {
2842
- NEW_STANDALONE_ANDROID_COMPILERS
2843
- . iter ( )
2844
- . any ( |x| Some ( x. as_ref ( ) ) == clang_path. file_name ( ) )
2843
+ let re = Regex :: new ( r"^.*\d{2}-clang(\+\+)?$" ) . unwrap ( ) ;
2844
+ re. is_match ( clang_path. to_str ( ) . unwrap ( ) )
2845
+ }
2846
+
2847
+ #[ test]
2848
+ fn test_android_clang_compiler_uses_target_arg_internally ( ) {
2849
+ for version in 16 ..21 {
2850
+ assert ! ( android_clang_compiler_uses_target_arg_internally( & PathBuf :: from( format!( "armv7a-linux-androideabi{}-clang" , version) ) ) ) ;
2851
+ assert ! ( android_clang_compiler_uses_target_arg_internally( & PathBuf :: from( format!( "armv7a-linux-androideabi{}-clang++" , version) ) ) ) ;
2852
+ }
2853
+ assert ! ( !android_clang_compiler_uses_target_arg_internally( & PathBuf :: from( "clang" ) ) ) ;
2854
+ assert ! ( !android_clang_compiler_uses_target_arg_internally( & PathBuf :: from( "clang++" ) ) ) ;
2845
2855
}
2846
2856
2847
2857
fn autodetect_android_compiler ( target : & str , host : & str , gnu : & str , clang : & str ) -> String {
0 commit comments