Browse Source

Use clang as backup for target android

Android ndk r18 remove gnu support, we should use clang instead of gcc
on this one is not present
wintest
edelangh 6 years ago
parent
commit
c6bfd111a0
  1. 29
      src/lib.rs

29
src/lib.rs

@ -1549,10 +1549,10 @@ impl Build {
} }
let host = self.get_host()?; let host = self.get_host()?;
let target = self.get_target()?; let target = self.get_target()?;
let (env, msvc, gnu, traditional) = if self.cpp { let (env, msvc, gnu, traditional, clang) = if self.cpp {
("CXX", "cl.exe", "g++", "c++") ("CXX", "cl.exe", "g++", "c++", "clang++")
} else { } else {
("CC", "cl.exe", "gcc", "cc") ("CC", "cl.exe", "gcc", "cc", "clang")
}; };
// On Solaris, c++/cc unlikely to exist or be correct. // On Solaris, c++/cc unlikely to exist or be correct.
@ -1607,15 +1607,20 @@ impl Build {
format!("{}.exe", gnu) format!("{}.exe", gnu)
} }
} else if target.contains("android") { } else if target.contains("android") {
format!( let target = target
"{}-{}", .replace("armv7", "arm")
target .replace("armv7neon", "arm")
.replace("armv7", "arm") .replace("thumbv7", "arm")
.replace("armv7neon", "arm") .replace("thumbv7neon", "arm");
.replace("thumbv7", "arm") let gnu_compiler = format!("{}-{}", target, gnu);
.replace("thumbv7neon", "arm"), let clang_compiler = format!("{}-{}", target, clang);
gnu // Check if gnu compiler is present
) // if not, use clang
if Command::new(&gnu_compiler).spawn().is_ok() {
gnu_compiler
} else {
clang_compiler
}
} else if target.contains("cloudabi") { } else if target.contains("cloudabi") {
format!("{}-{}", target, traditional) format!("{}-{}", target, traditional)
} else if self.get_host()? != target { } else if self.get_host()? != target {

Loading…
Cancel
Save