static string GetValidPath(string description, string path, Func <string, bool> validator, Func <string> defaultPath) { 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); }
// expectedRuntimePath: contains Mono.Android.DebugRuntime-*.apk // binPath: contains mandroid // mscorlibDir: contains mscorlib.dll public void Initialize(string expectedRuntimePath = null, string binPath = null, string bclPath = null) { 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; } if (runtimePath == null || binPath == null || bclPath == null) { Reset(); return; } RuntimePath = runtimePath; #pragma warning disable 0618 SdkPath = Path.GetFullPath(Path.Combine(runtimePath, "..", "..")); #pragma warning restore 0618 BinPath = binPath; BclPath = bclPath; LibrariesPath = FindLibraries(runtimePath); IncludePath = FindInclude(runtimePath); if (IncludePath != null && !Directory.Exists(IncludePath)) { IncludePath = null; } SharedRuntimeVersion = GetCurrentSharedRuntimeVersion(); FindSupportedFrameworks(); }