void CleanWithUBT(string TargetName, UnrealBuildTool.UnrealTargetPlatform Platform, string Config, FileReference UprojectPath, bool ForceMonolithic = false, bool ForceNonUnity = false, bool ForceDebugInfo = false, string InAddArgs = "", bool ForceUnity = false, Dictionary<string, string> EnvVars = null) { string AddArgs = ""; if (UprojectPath != null) { AddArgs += " " + CommandUtils.MakePathSafeToUseWithCommandLine(UprojectPath.FullName); } AddArgs += " " + InAddArgs; if (ForceMonolithic) { AddArgs += " -monolithic"; } if (ForceNonUnity) { AddArgs += " -disableunity"; } if (ForceUnity) { AddArgs += " -forceunity"; } if (ForceDebugInfo) { AddArgs += " -forcedebuginfo"; } if (!TargetName.Equals("UnrealHeaderTool", StringComparison.InvariantCultureIgnoreCase)) { AddArgs += " -nobuilduht"; } PrepareUBT(); using(TelemetryStopwatch CleanStopwatch = new TelemetryStopwatch("CleanWithUBT.{0}.{1}.{2}", TargetName, Platform.ToString(), Config)) { RunUBT(CmdEnv, UBTExecutable: UBTExecutable, Project: UprojectPath, Target: TargetName, Platform: Platform.ToString(), Config: Config, AdditionalArgs: "-clean" + AddArgs, EnvVars: EnvVars); } }
BuildManifest BuildWithUBT(string TargetName, UnrealBuildTool.UnrealTargetPlatform TargetPlatform, string Config, FileReference UprojectPath, bool ForceMonolithic = false, bool ForceNonUnity = false, bool ForceDebugInfo = false, bool ForceFlushMac = false, bool DisableXGE = false, string InAddArgs = "", bool ForceUnity = false, Dictionary<string, string> EnvVars = null) { string AddArgs = ""; if (UprojectPath != null) { AddArgs += " " + CommandUtils.MakePathSafeToUseWithCommandLine(UprojectPath.FullName); } AddArgs += " " + InAddArgs; if (ForceMonolithic) { AddArgs += " -monolithic"; } if (ForceNonUnity) { AddArgs += " -disableunity"; } if (ForceUnity) { AddArgs += " -forceunity"; } if (ForceDebugInfo) { AddArgs += " -forcedebuginfo"; } if (ForceFlushMac) { AddArgs += " -flushmac"; } if (DisableXGE) { AddArgs += " -noxge"; } PrepareUBT(); // let the platform determine when to use the manifest bool UseManifest = Platform.GetPlatform(TargetPlatform).ShouldUseManifestForUBTBuilds(AddArgs); BuildManifest Manifest = null; if (UseManifest) { string UBTManifest = GetUBTManifest(UprojectPath, AddArgs); DeleteFile(UBTManifest); using(TelemetryStopwatch PrepareManifestStopwatch = new TelemetryStopwatch("PrepareUBTManifest.{0}.{1}.{2}", TargetName, TargetPlatform.ToString(), Config)) { RunUBT(CmdEnv, UBTExecutable: UBTExecutable, Project: UprojectPath, Target: TargetName, Platform: TargetPlatform.ToString(), Config: Config, AdditionalArgs: AddArgs + " -generatemanifest", EnvVars: EnvVars); } Manifest = PrepareManifest(UBTManifest, false); } using(TelemetryStopwatch CompileStopwatch = new TelemetryStopwatch("Compile.{0}.{1}.{2}", TargetName, TargetPlatform.ToString(), Config)) { RunUBT(CmdEnv, UBTExecutable: UBTExecutable, Project: UprojectPath, Target: TargetName, Platform: TargetPlatform.ToString(), Config: Config, AdditionalArgs: AddArgs, EnvVars: EnvVars); } if(!AddArgs.Contains("-nolink")) { // allow the platform to perform any actions after building a target (seems almost like this should be done in UBT) Platform.GetPlatform(TargetPlatform).PostBuildTarget(this, UprojectPath, TargetName, Config); } if (UseManifest) { string UBTManifest = GetUBTManifest(UprojectPath, AddArgs); AddBuildProductsFromManifest(UBTManifest); DeleteFile(UBTManifest); } return Manifest; }
XGEItem XGEPrepareBuildWithUBT(string TargetName, UnrealBuildTool.UnrealTargetPlatform Platform, string Config, FileReference UprojectPath, bool ForceMonolithic = false, bool ForceNonUnity = false, bool ForceDebugInfo = false, string InAddArgs = "", bool ForceUnity = false, Dictionary<string, string> EnvVars = null) { string AddArgs = ""; if (UprojectPath != null) { AddArgs += " " + CommandUtils.MakePathSafeToUseWithCommandLine(UprojectPath.FullName); } AddArgs += " " + InAddArgs; if (ForceMonolithic) { AddArgs += " -monolithic"; } if (ForceNonUnity) { AddArgs += " -disableunity"; } if (ForceUnity) { AddArgs += " -forceunity"; } if (ForceDebugInfo) { AddArgs += " -forcedebuginfo"; } PrepareUBT(); string UBTManifest = GetUBTManifest(UprojectPath, AddArgs); DeleteFile(UBTManifest); XGEItem Result = new XGEItem(); ClearExportedXGEXML(); using(TelemetryStopwatch GenerateManifestStopwatch = new TelemetryStopwatch("GenerateXGEManifest.{0}.{1}.{2}", TargetName, Platform.ToString(), Config)) { RunUBT(CmdEnv, UBTExecutable: UBTExecutable, Project: UprojectPath, Target: TargetName, Platform: Platform.ToString(), Config: Config, AdditionalArgs: "-generatemanifest -nobuilduht -xgeexport" + AddArgs, EnvVars: EnvVars); } PrepareManifest(UBTManifest, true); Result.Platform = Platform; Result.Config = Config; Result.TargetName = TargetName; Result.UProjectPath = UprojectPath; Result.Manifest = ReadManifest(UBTManifest); Result.OutputCaption = String.Format("{0}-{1}-{2}", TargetName, Platform.ToString(), Config.ToString()); DeleteFile(UBTManifest); Result.CommandLine = UBTExecutable + " " + UBTCommandline(Project: UprojectPath, Target: TargetName, Platform: Platform.ToString(), Config: Config, AdditionalArgs: "-noxge -nobuilduht" + AddArgs); Result.XgeXmlFiles = new List<string>(); foreach (var XGEFile in FindXGEFiles()) { if (!FileExists_NoExceptions(XGEFile)) { throw new AutomationException("BUILD FAILED: Couldn't find file: {0}", XGEFile); } int FileNum = 0; string OutFile; while (true) { OutFile = CombinePaths(CmdEnv.LogFolder, String.Format("UBTExport.{0}.xge.xml", FileNum)); FileInfo ItemInfo = new FileInfo(OutFile); if (!ItemInfo.Exists) { break; } FileNum++; } CopyFile(XGEFile, OutFile); Result.XgeXmlFiles.Add(OutFile); } ClearExportedXGEXML(); return Result; }