Skip to content

Commit 784c32e

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 7f0e1ec commit 784c32e

File tree

5 files changed

+77
-12
lines changed

5 files changed

+77
-12
lines changed

Xamarin.Android.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Posix", "src\Mono.Posi
6767
EndProject
6868
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.EnterpriseServices", "src\System.EnterpriseServices\System.EnterpriseServices.csproj", "{2868FC32-A4E7-4008-87C8-2C7879CACB58}"
6969
EndProject
70+
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "unix-distribution-setup", "build-tools\unix-distribution-setup\unix-distribution-setup.mdproj", "{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}"
71+
EndProject
7072
Global
7173
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7274
Debug|AnyCPU = Debug|AnyCPU
@@ -280,6 +282,18 @@ Global
280282
{2868FC32-A4E7-4008-87C8-2C7879CACB58}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
281283
{2868FC32-A4E7-4008-87C8-2C7879CACB58}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
282284
{2868FC32-A4E7-4008-87C8-2C7879CACB58}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
285+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
286+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Debug|AnyCPU.Build.0 = Debug|Any CPU
287+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Release|AnyCPU.ActiveCfg = Release|Any CPU
288+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.Release|AnyCPU.Build.0 = Release|Any CPU
289+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU
290+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU
291+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU
292+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU
293+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|AnyCPU.ActiveCfg = Debug|Any CPU
294+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU
295+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU
296+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU
283297
EndGlobalSection
284298
GlobalSection(NestedProjects) = preSolution
285299
{8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
@@ -311,6 +325,7 @@ Global
311325
{40EAD437-216B-4DF4-8258-3F47E1672C3A} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}
312326
{83F00D30-0AC6-40D8-834B-DD39B6CAA8B3} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
313327
{2868FC32-A4E7-4008-87C8-2C7879CACB58} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
328+
{2CF172E5-BDAE-4ABA-8BC8-08040ED3E77A} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
314329
EndGlobalSection
315330
GlobalSection(MonoDevelopProperties) = preSolution
316331
Policies = $0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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
21+
Condition=" '$(HostOS)' != 'Windows' "
22+
Command="chmod +x $(OutputPath)bin\generator" />
23+
</Target>
24+
25+
<Target Name="Clean">
26+
<Delete Files="$(OutputPath)bin\generator" />
27+
</Target>
28+
</Project>
29+

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)