Skip to content

Commit 3e7d042

Browse files
authored
Merge pull request #334 from edelangh/use_clang_ndk_r18
Use clang for target android
2 parents 28f5e34 + c6bfd11 commit 3e7d042

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/lib.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,10 +1549,10 @@ impl Build {
15491549
}
15501550
let host = self.get_host()?;
15511551
let target = self.get_target()?;
1552-
let (env, msvc, gnu, traditional) = if self.cpp {
1553-
("CXX", "cl.exe", "g++", "c++")
1552+
let (env, msvc, gnu, traditional, clang) = if self.cpp {
1553+
("CXX", "cl.exe", "g++", "c++", "clang++")
15541554
} else {
1555-
("CC", "cl.exe", "gcc", "cc")
1555+
("CC", "cl.exe", "gcc", "cc", "clang")
15561556
};
15571557

15581558
// On Solaris, c++/cc unlikely to exist or be correct.
@@ -1607,15 +1607,20 @@ impl Build {
16071607
format!("{}.exe", gnu)
16081608
}
16091609
} else if target.contains("android") {
1610-
format!(
1611-
"{}-{}",
1612-
target
1613-
.replace("armv7", "arm")
1614-
.replace("armv7neon", "arm")
1615-
.replace("thumbv7", "arm")
1616-
.replace("thumbv7neon", "arm"),
1617-
gnu
1618-
)
1610+
let target = target
1611+
.replace("armv7", "arm")
1612+
.replace("armv7neon", "arm")
1613+
.replace("thumbv7", "arm")
1614+
.replace("thumbv7neon", "arm");
1615+
let gnu_compiler = format!("{}-{}", target, gnu);
1616+
let clang_compiler = format!("{}-{}", target, clang);
1617+
// Check if gnu compiler is present
1618+
// if not, use clang
1619+
if Command::new(&gnu_compiler).spawn().is_ok() {
1620+
gnu_compiler
1621+
} else {
1622+
clang_compiler
1623+
}
16191624
} else if target.contains("cloudabi") {
16201625
format!("{}-{}", target, traditional)
16211626
} else if self.get_host()? != target {

0 commit comments

Comments
 (0)