// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Text; namespace AutomationTool { public partial class CommandUtils { /// /// True if UBT has deleted junk files /// private static bool bJunkDeleted = false; /// /// Runs UBT with the specified commandline. Automatically creates a logfile. When /// no LogName is specified, the executable name is used as logfile base name. /// /// Environment to use. /// Commandline to pass on to UBT. /// Optional logfile name. public static void RunUBT(CommandEnvironment Env, string UBTExecutable, string CommandLine, string LogName = null, Dictionary EnvVars = null) { if (!FileExists(UBTExecutable)) { throw new AutomationException("Unable to find UBT executable: " + UBTExecutable); } if (GlobalCommandLine.Rocket) { CommandLine += " -rocket"; } if (!IsBuildMachine && UnrealBuildTool.BuildHostPlatform.Current.Platform == UnrealBuildTool.UnrealTargetPlatform.Mac) { CommandLine += " -nocreatestub"; } CommandLine += " -NoHotReloadFromIDE"; if (bJunkDeleted || GlobalCommandLine.IgnoreJunk) { // UBT has already deleted junk files, make sure it doesn't do it again CommandLine += " -ignorejunk"; } else { // UBT will delete junk on first run bJunkDeleted = true; } CommandUtils.RunAndLog(Env, UBTExecutable, CommandLine, LogName, EnvVars: EnvVars); } /// /// Builds a UBT Commandline. /// /// Unreal project to build (optional) /// Target to build. /// Platform to build for. /// Configuration to build. /// Additional arguments to pass on to UBT. public static string UBTCommandline(string Project, string Target, string Platform, string Config, string AdditionalArgs = "") { string CmdLine; if (String.IsNullOrEmpty(Project)) { CmdLine = String.Format("{0} {1} {2} {3}", Target, Platform, Config, AdditionalArgs); } else { CmdLine = String.Format("{0} {1} {2} -Project={3} {4}", Target, Platform, Config, CommandUtils.MakePathSafeToUseWithCommandLine(Project), AdditionalArgs); } return CmdLine; } /// /// Builds a target using UBT. Automatically creates a logfile. When /// no LogName is specified, the executable name is used as logfile base name. /// /// BuildEnvironment to use. /// Unreal project to build (optional) /// Target to build. /// Platform to build for. /// Configuration to build. /// Additional arguments to pass on to UBT. /// Optional logifle name. public static void RunUBT(CommandEnvironment Env, string UBTExecutable, string Project, string Target, string Platform, string Config, string AdditionalArgs = "", string LogName = null, Dictionary EnvVars = null) { RunUBT(Env, UBTExecutable, UBTCommandline(Project, Target, Platform, Config, AdditionalArgs), LogName, EnvVars); } } }