Skip to content

Commit e695623

Browse files
committed
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.)
1 parent 95c71bb commit e695623

File tree

5 files changed

+66
-15
lines changed

5 files changed

+66
-15
lines changed

Xamarin.Android.sln

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2012
44
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build-Tools", "Build-Tools", "{E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}"
55
EndProject
6-
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "android-toolchain", "build-tools\android-toolchain\android-toolchain.mdproj", "{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}"
6+
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "unix-distribution-setup", "build-tools\unix-distribution-setup\unix-distribution-setup.mdproj", "{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools.BootstrapTasks", "src\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj", "{E8492EFB-D14A-4F32-AA28-88848322ECEA}"
99
EndProject
@@ -99,12 +99,16 @@ Global
9999
{66CF299A-CE95-4131-BCD8-DB66E30C4BF7}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
100100
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
101101
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Debug|AnyCPU.Build.0 = Debug|Any CPU
102-
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.ActiveCfg = Release|AnyCPU
103-
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.Build.0 = Release|AnyCPU
102+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.ActiveCfg = Release|Any CPU
103+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.Release|AnyCPU.Build.0 = Release|Any CPU
104104
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
105105
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
106106
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
107107
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
108+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|AnyCPU.ActiveCfg = Debug|Any CPU
109+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
110+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
111+
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
108112
{91713046-C358-4647-B162-ED4E1442F3D8}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
109113
{91713046-C358-4647-B162-ED4E1442F3D8}.Debug|AnyCPU.Build.0 = Debug|Any CPU
110114
{91713046-C358-4647-B162-ED4E1442F3D8}.Release|AnyCPU.ActiveCfg = Release|Any CPU
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
3+
<PropertyGroup>
4+
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ItemType>GenericProject</ItemType>
7+
<ProjectGuid>{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA}</ProjectGuid>
8+
</PropertyGroup>
9+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
10+
<OutputPath>..\..\bin\Debug\</OutputPath>
11+
</PropertyGroup>
12+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
13+
<OutputPath>..\..\bin\Release\</OutputPath>
14+
</PropertyGroup>
15+
16+
<Import Project="..\..\Configuration.props" />
17+
18+
<Target Name="Build">
19+
<Copy SourceFiles="..\..\tools\scripts\generator" DestinationFiles="$(OutputPath)bin\generator" />
20+
</Target>
21+
22+
<Target Name="Clean">
23+
<Delete Files="$(OutputPath)bin\generator" />
24+
</Target>
25+
</Project>
26+

