From 422d8560276e329cbfe6b35c9276b3efb86058cb Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Fri, 16 Jul 2021 17:30:25 +0200 Subject: [PATCH] [WIP] If in-tree binutils aren't found, try to get them from the system location --- .../Utilities/BaseTest.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs index 3dca0424e21..f6f0b5eca70 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs @@ -80,6 +80,11 @@ public void BeforeAllTests () Console.Error.WriteLine ("Failed to determine whether there is Android target emulator or not: " + ex); } + CreateBinutilsSymlink (); + } + + void CreateBinutilsSymlink () + { Console.Error.WriteLine ("DEBUG: making sure ndk link exists at the test assemblies location:"); string hostNdkDir = GetHostBinutilsDir (); Console.Error.WriteLine ($" DEBUG: hostNdkDir == {hostNdkDir}"); @@ -105,9 +110,16 @@ public void BeforeAllTests () File.Delete (symlinkDir); } + // We first try the in-tree location... string binutilsDirFullPath = Path.Combine (XABuildPaths.PrefixDirectory, "lib", "xamarin.android", "xbuild", "Xamarin", "Android", hostNdkDir); if (!Directory.Exists (binutilsDirFullPath)) { - throw new InvalidOperationException ($"Host NDK directory does not exist, {hostNdkDir}"); + Console.Error.WriteLine ($"In-tree binutils not found in {binutilsDirFullPath}, trying the system location"); + + // ...since it failed, we'll try to find the system location + binutilsDirFullPath = Path.Combine (TestEnvironment.MonoAndroidToolsDirectory, hostNdkDir); + if (!Directory.Exists (binutilsDirFullPath)) { + throw new InvalidOperationException ($"Host NDK directory does not exist, {binutilsDirFullPath}"); + } } Console.Error.WriteLine ($" DEBUG: binutilsDirFullPath == {binutilsDirFullPath}");