From 784c32ec47df6f160054055f587c3908a485428c Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Mon, 30 May 2016 16:10:11 +0800 Subject: [PATCH] Fix monodroid SDK detection that depended on non-existent file. We don't build DebugRuntime apk in this new source set anymore, so do not look for the file in our SDK sanity checker. Additional warning logs are added because, we should do that. (Otherwise we will keep ignorant of the actual cause of the problem forever.) --- Xamarin.Android.sln | 15 ++++++++++ .../unix-distribution-setup.mdproj | 29 +++++++++++++++++++ .../Sdks/MonoDroidSdkBase.cs | 26 ++++++++++++----- .../Sdks/MonoDroidSdkUnix.cs | 13 +++++---- tools/scripts/generator | 6 ++++ 5 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 build-tools/unix-distribution-setup/unix-distribution-setup.mdproj create mode 100755 tools/scripts/generator diff --git a/Xamarin.Android.sln b/Xamarin.Android.sln index 3dd06009343..da3eb0c4a93 100644 --- a/Xamarin.Android.sln +++ b/Xamarin.Android.sln @@ -67,6 +67,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Posix", "src\Mono.Posi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.EnterpriseServices", "src\System.EnterpriseServices\System.EnterpriseServices.csproj", "{2868FC32-A4E7-4008-87C8-2C7879CACB58}" EndProject +Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "unix-distribution-setup", "build-tools\unix-distribution-setup\unix-distribution-setup.mdproj", "{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|AnyCPU = Debug|AnyCPU @@ -280,6 +282,18 @@ Global {2868FC32-A4E7-4008-87C8-2C7879CACB58}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU {2868FC32-A4E7-4008-87C8-2C7879CACB58}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU {2868FC32-A4E7-4008-87C8-2C7879CACB58}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Debug|AnyCPU.Build.0 = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Release|AnyCPU.ActiveCfg = Release|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Release|AnyCPU.Build.0 = Release|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|AnyCPU.ActiveCfg = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62} @@ -311,6 +325,7 @@ Global {40EAD437-216B-4DF4-8258-3F47E1672C3A} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483} {83F00D30-0AC6-40D8-834B-DD39B6CAA8B3} = {04E3E11E-B47D-4599-8AFC-50515A95E715} {2868FC32-A4E7-4008-87C8-2C7879CACB58} = {04E3E11E-B47D-4599-8AFC-50515A95E715} + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/build-tools/unix-distribution-setup/unix-distribution-setup.mdproj b/build-tools/unix-distribution-setup/unix-distribution-setup.mdproj new file mode 100644 index 00000000000..557fb4e89d9 --- /dev/null +++ b/build-tools/unix-distribution-setup/unix-distribution-setup.mdproj @@ -0,0 +1,29 @@ + + + + Debug + AnyCPU + GenericProject + {2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A} + + + ..\..\bin\Debug\ + + + ..\..\bin\Release\ + + + + + + + + + + + + + + diff --git a/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs b/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs index d02dc69fea2..2894850d794 100644 --- a/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs +++ b/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs @@ -9,6 +9,8 @@ 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 GeneratorScript = "generator"; // I can never remember the difference between SdkPath and anything else... [Obsolete ("Do not use.")] @@ -31,16 +33,18 @@ abstract class MonoDroidSdkBase public int SharedRuntimeVersion { get; private set; } - // runtimePath: contains Mono.Android.DebugRuntime-*.apk + // expectedRuntimePath: contains Mono.Android.DebugRuntime-*.apk // binPath: contains mandroid // mscorlibDir: contains mscorlib.dll - public void Initialize (string runtimePath = null, string binPath = null, string bclPath = null) + public void Initialize (string expectedRuntimePath = null, string binPath = null, string bclPath = null) { - runtimePath = GetValidPath ("MonoAndroidToolsPath", runtimePath, ValidateRuntime, () => FindRuntime ()); + var runtimePath = GetValidPath ("MonoAndroidToolsPath", expectedRuntimePath, ValidateRuntime, () => FindRuntime ()); if (runtimePath != null) { binPath = GetValidPath ("MonoAndroidBinPath", binPath, ValidateBin, () => FindBin (runtimePath)); bclPath = GetValidPath ("mscorlib.dll", bclPath, ValidateFramework, () => FindFramework (runtimePath)); } else { + if (expectedRuntimePath != null) + AndroidLogger.LogWarning (null, "Runtime was not found at {0}", expectedRuntimePath); binPath = bclPath = null; } @@ -67,14 +71,21 @@ public void Initialize (string runtimePath = null, string binPath = null, string static string GetValidPath (string description, string path, Func validator, Func defaultPath) { - if (!string.IsNullOrEmpty (path) && Directory.Exists (path)) { - if (validator (path)) - return path; - AndroidLogger.LogWarning ("{0} path {1} is not valid; skipping.", description, path); + if (!string.IsNullOrEmpty (path)) { + if (Directory.Exists (path)) { + if (validator (path)) + return path; + AndroidLogger.LogWarning (null, "{0} path '{1}' is explicitly specified, but it was not valid; skipping.", description, path); + } else + AndroidLogger.LogWarning (null, "{0} path '{1}' is explicitly specified, but it was not found; skipping.", description, path); } path = defaultPath (); if (path != null && validator (path)) return path; + if (path != null) + AndroidLogger.LogWarning (null, "{0} path is defaulted to '{1}', but it was not valid; skipping", description, path); + else + AndroidLogger.LogWarning (null, "{0} path is not found and no default location is provided; skipping", description); return null; } @@ -96,6 +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, "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 4a8f7709968..f5270eceb75 100644 --- a/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs +++ b/src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs @@ -24,8 +24,12 @@ protected override string FindRuntime () string monoAndroidPath = Environment.GetEnvironmentVariable ("MONO_ANDROID_PATH"); if (!string.IsNullOrEmpty (monoAndroidPath)) { string libMandroid = Path.Combine (monoAndroidPath, "lib", "mandroid"); - if (Directory.Exists (libMandroid) && ValidateRuntime (libMandroid)) - return libMandroid; + if (Directory.Exists (libMandroid)) { + if (ValidateRuntime (libMandroid)) + return libMandroid; + AndroidLogger.LogInfo (null, "MONO_ANDROID_PATH points to {0}, but it is invalid.", monoAndroidPath); + } else + AndroidLogger.LogInfo (null, "MONO_ANDROID_PATH points to {0}, but it does not exist.", monoAndroidPath); } // check also in the users folder @@ -38,7 +42,7 @@ protected override string FindRuntime () protected override bool ValidateBin (string binPath) { return !string.IsNullOrWhiteSpace (binPath) && - File.Exists (Path.Combine (binPath, "generator")); + File.Exists (Path.Combine (binPath, GeneratorScript)); } protected override string FindFramework (string runtimePath) @@ -64,8 +68,7 @@ protected override string FindFramework (string runtimePath) protected override string FindBin (string runtimePath) { string binPath = Path.GetFullPath (Path.Combine (runtimePath, "..", "..", "bin")); - Console.WriteLine (binPath); - if (File.Exists (Path.Combine (binPath, "generator"))) + if (File.Exists (Path.Combine (binPath, GeneratorScript))) return binPath; return null; } diff --git a/tools/scripts/generator b/tools/scripts/generator new file mode 100755 index 00000000000..1bcede4ad5d --- /dev/null +++ b/tools/scripts/generator @@ -0,0 +1,6 @@ +#!/bin/sh +BINDIR=`dirname "$0"` +MANDROID_DIR="$BINDIR/../lib/mandroid" + +unset MONO_PATH +exec mono $MONO_OPTIONS "$MANDROID_DIR/generator.exe" "$@"