public LoadDependencies ( bool allClients, bool keepMissing = false ) : Dependency>.Dictionary |
||
allClients | bool | If true, all client dependencies are loaded and returned /// |
keepMissing | bool | If false, missing dependencies result in a /// ResolutionException being thrown. If true, each missing dependency is included in /// the returned set with RepoPath set to an empty string. |
리턴 | Dependency>.Dictionary |
/// <summary> /// Creates an instance of PlayServicesSupport. This instance is /// used to add dependencies for the calling client and invoke the resolution. /// </summary> /// <returns>The instance.</returns> /// <param name="clientName">Client name. Must be a valid filename. /// This is used to uniquely identify /// the calling client so that dependencies can be associated with a specific /// client to help in resetting dependencies.</param> /// <param name="sdkPath">Sdk path for Android SDK.</param> /// <param name="additionalRepositories">Array of additional repository paths. can be null</param> /// <param name="settingsDirectory">The relative path to the directory /// to save the settings. For Unity projects this is "ProjectSettings"</param> /// <param name="logger">Delegate used to write messages to the log.</param> internal static PlayServicesSupport CreateInstance( string clientName, string sdkPath, string[] additionalRepositories, string settingsDirectory, LogMessage logger = null) { PlayServicesSupport instance = new PlayServicesSupport(); instance.logger = logger; instance.sdk = sdkPath; string badchars = new string(Path.GetInvalidFileNameChars()); foreach (char ch in clientName) { if (badchars.IndexOf(ch) >= 0) { throw new Exception("Invalid clientName: " + clientName); } } instance.clientName = clientName; instance.settingsDirectory = settingsDirectory; // Add the standard repo paths from the Android SDK string sdkExtrasDir = Path.Combine("$SDK", "extras"); instance.repositoryPaths[ Path.Combine(sdkExtrasDir, Path.Combine("android", "m2repository"))] = true; instance.repositoryPaths[ Path.Combine(sdkExtrasDir, Path.Combine("google", "m2repository"))] = true; foreach (string repo in additionalRepositories ?? new string[] {}) { instance.repositoryPaths[repo] = true; } instance.clientDependenciesMap = instance.LoadDependencies(false, true); return(instance); }
/// <summary> /// Creates an instance of PlayServicesSupport. This instance is /// used to add dependencies for the calling client and invoke the resolution. /// </summary> /// <returns>The instance.</returns> /// <param name="clientName">Client name. Must be a valid filename. /// This is used to uniquely identify /// the calling client so that dependencies can be associated with a specific /// client to help in resetting dependencies.</param> /// <param name="sdkPath">Sdk path for Android SDK.</param> /// <param name="settingsDirectory">The relative path to the directory /// to save the settings. For Unity projects this is "ProjectSettings"</param> public static PlayServicesSupport CreateInstance( string clientName, string sdkPath, string settingsDirectory) { PlayServicesSupport instance = new PlayServicesSupport(); instance.sdk = sdkPath; string badchars = new string(Path.GetInvalidFileNameChars()); foreach (char ch in clientName) { if (badchars.IndexOf(ch) >= 0) { throw new Exception("Invalid clientName: " + clientName); } } instance.clientName = clientName; instance.settingsDirectory = settingsDirectory; instance.clientDependenciesMap = instance.LoadDependencies(false); return(instance); }
/// <summary> /// Perform the resolution and the exploding/cleanup as needed. /// </summary> public override void DoResolution( PlayServicesSupport svcSupport, string destinationDirectory, PlayServicesSupport.OverwriteConfirmation handleOverwriteConfirmation, System.Action resolutionComplete) { System.Action resolve = () => { DoResolutionNoAndroidPackageChecks(svcSupport, destinationDirectory, handleOverwriteConfirmation); resolutionComplete(); }; // Set of packages that need to be installed. Dictionary<string, bool> installPackages = new Dictionary<string, bool>(); // Retrieve the set of required packages and whether they're installed. Dictionary<string, Dictionary<string, bool>> requiredPackages = new Dictionary<string, Dictionary<string, bool>>(); foreach (Dependency dependency in svcSupport.LoadDependencies(true, keepMissing: true).Values) { if (dependency.PackageIds != null) { foreach (string packageId in dependency.PackageIds) { Dictionary<string, bool> dependencySet; if (!requiredPackages.TryGetValue(packageId, out dependencySet)) { dependencySet = new Dictionary<string, bool>(); } dependencySet[dependency.Key] = false; requiredPackages[packageId] = dependencySet; // If the dependency is missing, add it to the set that needs to be // installed. if (System.String.IsNullOrEmpty(dependency.BestVersionPath)) { installPackages[packageId] = false; } } } } // If no packages need to be installed or Android SDK package installation is disabled. if (installPackages.Count == 0 || !AndroidPackageInstallationEnabled()) { // Report missing packages as warnings and try to resolve anyway. foreach (string pkg in requiredPackages.Keys) { string depString = System.String.Join( ", ", CollectionToArray(requiredPackages[pkg].Keys)); if (installPackages.ContainsKey(pkg) && depString.Length > 0) { Debug.LogWarning(pkg + " not installed or out of date! This is " + "required by the following dependencies " + depString); } } // Attempt resolution. resolve(); return; } // Find the Android SDK manager. string sdkPath = svcSupport.SDK; string androidTool = FindAndroidSdkTool(svcSupport, "android"); if (androidTool == null || sdkPath == null || sdkPath == "") { Debug.LogError("Unable to find the Android SDK manager tool. " + "Required Android packages (" + System.String.Join(", ", CollectionToArray(installPackages.Keys)) + ") can not be installed. " + PlayServicesSupport.AndroidSdkConfigurationError); return; } // Get the set of available and installed packages. GetAvailablePackages( androidTool, svcSupport, (Dictionary<string, bool> packageInfo) => { if (packageInfo == null) { return; } // Filter the set of packages to install by what is available. foreach (string pkg in requiredPackages.Keys) { bool installed = false; string depString = System.String.Join( ", ", CollectionToArray(requiredPackages[pkg].Keys)); if (packageInfo.TryGetValue(pkg, out installed)) { if (!installed) { installPackages[pkg] = false; Debug.LogWarning(pkg + " not installed or out of date! " + "This is required by the following " + "dependencies " + depString); } } else { Debug.LogWarning(pkg + " referenced by " + depString + " not available in the Android SDK. This " + "package will not be installed."); installPackages.Remove(pkg); } } if (installPackages.Count == 0) { resolve(); return; } // Start installation. string installPackagesString = System.String.Join( ",", CollectionToArray(installPackages.Keys)); string packagesCommand = "update sdk -a -u -t " + installPackagesString; CommandLineDialog window = CommandLineDialog.CreateCommandLineDialog( "Install Android SDK packages"); window.summaryText = "Retrieving licenses..."; window.modal = false; window.progressTitle = window.summaryText; window.RunAsync( androidTool, packagesCommand, (CommandLine.Result getLicensesResult) => { // Get the start of the license text. int licenseTextStart = getLicensesResult.stdout.IndexOf("--------"); if (getLicensesResult.exitCode != 0 || licenseTextStart < 0) { window.Close(); Debug.LogError("Unable to retrieve licenses for packages " + installPackagesString); return; } // Remove the download output from the string. string licenseText = getLicensesResult.stdout.Substring( licenseTextStart); window.summaryText = ("License agreement(s) required to install " + "Android SDK packages"); window.bodyText = licenseText; window.yesText = "agree"; window.noText = "decline"; window.result = false; window.Repaint(); window.buttonClicked = (TextAreaDialog dialog) => { if (!dialog.result) { window.Close(); return; } window.summaryText = "Installing Android SDK packages..."; window.bodyText = ""; window.yesText = ""; window.noText = ""; window.buttonClicked = null; window.progressTitle = window.summaryText; window.autoScrollToBottom = true; window.Repaint(); // Kick off installation. ((CommandLineDialog)window).RunAsync( androidTool, packagesCommand, (CommandLine.Result updateResult) => { window.Close(); if (updateResult.exitCode == 0) { resolve(); } else { Debug.LogError("Android SDK update failed. " + updateResult.stderr + "(" + updateResult.exitCode.ToString() + ")"); } }, ioHandler: (new LicenseResponder(true)).AggregateLine, maxProgressLines: 500); }; }, ioHandler: (new LicenseResponder(false)).AggregateLine, maxProgressLines: 250); }); }
/// <summary> /// Creates an instance of PlayServicesSupport. This instance is /// used to add dependencies for the calling client and invoke the resolution. /// </summary> /// <returns>The instance.</returns> /// <param name="clientName">Client name. Must be a valid filename. /// This is used to uniquely identify /// the calling client so that dependencies can be associated with a specific /// client to help in resetting dependencies.</param> /// <param name="sdkPath">Sdk path for Android SDK.</param> /// <param name="additionalRepositories">Array of additional repository paths. can be null</param> /// <param name="settingsDirectory">The relative path to the directory /// to save the settings. For Unity projects this is "ProjectSettings"</param> /// <param name="logger">Delegate used to write messages to the log.</param> internal static PlayServicesSupport CreateInstance( string clientName, string sdkPath, string[] additionalRepositories, string settingsDirectory, LogMessage logger = null) { PlayServicesSupport instance = new PlayServicesSupport(); instance.logger = logger; instance.sdk = sdkPath; string badchars = new string(Path.GetInvalidFileNameChars()); foreach (char ch in clientName) { if (badchars.IndexOf(ch) >= 0) { throw new Exception("Invalid clientName: " + clientName); } } instance.clientName = clientName; instance.settingsDirectory = settingsDirectory; // Add the standard repo paths from the Android SDK string sdkExtrasDir = Path.Combine("$SDK", "extras"); instance.repositoryPaths[ Path.Combine(sdkExtrasDir, Path.Combine("android","m2repository"))] = true; instance.repositoryPaths[ Path.Combine(sdkExtrasDir, Path.Combine("google","m2repository"))] = true; foreach (string repo in additionalRepositories ?? new string[] {}) { instance.repositoryPaths[repo] = true; } instance.clientDependenciesMap = instance.LoadDependencies(false, true); return instance; }