Skip to content

Commit 027df7c

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 10b5364 commit 027df7c

File tree

5 files changed

+74
-12
lines changed

5 files changed

+74
-12
lines changed

Xamarin.Android.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ EndProject
6464
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Android-Tests", "src\Mono.Android\Test\Mono.Android-Tests.csproj", "{40EAD437-216B-4DF4-8258-3F47E1672C3A}"
6565
EndProject
6666
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Posix", "src\Mono.Posix\Mono.Posix.csproj", "{83F00D30-0AC6-40D8-834B-DD39B6CAA8B3}"
67+
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "unix-distribution-setup", "build-tools\unix-distribution-setup\unix-distribution-setup.mdproj", "{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}"
6768
EndProject
6869
Global
6970
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -266,6 +267,18 @@ Global
266267
{83F00D30-0AC6-40D8-834B-DD39B6CAA8B3}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
267268
{83F00D30-0AC6-40D8-834B-DD39B6CAA8B3}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
268269
{83F00D30-0AC6-40D8-834B-DD39B6CAA8B3}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
270+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
271+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Debug|AnyCPU.Build.0 = Debug|Any CPU
272+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Release|AnyCPU.ActiveCfg = Release|Any CPU
273+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Release|AnyCPU.Build.0 = Release|Any CPU
274+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
275+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
276+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
277+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
278+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|AnyCPU.ActiveCfg = Debug|Any CPU
279+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
280+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
281+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
269282
EndGlobalSection
270283
GlobalSection(NestedProjects) = preSolution
271284
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
@@ -296,6 +309,7 @@ Global
296309
{53E4ABF0-1085-45F9-B964-DCAE4B819998} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}
297310
{40EAD437-216B-4DF4-8258-3F47E1672C3A} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}
298311
{83F00D30-0AC6-40D8-834B-DD39B6CAA8B3} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
312+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
299313
EndGlobalSection
300314
GlobalSection(MonoDevelopProperties) = preSolution
301315
Policies = $0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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>{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}</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+
<Exec Command="chmod +x $(OutputPath)bin\generator" />
21+
</Target>
22+
23+
<Target Name="Clean">
24+
<Delete Files="$(OutputPath)bin\generator" />
25+
</Target>
26+
</Project>
27+

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

Lines changed: 19 additions & 7 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.")]
@@ -31,16 +33,18 @@ abstract class MonoDroidSdkBase
3133

3234
public int SharedRuntimeVersion { get; private set; }
3335

34-
// runtimePath: contains Mono.Android.DebugRuntime-*.apk
36+
// expectedRuntimePath: 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: 8 additions & 5 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)
@@ -64,8 +68,7 @@ protected override string FindFramework (string runtimePath)
6468
protected override string FindBin (string runtimePath)
6569
{
6670
string binPath = Path.GetFullPath (Path.Combine (runtimePath, "..", "..", "bin"));
67-
Console.WriteLine (binPath);
68-
if (File.Exists (Path.Combine (binPath, "generator")))
71+
if (File.Exists (Path.Combine (binPath, GeneratorScript)))
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)