private static void SelectXcode(ref string DeveloperDir, bool bVerbose) { string Reason = "hardcoded"; if (DeveloperDir == "xcode-select") { Reason = "xcode-select"; // on the Mac, run xcode-select directly DeveloperDir = Utils.RunLocalProcessAndReturnStdOut("xcode-select", "--print-path"); // make sure we get a full path if (Directory.Exists(DeveloperDir) == false) { throw new BuildException("Selected Xcode ('{0}') doesn't exist, cannot continue.", DeveloperDir); } if (DeveloperDir.EndsWith("/") == false) { // we expect this to end with a slash DeveloperDir += "/"; } } if (bVerbose && !DeveloperDir.StartsWith("/Applications/Xcode.app")) { Log.TraceInformationOnce("Compiling with non-standard Xcode ({0}): {1}", Reason, DeveloperDir); } }
protected Version GetClangVersion() { if (ClangVersion == null) { FileReference ClangLocation = new FileReference("/usr/bin/clang"); string VersionString = Utils.RunLocalProcessAndReturnStdOut(ClangLocation.FullName, "--version"); Match M = Regex.Match(VersionString, @"version\s+(\d+)\.(\d+)\.(\d+)"); if (M.Success) { ClangVersion = new Version( Convert.ToInt32(M.Groups[1].ToString()), Convert.ToInt32(M.Groups[2].ToString()), Convert.ToInt32(M.Groups[3].ToString()) ); } else { Log.TraceError("Failed to detect clang version from output of {0} --version. Output={1}", ClangLocation.FullName, VersionString); ClangVersion = new Version(0, 0, 0); } } return(ClangVersion); }
public string RunMabuAndReadOutput(string Params) { try { return(Utils.RunLocalProcessAndReturnStdOut(MabuPath, Params)); } catch (Exception e) { throw new BuildException("Running mabu failed: '{0}'", e.Message); } }
private static void SelectXcode(ref string DeveloperDir, bool bVerbose) { string Reason = "hardcoded"; if (DeveloperDir == "xcode-select") { Reason = "xcode-select"; // on the Mac, run xcode-select directly DeveloperDir = Utils.RunLocalProcessAndReturnStdOut("xcode-select", "--print-path"); // make sure we get a full path if (Directory.Exists(DeveloperDir) == false) { throw new BuildException("Selected Xcode ('{0}') doesn't exist, cannot continue.", DeveloperDir); } if (DeveloperDir.EndsWith("/") == false) { // we expect this to end with a slash DeveloperDir += "/"; } } if (bVerbose && !DeveloperDir.StartsWith("/Applications/Xcode.app")) { Log.TraceInformationOnce("Compiling with non-standard Xcode ({0}): {1}", Reason, DeveloperDir); } // Installed engine requires Xcode 11 if (UnrealBuildTool.IsEngineInstalled()) { string XcodeBuilderVersionOutput = Utils.RunLocalProcessAndReturnStdOut("xcodebuild", "-version"); if (XcodeBuilderVersionOutput.Length > 10) { string[] Version = XcodeBuilderVersionOutput.Substring(6, 4).Split('.'); if (Version.Length == 2) { if (int.Parse(Version[0]) < 11) { throw new BuildException("Building for macOS, iOS and tvOS requires Xcode 11 or newer, Xcode " + Version[0] + "." + Version[1] + " detected"); } } else { Log.TraceWarning("Failed to query Xcode version"); } } else { Log.TraceWarning("Failed to query Xcode version"); } } }
/// <summary> /// Runs the provided tool and argument and parses the output to retrieve the version /// </summary> /// <param name="Command">Full path to the tool to run</param> /// <param name="VersionArg">Argument that will result in the version string being shown (it's ok this is a byproduct of a command that returns an error)</param> /// <param name="VersionExpression">Regular expression to capture the version. By default we look for four integers separated by periods, with the last two optional</param> /// <returns></returns> public static Version RunToolAndCaptureVersion(FileReference Command, string VersionArg, string VersionExpression = @"(\d+\.\d+(\.\d+)?(\.\d+)?)") { string ProcessOutput = Utils.RunLocalProcessAndReturnStdOut(Command.FullName, VersionArg); Match M = Regex.Match(ProcessOutput, VersionExpression); Version ToolVersion = new Version(0, 0); if (M.Success && Version.TryParse(M.Groups[1].ToString(), out ToolVersion)) { return(ToolVersion); } Log.TraceWarning("Unable to retrieve version from {0} {1}", Command, VersionArg); return(ToolVersion); }
/// <summary> /// Runs external program. Blocking. /// </summary> /// <param name="Executable"> Executable</param> /// <param name="CommandLine"> Commandline</param> /// <returns>bool Application ran successfully</returns> protected bool RunExternalProgram(string Executable, string CommandLine) { if (File.Exists(Executable) == false) { throw new BuildException("BUILD FAILED: Couldn't find the executable to Run: {0}", Executable); } int ExitCode; string StdOutString = Utils.RunLocalProcessAndReturnStdOut(Executable, CommandLine, out ExitCode, (Log.OutputLevel >= LogEventType.Verbose)); if (ExitCode == 0) { return(true); } else { Log.TraceError(Path.GetFileName(Executable) + " returned an error.\nApplication output:\n" + StdOutString); return(false); } }
protected static void SelectXcode(ref string DeveloperDir, bool bVerbose) { string Reason = "hardcoded"; if (DeveloperDir == "xcode-select") { Reason = "xcode-select"; if (Utils.IsRunningOnMono) { // on the Mac, run xcode-select directly DeveloperDir = Utils.RunLocalProcessAndReturnStdOut("xcode-select", "--print-path"); // make sure we get a full path if (Directory.Exists(DeveloperDir) == false) { throw new BuildException("Selected Xcode ('{0}') doesn't exist, cannot continue.", DeveloperDir); } } else { Hashtable Results = RPCUtilHelper.Command("/", "xcode-select", "--print-path", null); if (Results != null) { DeveloperDir = (string)Results["CommandOutput"]; DeveloperDir = DeveloperDir.TrimEnd(); } } if (DeveloperDir.EndsWith("/") == false) { // we expect this to end with a slash DeveloperDir += "/"; } } if (bVerbose && !DeveloperDir.StartsWith("/Applications/Xcode.app")) { Log.TraceInformationOnce("Compiling with non-standard Xcode ({0}): {1}", Reason, DeveloperDir); } }
protected string GetDsymutilPath(out string ExtraOptions, bool bIsForLTOBuild = false) { FileReference DsymutilLocation = new FileReference("/usr/bin/dsymutil"); // dsymutil before 10.0.1 has a bug that causes issues, it's fixed in autosdks but not everyone has those set up so for the timebeing we have // a version in P4 - first determine if we need it string DsymutilVersionString = Utils.RunLocalProcessAndReturnStdOut(DsymutilLocation.FullName, "-version"); bool bUseInstalledDsymutil = true; int Major = 0, Minor = 0, Patch = 0; // tease out the version number string[] Tokens = DsymutilVersionString.Split(" ".ToCharArray()); // sanity check if (Tokens.Length < 4 || Tokens[3].Contains(".") == false) { Log.TraceInformationOnce("Unable to parse dsymutil version out of: {0}", DsymutilVersionString); bUseInstalledDsymutil = false; } else { string[] Versions = Tokens[3].Split(".".ToCharArray()); if (Versions.Length < 3) { Log.TraceInformationOnce("Unable to parse version token: {0}", Tokens[3]); } else { if (!int.TryParse(Versions[0], out Major) || !int.TryParse(Versions[1], out Minor) || !int.TryParse(Versions[2], out Patch)) { Log.TraceInformationOnce("Unable to parse version tokens: {0}", Tokens[3]); } else { Log.TraceInformationOnce("Parsed dsymutil version as {0}.{1}.{2}", Major, Minor, Patch); if (Major < 10 || (Minor == 0 && Patch == 0)) { bUseInstalledDsymutil = false; } } } } // if the installed one is too old, use a fixed up one if it can if (bUseInstalledDsymutil == false) { FileReference PatchedDsymutilLocation = FileReference.Combine(UnrealBuildTool.EngineDirectory, "Binaries/Mac/NotForLicensees/LLVM/bin/dsymutil"); if (File.Exists(PatchedDsymutilLocation.FullName)) { DsymutilLocation = PatchedDsymutilLocation; } DirectoryReference AutoSdkDir; if (UEBuildPlatformSDK.TryGetHostPlatformAutoSDKDir(out AutoSdkDir)) { FileReference AutoSdkDsymutilLocation = FileReference.Combine(AutoSdkDir, "Mac", "LLVM", "bin", "dsymutil"); if (FileReference.Exists(AutoSdkDsymutilLocation)) { DsymutilLocation = AutoSdkDsymutilLocation; } } } // 10.0.1 has an issue with LTO builds where we need to limit the number of threads ExtraOptions = (bIsForLTOBuild && Major == 10 && Minor == 0 && Patch == 1) ? "-j 1" : ""; return(DsymutilLocation.FullName); }