public static FindExecutable ( string executable ) : string | ||
executable | string | |
Результат | string |
// Handles the platform specific differences of executing the generate gradle script, and // creating the dialog responsible for showing the progress of the execution. // Any errors are reported to the console as well. /// <param name="args">Arguments to be passed to the generate gradle script tool.</param> private static void RunGenGradleScript(string args) { // b/35663224 Combine execute-python-exe which handles the windows logic. bool onWindows = UnityEngine.Application.platform == UnityEngine.RuntimePlatform.WindowsEditor; string command = "\"" + Path.Combine(GRADLE_SCRIPT_LOCATION, onWindows ? GENERATE_GRADLE_EXE_WINDOWS : GENERATE_GRADLE_EXE_GENERIC) + "\""; if (!onWindows) { args = command + args; command = CommandLine.FindExecutable("python"); } CommandLineDialog window = CommandLineDialog.CreateCommandLineDialog( "Resolving Jars."); window.modal = false; window.summaryText = "Generating and running Gradle prebuild."; window.progressTitle = window.summaryText; window.autoScrollToBottom = true; window.RunAsync( command, args, (result) => { if (result.exitCode != 0) { Debug.LogError("Error somewhere in the process of creating the gradle build, " + "executing it, and copying the outputs.\n" + "This will break dependency resolution and your build will not run.\n" + "See the output below for possible gradle build errors. The most likely " + "cases are: an invalid bundleID (which you can correct in the Android " + "Player Settings), or a failure to determine the Android SDK platform " + "and build tools verison (you can verify that you have a valid android " + "SDK path in the Unity preferences.\n" + "If you're not able to diagnose the error, please report a bug at: " + "https://github.com/googlesamples/unity-jar-resolver/issues" + "A possible work-around is to turn off the " + "\"Gradle Prebuild\" from the Jar Resolver Settings.\n\n" + "Error (" + result.exitCode + "):\n" + result.stdout + result.stderr); window.bodyText += "\n\nResolution Failed."; } else { window.bodyText += "\n\nResolution Complete."; } window.noText = "Close"; // After adding the button we need to scroll down a little more. window.scrollPosition.y = Mathf.Infinity; window.Repaint(); window.buttonClicked = (TextAreaDialog dialog) => { if (!dialog.result) { window.Close(); } }; }, maxProgressLines: 50); window.Show(); }
/// <summary> /// Find a Java tool. /// </summary> /// <param name="toolName">Name of the tool to search for.</param> private string FindJavaTool(string javaTool) { string javaHome = UnityEditor.EditorPrefs.GetString("JdkPath"); if (string.IsNullOrEmpty(javaHome)) { javaHome = Environment.GetEnvironmentVariable("JAVA_HOME"); } string toolPath; if (javaHome != null) { toolPath = Path.Combine( javaHome, Path.Combine( "bin", javaTool + CommandLine.GetExecutableExtension())); if (!File.Exists(toolPath)) { EditorUtility.DisplayDialog("Play Services Dependencies", "JAVA_HOME environment references a directory (" + javaHome + ") that does not contain " + javaTool + " which is required to process Play Services " + "dependencies.", "OK"); throw new Exception("JAVA_HOME references incomplete Java distribution. " + javaTool + " not found."); } } else { toolPath = CommandLine.FindExecutable(javaTool); if (!File.Exists(toolPath)) { EditorUtility.DisplayDialog("Play Services Dependencies", "Unable to find " + javaTool + " in the system " + "path. This tool is required to process Play " + "Services dependencies. Either set JAVA_HOME " + "or add " + javaTool + " to the PATH variable " + "to resolve this error.", "OK"); throw new Exception(javaTool + " not found."); } } return(toolPath); }
/// <summary> /// Find a Java tool. /// </summary> /// <param name="toolName">Name of the tool to search for.</param> /// <returns>Path to the tool if it's found, throws a ToolNotFoundException /// otherwise.</returns> private static string FindJavaTool(string javaTool) { var javaHome = JavaHome; string toolPath = null; if (!String.IsNullOrEmpty(javaHome)) { toolPath = JavaHomeBinaryPath(javaTool); if (String.IsNullOrEmpty(toolPath)) { EditorUtility.DisplayDialog( "Android Resolver", String.Format("{0} environment references a directory ({1}) that does " + "not contain {2} which is required to process Android " + "libraries.", JAVA_HOME, javaHome, toolPath), "OK"); throw new ToolNotFoundException( String.Format("{0} not found, {1} references incomplete Java distribution.", javaTool, javaHome)); } } else { toolPath = CommandLine.FindExecutable(javaTool); if (!File.Exists(toolPath)) { EditorUtility.DisplayDialog( "Android Resolver", String.Format("Unable to find {0} in the system path. This tool is " + "required to process Android libraries. Please configure " + "your JDK location under the " + "'Unity Preferences > External Tools' menu.", javaTool), "OK"); throw new ToolNotFoundException(javaTool + " not found."); } } return(toolPath); }
/// <summary> /// Find a tool in the Android SDK. /// </summary> /// <param name="svcSupport">PlayServicesSupport instance used to retrieve the SDK /// path. </param> /// <param name="toolName">Name of the tool to search for.</param> /// <returns>String with the path to the tool if found, null otherwise.</returns> internal static string FindAndroidSdkTool(PlayServicesSupport svcSupport, string toolName) { string toolPath = null; string sdkPath = svcSupport.SDK; if (sdkPath == null || sdkPath == "") { Debug.LogWarning(PlayServicesSupport.AndroidSdkConfigurationError + " Will fallback to searching for " + toolName + " in the system path."); } else { string[] extensions; if (UnityEngine.RuntimePlatform.WindowsEditor == UnityEngine.Application.platform) { extensions = new string[] { CommandLine.GetExecutableExtension(), ".bat", ".cmd" }; } else { extensions = new string[] { CommandLine.GetExecutableExtension() }; } foreach (var extension in extensions) { toolPath = Path.Combine(sdkPath, Path.Combine("tools", toolName + extension)); if (File.Exists(toolPath)) { break; } } } if (toolPath == null || !File.Exists(toolPath)) { toolPath = CommandLine.FindExecutable(toolName); } return(toolPath); }
/// <summary> /// Find a tool in the Android SDK. /// </summary> /// <param name="svcSupport">PlayServicesSupport instance used to retrieve the SDK /// path. </param> /// <param name="toolName">Name of the tool to search for.</param> /// <returns>String with the path to the tool if found, null otherwise.</returns> internal static string FindAndroidSdkTool(PlayServicesSupport svcSupport, string toolName) { string toolPath = null; string sdkPath = svcSupport.SDK; if (sdkPath == null || sdkPath == "") { Debug.LogWarning(PlayServicesSupport.AndroidSdkConfigurationError + " Will fallback to searching for " + toolName + " in the system path."); } else { toolPath = Path.Combine( sdkPath, Path.Combine( "tools", toolName + CommandLine.GetExecutableExtension())); } if (toolPath == null || !File.Exists(toolPath)) { toolPath = CommandLine.FindExecutable(toolName); } return(toolPath); }
/// <summary> /// Find a tool in the Android SDK. /// </summary> /// <param name="toolName">Name of the tool to search for.</param> /// <param name="sdkPath">SDK path to search for the tool. If this is null or empty, the // system path is searched instead.</param> /// <returns>String with the path to the tool if found, null otherwise.</returns> private static string FindAndroidSdkTool(string toolName, string sdkPath = null) { if (String.IsNullOrEmpty(sdkPath)) { PlayServicesResolver.Log(String.Format( "{0}\n" + "Falling back to searching for the Android SDK tool {1} in the system path.", PlayServicesSupport.AndroidSdkConfigurationError, toolName)); } else { var extensions = new List <string> { CommandLine.GetExecutableExtension() }; if (UnityEngine.RuntimePlatform.WindowsEditor == UnityEngine.Application.platform) { extensions.AddRange(new [] { ".bat", ".cmd" }); } foreach (var dir in new [] { "tools", Path.Combine("tools", "bin") }) { foreach (var extension in extensions) { var currentPath = Path.Combine(sdkPath, Path.Combine(dir, toolName + extension)); if (File.Exists(currentPath)) { return(currentPath); } } } } var toolPath = CommandLine.FindExecutable(toolName); return(toolPath != null && File.Exists(toolPath) ? toolPath : null); }