From 30c168e516c5ef6dc3286f3da4072aaed5a06f25 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Tue, 7 Jun 2016 10:14:22 +0800 Subject: [PATCH] Fix part of Mono.Posix build issue regarding MonoDroidSDK discovery. We can build xamarin-android on Linux only because we somehow had a working monodroid setup with MONO_ANDROID_PATH. Hence, fresh build hits: bin/Debug/lib/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task ResolveSdks: Value cannot be null. Now that Mono.Posix and some other libs depends on existing SDK, MonoDroidSdkUnix needs to also deal with bootstrap build. So far, the SDK sanity check uses generator.exe which does not exist when we are building Mono.Posix, so use class-parse.exe which exists instead. Also we only build 6.0 and UseLatestSDK somehow tries to find 6.0.99 and fails, so use 6.0 instead. --- src/Mono.Posix/Mono.Posix.csproj | 3 +-- src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs | 2 ++ .../Utilities/MonoAndroidHelper.cs | 2 +- .../Sdks/MonoDroidSdkBase.cs | 4 ++-- .../Sdks/MonoDroidSdkUnix.cs | 6 +++++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Mono.Posix/Mono.Posix.csproj b/src/Mono.Posix/Mono.Posix.csproj index 42b50f601a5..bc2f49f77dd 100644 --- a/src/Mono.Posix/Mono.Posix.csproj +++ b/src/Mono.Posix/Mono.Posix.csproj @@ -11,9 +11,8 @@ Resources Resource Resources\Resource.designer.cs - True Mono.Posix - v5.0 + v6.0 true diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs index 95f99b6aac1..6836123611d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs @@ -113,6 +113,8 @@ public override bool Execute () Log.LogDebugMessage (" TargetFrameworkVersion: {0}", TargetFrameworkVersion); Log.LogDebugMessage (" UseLatestAndroidPlatformSdk: {0}", UseLatestAndroidPlatformSdk); Log.LogDebugMessage (" SequencePointsMode: {0}", SequencePointsMode); + Log.LogDebugMessage (" MonoAndroidToolsPath: {0}", MonoAndroidToolsPath); + Log.LogDebugMessage (" MonoAndroidBinPath: {0}", MonoAndroidBinPath); MonoAndroidHelper.InitializeAndroidLogger (Log); diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs b/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs index a32724922ab..c38aef9fb71 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs @@ -58,7 +58,7 @@ public static void RefreshAndroidSdk (string sdkPath, string ndkPath, string jav public static void RefreshMonoDroidSdk (string toolsPath, string binPath, string[] referenceAssemblyPaths) { MonoDroidSdk.Refresh (toolsPath, binPath, - (from refPath in referenceAssemblyPaths + (from refPath in referenceAssemblyPaths ?? new string [0] where !string.IsNullOrEmpty (refPath) let path = refPath.TrimEnd (Path.DirectorySeparatorChar) where File.Exists (Path.Combine (path, "mscorlib.dll")) diff --git a/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs b/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs index 2894850d794..dfdb9829a50 100644 --- a/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs +++ b/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs @@ -9,7 +9,7 @@ namespace Xamarin.Android.Build.Utilities abstract class MonoDroidSdkBase { protected readonly static string DebugRuntime = "Mono.Android.DebugRuntime-debug.apk"; - protected readonly static string GeneratorExe = "generator.exe"; + protected readonly static string ClassParseExe = "class-parse.exe"; protected readonly static string GeneratorScript = "generator"; // I can never remember the difference between SdkPath and anything else... @@ -107,7 +107,7 @@ protected static bool ValidateRuntime (string loc) { return !string.IsNullOrWhiteSpace (loc) && (File.Exists (Path.Combine (loc, DebugRuntime)) || // Normal/expected - File.Exists (Path.Combine (loc, GeneratorExe)) || // Normal/expected + File.Exists (Path.Combine (loc, ClassParseExe)) || // Normal/expected File.Exists (Path.Combine (loc, "Ionic.Zip.dll"))); // Wrench builds } diff --git a/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs b/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs index f5270eceb75..ebe35c2d08a 100644 --- a/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs +++ b/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs @@ -34,7 +34,11 @@ protected override string FindRuntime () // check also in the users folder var personal = Environment.GetFolderPath (Environment.SpecialFolder.Personal); - var additionalSearchPaths = new [] { Path.Combine (personal, @".xamarin.android/lib/mandroid") }; + var additionalSearchPaths = new [] { + // for Mono.Posix and Mono.Data.Sqlite builds in xamarin-android. + monoAndroidPath = Path.GetFullPath (Path.Combine (new Uri (GetType ().Assembly.CodeBase).LocalPath, "..", "..", "..", "..", "..", "lib", "mandroid")), + Path.Combine (personal, @".xamarin.android/lib/mandroid") + }; return additionalSearchPaths.Concat (SearchPaths).FirstOrDefault (ValidateRuntime); }