From 4c6e7c624d3c6560bd2ca4711ad3a10418065a84 Mon Sep 17 00:00:00 2001 From: Osspial Date: Wed, 22 Apr 2020 10:17:50 -0400 Subject: [PATCH] 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 --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 876533417..5324cb45b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1981,10 +1981,19 @@ impl Build { .replace("thumbv7", "arm"); let gnu_compiler = format!("{}-{}", target, gnu); 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 }