Skip to content

Commit 4c6e7c6

Browse files
authored
Fix Android clang compiler path when building with Windows host (#489)
* Fix android clang compiler path when building with Windows host * Only use the cmd clang compiler if the exe clang doesn't exist
1 parent 5bb26a6 commit 4c6e7c6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1981,10 +1981,19 @@ impl Build {
19811981
.replace("thumbv7", "arm");
19821982
let gnu_compiler = format!("{}-{}", target, gnu);
19831983
let clang_compiler = format!("{}-{}", target, clang);
1984+
// On Windows, the Android clang compiler is provided as a `.cmd` file instead
1985+
// of a `.exe` file. `std::process::Command` won't run `.cmd` files unless the
1986+
// `.cmd` is explicitly appended to the command name, so we do that here.
1987+
let clang_compiler_cmd = format!("{}-{}.cmd", target, clang);
1988+
19841989
// Check if gnu compiler is present
19851990
// if not, use clang
19861991
if Command::new(&gnu_compiler).spawn().is_ok() {
19871992
gnu_compiler
1993+
} else if host.contains("windows")
1994+
&& Command::new(&clang_compiler).spawn().is_err()
1995+
{
1996+
clang_compiler_cmd
19881997
} else {
19891998
clang_compiler
19901999
}

0 commit comments

Comments
 (0)