@@ -9,6 +9,8 @@ namespace Xamarin.Android.Build.Utilities
9
9
abstract class MonoDroidSdkBase
10
10
{
11
11
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" ;
12
14
13
15
// I can never remember the difference between SdkPath and anything else...
14
16
[ Obsolete ( "Do not use." ) ]
@@ -31,16 +33,18 @@ abstract class MonoDroidSdkBase
31
33
32
34
public int SharedRuntimeVersion { get ; private set ; }
33
35
34
- // runtimePath : contains Mono.Android.DebugRuntime-*.apk
36
+ // expectedRuntimePath : contains Mono.Android.DebugRuntime-*.apk
35
37
// binPath: contains mandroid
36
38
// 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 )
38
40
{
39
- runtimePath = GetValidPath ( "MonoAndroidToolsPath" , runtimePath , ValidateRuntime , ( ) => FindRuntime ( ) ) ;
41
+ var runtimePath = GetValidPath ( "MonoAndroidToolsPath" , expectedRuntimePath , ValidateRuntime , ( ) => FindRuntime ( ) ) ;
40
42
if ( runtimePath != null ) {
41
43
binPath = GetValidPath ( "MonoAndroidBinPath" , binPath , ValidateBin , ( ) => FindBin ( runtimePath ) ) ;
42
44
bclPath = GetValidPath ( "mscorlib.dll" , bclPath , ValidateFramework , ( ) => FindFramework ( runtimePath ) ) ;
43
45
} else {
46
+ if ( expectedRuntimePath != null )
47
+ AndroidLogger . LogWarning ( null , "Runtime was not found at {0}" , expectedRuntimePath ) ;
44
48
binPath = bclPath = null ;
45
49
}
46
50
@@ -67,14 +71,21 @@ public void Initialize (string runtimePath = null, string binPath = null, string
67
71
68
72
static string GetValidPath ( string description , string path , Func < string , bool > validator , Func < string > defaultPath )
69
73
{
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 ) ;
74
81
}
75
82
path = defaultPath ( ) ;
76
83
if ( path != null && validator ( path ) )
77
84
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 ) ;
78
89
return null ;
79
90
}
80
91
@@ -96,6 +107,7 @@ protected static bool ValidateRuntime (string loc)
96
107
{
97
108
return ! string . IsNullOrWhiteSpace ( loc ) &&
98
109
( File . Exists ( Path . Combine ( loc , DebugRuntime ) ) || // Normal/expected
110
+ File . Exists ( Path . Combine ( loc , GeneratorExe ) ) || // Normal/expected
99
111
File . Exists ( Path . Combine ( loc , "Ionic.Zip.dll" ) ) ) ; // Wrench builds
100
112
}
101
113
0 commit comments