@@ -216,16 +216,18 @@ protected virtual string GetPlatformLibPath (AndroidTargetArch arch, int apiLeve
216216 {
217217 string ? executablePath = null ;
218218 if ( IsWindows ) {
219- string toolDir = Path . GetDirectoryName ( toolPath ) ;
220- executablePath = Path . Combine ( toolDir , MonoAndroidHelper . GetExecutablePath ( toolDir , Path . GetFileName ( toolPath ) ) ) ;
221-
222- if ( String . Compare ( Path . GetExtension ( executablePath ) , ".cmd" , StringComparison . Ordinal ) == 0 && executablePath . IndexOf ( ' ' ) >= 0 ) {
223- // NDK has CMD scripts to execute the compilers on Windows, but the scripts do not quote spaces in the command path properly, we need to do
224- // it for them here or e.g. mkbundle will fail:
225- //
226- // [CC] "C:\a\_work\1\s\bin\TestRelease\temp\SDK Ümläüts\ndk\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi16-clang.CMD" -c -D__ANDROID_API__=16 -DANDROID -o obj\Release\bundles\armeabi-v7a\temp.o -I "C:\a\_work\1\s\bin\TestRelease\temp\SDK Ümläüts\ndk\sysroot\usr\include\arm-linux-androideabi" -I "C:\a\_work\1\s\bin\TestRelease\temp\SDK Ümläüts\ndk\sysroot\usr\include" obj\Release\bundles\armeabi-v7a\temp.c (TaskId:181)
227- // [cc stderr] 'C:\a\_work\1\s\bin\TestRelease\temp\SDK' is not recognized as an internal or external command, (TaskId:181)
228- executablePath = executablePath . Replace ( " " , "\\ " ) ;
219+ // We can't just use `File.Exists (toolPath)` since the Windows NDK contains extension-less
220+ // Unix shell scripts which would fail to work if an attempt to execute them would be made.
221+ //
222+ // Also, the NDK r19+ workaround (see NdkToolsWithClangWithPlatforms.ctor) will cause `toolPath`
223+ // here to end with .exe when looking for the compiler and we can save some time by not letting
224+ // `MonoAndroidHelper.GetExecutablePath` iterate over all %PATHEXT% extensions only to return the
225+ // original tool name
226+ if ( Path . HasExtension ( toolPath ) && File . Exists ( toolPath ) ) {
227+ executablePath = toolPath ;
228+ } else {
229+ string toolDir = Path . GetDirectoryName ( toolPath ) ;
230+ executablePath = Path . Combine ( toolDir , MonoAndroidHelper . GetExecutablePath ( toolDir , Path . GetFileName ( toolPath ) ) ) ;
229231 }
230232 } else if ( File . Exists ( toolPath ) ) {
231233 executablePath = toolPath ;
0 commit comments