From 9a506488643b4bc3ac34522000d60f87ea512301 Mon Sep 17 00:00:00 2001 From: Osspial Date: Tue, 21 Apr 2020 15:25:36 -0400 Subject: [PATCH 1/2] Fix android clang compiler path when building with Windows host --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 87653341..76d20693 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1980,7 +1980,11 @@ impl Build { .replace("thumbv7neon", "arm") .replace("thumbv7", "arm"); let gnu_compiler = format!("{}-{}", target, gnu); - let clang_compiler = format!("{}-{}", target, clang); + let clang_compiler = if host.contains("windows") { + format!("{}-{}.cmd", target, clang) + } else { + format!("{}-{}", target, clang) + }; // Check if gnu compiler is present // if not, use clang if Command::new(&gnu_compiler).spawn().is_ok() { From fc6ccd4c0ea6c9a9dd57048433f866a0aa2da91b Mon Sep 17 00:00:00 2001 From: Osspial Date: Tue, 21 Apr 2020 19:10:57 -0400 Subject: [PATCH 2/2] Only use the cmd clang compiler if the exe clang doesn't exist --- src/lib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 76d20693..5324cb45 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1980,15 +1980,20 @@ impl Build { .replace("thumbv7neon", "arm") .replace("thumbv7", "arm"); let gnu_compiler = format!("{}-{}", target, gnu); - let clang_compiler = if host.contains("windows") { - format!("{}-{}.cmd", target, clang) - } else { - format!("{}-{}", target, clang) - }; + let clang_compiler = format!("{}-{}", target, clang); + // On Windows, the Android clang compiler is provided as a `.cmd` file instead + // of a `.exe` file. `std::process::Command` won't run `.cmd` files unless the + // `.cmd` is explicitly appended to the command name, so we do that here. + let clang_compiler_cmd = format!("{}-{}.cmd", target, clang); + // Check if gnu compiler is present // if not, use clang if Command::new(&gnu_compiler).spawn().is_ok() { gnu_compiler + } else if host.contains("windows") + && Command::new(&clang_compiler).spawn().is_err() + { + clang_compiler_cmd } else { clang_compiler }