From 02f7ae7de2504707c91870f66c007cce58a0118b Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 6 Jul 2021 22:19:12 +0200 Subject: [PATCH] [NDK] Properly detect 64-bit NDK The code detecting whether an instance of NDK is a 64-bit one assumed that the GNU binutils paths existed below the toolchains dir and used them to check whether the 64-bit platform directory exists under them in order to determine if the NDK is a 64-bit one. NDK r23, however, will remove the GNU binutils completely and those paths no longer exist. Add a check for the `toolchains/llvm/prebuilt/[PLATFORM]` directory existence before the older check so that detection works correctly for NDK r23+. --- src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs b/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs index e26233b..c76fe9b 100644 --- a/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs +++ b/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs @@ -87,7 +87,11 @@ public virtual void Initialize (string? androidSdkPath = null, string? androidNd if (!string.IsNullOrEmpty (AndroidNdkPath)) { // It would be nice if .NET had real globbing support in System.IO... string toolchainsDir = Path.Combine (AndroidNdkPath, "toolchains"); - if (Directory.Exists (toolchainsDir)) { + string llvmNdkToolchainDir = Path.Combine (toolchainsDir, "llvm", "prebuilt", NdkHostPlatform64Bit); + + if (Directory.Exists (llvmNdkToolchainDir)) { + IsNdk64Bit = true; + } else if (Directory.Exists (toolchainsDir)) { IsNdk64Bit = Directory.EnumerateDirectories (toolchainsDir, "arm-linux-androideabi-*") .Any (dir => Directory.Exists (Path.Combine (dir, "prebuilt", NdkHostPlatform64Bit))); }