@@ -168,23 +168,7 @@ fn set_compiler(
168168 // compiler already takes into account the triple in question.
169169 t if t. contains ( "android" ) => {
170170 if let Some ( ndk) = config. and_then ( |c| c. ndk . as_ref ( ) ) {
171- let mut triple_iter = target. triple . split ( "-" ) ;
172- let triple_translated = if let Some ( arch) = triple_iter. next ( ) {
173- let arch_new = match arch {
174- "arm" | "armv7" | "armv7neon" | "thumbv7" | "thumbv7neon" => "armv7a" ,
175- other => other,
176- } ;
177- std:: iter:: once ( arch_new) . chain ( triple_iter) . collect :: < Vec < & str > > ( ) . join ( "-" )
178- } else {
179- target. triple . to_string ( )
180- } ;
181-
182- // API 19 is the earliest API level supported by NDK r25b but AArch64 and x86_64 support
183- // begins at API level 21.
184- let api_level =
185- if t. contains ( "aarch64" ) || t. contains ( "x86_64" ) { "21" } else { "19" } ;
186- let compiler = format ! ( "{}{}-{}" , triple_translated, api_level, compiler. clang( ) ) ;
187- cfg. compiler ( ndk. join ( "bin" ) . join ( compiler) ) ;
171+ cfg. compiler ( ndk_compiler ( compiler, & * target. triple , ndk) ) ;
188172 }
189173 }
190174
@@ -236,8 +220,28 @@ fn set_compiler(
236220 }
237221}
238222
223+ pub ( crate ) fn ndk_compiler ( compiler : Language , triple : & str , ndk : & Path ) -> PathBuf {
224+ let mut triple_iter = triple. split ( "-" ) ;
225+ let triple_translated = if let Some ( arch) = triple_iter. next ( ) {
226+ let arch_new = match arch {
227+ "arm" | "armv7" | "armv7neon" | "thumbv7" | "thumbv7neon" => "armv7a" ,
228+ other => other,
229+ } ;
230+ std:: iter:: once ( arch_new) . chain ( triple_iter) . collect :: < Vec < & str > > ( ) . join ( "-" )
231+ } else {
232+ triple. to_string ( )
233+ } ;
234+
235+ // API 19 is the earliest API level supported by NDK r25b but AArch64 and x86_64 support
236+ // begins at API level 21.
237+ let api_level =
238+ if triple. contains ( "aarch64" ) || triple. contains ( "x86_64" ) { "21" } else { "19" } ;
239+ let compiler = format ! ( "{}{}-{}" , triple_translated, api_level, compiler. clang( ) ) ;
240+ ndk. join ( "bin" ) . join ( compiler)
241+ }
242+
239243/// The target programming language for a native compiler.
240- enum Language {
244+ pub ( crate ) enum Language {
241245 /// The compiler is targeting C.
242246 C ,
243247 /// The compiler is targeting C++.
0 commit comments