src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace Xamarin.Android.Build.Utilities
99
abstract class MonoDroidSdkBase
1010
{
1111
protected readonly static string DebugRuntime = "Mono.Android.DebugRuntime-debug.apk";
12+
protected readonly static string GeneratorExe = "generator.exe";
13+
protected readonly static string GeneratorScript = "generator";
1214

1315
// I can never remember the difference between SdkPath and anything else...
1416
[Obsolete ("Do not use.")]
@@ -34,13 +36,15 @@ abstract class MonoDroidSdkBase
3436
// runtimePath: contains Mono.Android.DebugRuntime-*.apk
3537
// binPath: contains mandroid
3638
// mscorlibDir: contains mscorlib.dll
37-
public void Initialize (string runtimePath = null, string binPath = null, string bclPath = null)
39+
public void Initialize (string expectedRuntimePath = null, string binPath = null, string bclPath = null)
3840
{
39-
runtimePath = GetValidPath ("MonoAndroidToolsPath", runtimePath, ValidateRuntime, () => FindRuntime ());
41+
var runtimePath = GetValidPath ("MonoAndroidToolsPath", expectedRuntimePath, ValidateRuntime, () => FindRuntime ());
4042
if (runtimePath != null) {
4143
binPath = GetValidPath ("MonoAndroidBinPath", binPath, ValidateBin, () => FindBin (runtimePath));
4244
bclPath = GetValidPath ("mscorlib.dll", bclPath, ValidateFramework, () => FindFramework (runtimePath));
4345
} else {
46+
if (expectedRuntimePath != null)
47+
AndroidLogger.LogWarning (null, "Runtime was not found at {0}", expectedRuntimePath);
4448
binPath = bclPath = null;
4549
}
4650

@@ -67,14 +71,21 @@ public void Initialize (string runtimePath = null, string binPath = null, string
6771

6872
static string GetValidPath (string description, string path, Func<string, bool> validator, Func<string> defaultPath)
6973
{
70-
if (!string.IsNullOrEmpty (path) && Directory.Exists (path)) {
71-
if (validator (path))
72-
return path;
73-
AndroidLogger.LogWarning ("{0} path {1} is not valid; skipping.", description, path);
74+
if (!string.IsNullOrEmpty (path)) {
75+
if (Directory.Exists (path)) {
76+
if (validator (path))
77+
return path;
78+
AndroidLogger.LogWarning (null, "{0} path '{1}' is explicitly specified, but it was not valid; skipping.", description, path);
79+
} else
80+
AndroidLogger.LogWarning (null, "{0} path '{1}' is explicitly specified, but it was not found; skipping.", description, path);
7481
}
7582
path = defaultPath ();
7683
if (path != null && validator (path))
7784
return path;
85+
if (path != null)
86+
AndroidLogger.LogWarning (null, "{0} path is defaulted to '{1}', but it was not valid; skipping", description, path);
87+
else
88+
AndroidLogger.LogWarning (null, "{0} path is not found and no default location is provided; skipping", description);
7889
return null;
7990
}
8091

@@ -96,6 +107,7 @@ protected static bool ValidateRuntime (string loc)
96107
{
97108
return !string.IsNullOrWhiteSpace (loc) &&
98109
(File.Exists (Path.Combine (loc, DebugRuntime)) || // Normal/expected
110+
File.Exists (Path.Combine (loc, GeneratorExe)) || // Normal/expected
99111
File.Exists (Path.Combine (loc, "Ionic.Zip.dll"))); // Wrench builds
100112
}
101113

src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ protected override string FindRuntime ()
2424
string monoAndroidPath = Environment.GetEnvironmentVariable ("MONO_ANDROID_PATH");
2525
if (!string.IsNullOrEmpty (monoAndroidPath)) {
2626
string libMandroid = Path.Combine (monoAndroidPath, "lib", "mandroid");
27-
if (Directory.Exists (libMandroid) && ValidateRuntime (libMandroid))
28-
return libMandroid;
27+
if (Directory.Exists (libMandroid)) {
28+
if (ValidateRuntime (libMandroid))
29+
return libMandroid;
30+
AndroidLogger.LogInfo (null, "MONO_ANDROID_PATH points to {0}, but it is invalid.", monoAndroidPath);
31+
} else
32+
AndroidLogger.LogInfo (null, "MONO_ANDROID_PATH points to {0}, but it does not exist.", monoAndroidPath);
2933
}
3034

3135
// check also in the users folder
@@ -38,7 +42,7 @@ protected override string FindRuntime ()
3842
protected override bool ValidateBin (string binPath)
3943
{
4044
return !string.IsNullOrWhiteSpace (binPath) &&
41-
File.Exists (Path.Combine (binPath, "generator"));
45+
File.Exists (Path.Combine (binPath, GeneratorScript));
4246
}
4347

4448
protected override string FindFramework (string runtimePath)
@@ -63,9 +67,8 @@ protected override string FindFramework (string runtimePath)
6367

6468
protected override string FindBin (string runtimePath)
6569
{
66-
string binPath = Path.GetFullPath (Path.Combine (runtimePath, "..", "..", "bin"));
67-
Console.WriteLine (binPath);
68-
if (File.Exists (Path.Combine (binPath, "generator")))
70+
string binPath = Path.GetFullPath (Path.Combine (runtimePath));
71+
if (File.Exists (Path.Combine (binPath, GeneratorExe)))
6972
return binPath;
7073
return null;
7174
}

tools/scripts/generator

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
BINDIR=`dirname "$0"`
3+
MANDROID_DIR="$BINDIR/../lib/mandroid"
4+
5+
unset MONO_PATH
6+
exec mono $MONO_OPTIONS "$MANDROID_DIR/generator.exe" "$@"

0 commit comments

Comments
 (0)