/// <summary> /// Execute the task and compile these targets. /// </summary> /// <param name="BuildProducts">Current list of build products for this node</param> /// <returns>True if the task succeeded</returns> public override bool Execute(List <string> BuildProducts) { UE4Build Builder = new UE4Build(null); UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); Agenda.Targets.AddRange(Targets); Builder.Build(Agenda, InDeleteBuildProducts: false, InUpdateVersionFiles: false, InForceNoXGE: true, InForceUnity: true, InUseParallelExecutor: false); UE4Build.CheckBuildProducts(Builder.BuildProductFiles); BuildProducts.AddRange(Builder.BuildProductFiles); return(true); }
public override void ExecuteBuild() { Log("************************* BuildCommonTools"); // Get the list of platform names string[] PlatformNames = ParseParamValue("platforms", BuildHostPlatform.Current.Platform.ToString()).Split('+'); // Parse the platforms List <UnrealBuildTool.UnrealTargetPlatform> Platforms = new List <UnrealTargetPlatform>(); foreach (string PlatformName in PlatformNames) { UnrealBuildTool.UnrealTargetPlatform Platform; if (!UnrealBuildTool.UnrealTargetPlatform.TryParse(PlatformName, out Platform)) { throw new AutomationException("Unknown platform specified on command line - '{0}' - valid platforms are {1}", PlatformName, String.Join("/", Enum.GetNames(typeof(UnrealBuildTool.UnrealTargetPlatform)))); } Platforms.Add(Platform); } // Get the agenda UE4Build.BuildAgenda Agenda = MakeAgenda(Platforms.ToArray()); // Build everything. We don't want to touch version files for GitHub builds -- these are "programmer builds" and won't have a canonical build version UE4Build Builder = new UE4Build(this); Builder.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: false); // Add UAT and UBT to the build products Builder.AddUATFilesToBuildProducts(); Builder.AddUBTFilesToBuildProducts(); // Make sure all the build products exist UE4Build.CheckBuildProducts(Builder.BuildProductFiles); // Write the manifest if needed string ManifestPath = ParseParamValue("manifest"); if (ManifestPath != null) { UnrealBuildTool.FileManifest Manifest = new UnrealBuildTool.FileManifest(); foreach (string BuildProductFile in Builder.BuildProductFiles) { Manifest.AddFileName(BuildProductFile); } UnrealBuildTool.Utils.WriteClass(Manifest, ManifestPath, ""); } }
/// <summary> /// Execute the task. /// </summary> /// <param name="Job">Information about the current job</param> /// <param name="BuildProducts">Set of build products produced by this node.</param> /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param> /// <returns>True if the task succeeded</returns> public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet) { // Create the agenda UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); Agenda.Targets.AddRange(Targets); // Build everything Dictionary <UE4Build.BuildTarget, BuildManifest> TargetToManifest = new Dictionary <UE4Build.BuildTarget, BuildManifest>(); UE4Build Builder = new UE4Build(Job.OwnerCommand); try { bool bCanUseParallelExecutor = (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64); // parallel executor is only available on Windows as of 2016-09-22 Builder.Build(Agenda, InDeleteBuildProducts: null, InUpdateVersionFiles: false, InForceNoXGE: false, InUseParallelExecutor: bCanUseParallelExecutor, InTargetToManifest: TargetToManifest); } catch (CommandUtils.CommandFailedException) { return(false); } UE4Build.CheckBuildProducts(Builder.BuildProductFiles); // Tag all the outputs foreach (KeyValuePair <UE4Build.BuildTarget, string> TargetTagName in TargetToTagName) { BuildManifest Manifest; if (!TargetToManifest.TryGetValue(TargetTagName.Key, out Manifest)) { throw new AutomationException("Missing manifest for target {0} {1} {2}", TargetTagName.Key.TargetName, TargetTagName.Key.Platform, TargetTagName.Key.Config); } foreach (string TagName in SplitDelimitedList(TargetTagName.Value)) { HashSet <FileReference> FileSet = FindOrAddTagSet(TagNameToFileSet, TagName); FileSet.UnionWith(Manifest.BuildProducts.Select(x => new FileReference(x))); FileSet.UnionWith(Manifest.LibraryBuildProducts.Select(x => new FileReference(x))); } } // Add everything to the list of build products BuildProducts.UnionWith(Builder.BuildProductFiles.Select(x => new FileReference(x))); BuildProducts.UnionWith(Builder.LibraryBuildProductFiles.Select(x => new FileReference(x))); return(true); }
// Broken down steps used to run the process. #region RebuildHLOD Process Steps private void BuildNecessaryTargets() { LogInformation("Running Step:- RebuildHLOD::BuildNecessaryTargets"); UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); Agenda.AddTarget("UnrealHeaderTool", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development); Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development); Agenda.AddTarget(CommandletTargetName, UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development); try { UE4Build Builder = new UE4Build(this); Builder.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true, InForceNoXGE: false, InChangelistNumberOverride: GetLatestCodeChange()); UE4Build.CheckBuildProducts(Builder.BuildProductFiles); } catch (AutomationException) { LogError("Rebuild HLOD for Maps has failed."); throw; } }
// Broken down steps used to run the process. #region RebuildLightMaps Process Steps private void BuildNecessaryTargets() { Log("Running Step:- RebuildLightMaps::BuildNecessaryTargets"); UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development); Agenda.AddTarget("UnrealLightmass", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development); Agenda.AddTarget(CommandletTargetName, UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development); try { UE4Build Builder = new UE4Build(this); Builder.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true, InForceNoXGE: false); UE4Build.CheckBuildProducts(Builder.BuildProductFiles); } catch (AutomationException Ex) { LogError("Rebuild Light Maps has failed."); throw Ex; } }
public override void ExecuteBuild() { var Build = new UE4Build(this); var Agenda = new UE4Build.BuildAgenda(); var Platform = UnrealBuildTool.UnrealTargetPlatform.Win64; var Configuration = UnrealBuildTool.UnrealTargetConfiguration.Development; var Targets = new List <string>(); foreach (var ObjParam in Params) { var Param = (string)ObjParam; if (!UnrealTargetPlatform.TryParse(Param, out Platform)) { continue; } UnrealBuildTool.UnrealTargetConfiguration ParseConfiguration; if (Enum.TryParse <UnrealBuildTool.UnrealTargetConfiguration>(Param, true, out ParseConfiguration)) { Configuration = ParseConfiguration; continue; } if (String.Compare("NoXGE", Param, true) != 0 && String.Compare("Clean", Param, true) != 0) { Targets.Add(Param); } } var Clean = ParseParam("Clean"); Agenda.AddTargets(Targets.ToArray(), Platform, Configuration); LogInformation("UBT Buid"); LogInformation("Targets={0}", String.Join(",", Targets)); LogInformation("Platform={0}", Platform); LogInformation("Configuration={0}", Configuration); LogInformation("Clean={0}", Clean); Build.Build(Agenda, InUpdateVersionFiles: false); LogInformation("UBT Completed"); }
private static void BuildProduct(BuildCommand Command, UE4Build.BuildTarget Target) { if (Target == null) { throw new AutomationException("Target is required when calling UE4BuildUtils.BuildProduct"); } Log("Building {0}", Target.TargetName); if (Command == null) { Command = new UE4BuildUtilDummyBuildCommand(); } var UE4Build = new UE4Build(Command); var Agenda = new UE4Build.BuildAgenda(); Agenda.Targets.Add(Target); UE4Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true); UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles); }
/// <summary> /// Builds BuildPatchTool for the specified platform. /// </summary> /// <param name="Command"></param> /// <param name="InPlatform"></param> public static void BuildBuildPatchTool(BuildCommand Command, UnrealBuildTool.UnrealTargetPlatform InPlatform) { Log("Building BuildPatchTool"); if (Command == null) { Command = new UE4BuildUtilDummyBuildCommand(); } var UE4Build = new UE4Build(Command); var Agenda = new UE4Build.BuildAgenda(); Agenda.Targets.Add(new UE4Build.BuildTarget() { ProjectName = "", TargetName = "BuildPatchTool", Platform = InPlatform, Config = UnrealBuildTool.UnrealTargetConfiguration.Development, }); UE4Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true); UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles); }
public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1, ProjectBuildTargets TargetMask = ProjectBuildTargets.All) { Params.ValidateAndLog(); if (!Params.Build) { return; } Log("********** BUILD COMMAND STARTED **********"); var UE4Build = new UE4Build(Command); var Agenda = new UE4Build.BuildAgenda(); var CrashReportPlatforms = new HashSet <UnrealTargetPlatform>(); // Setup editor targets if (Params.HasEditorTargets && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Editor) == ProjectBuildTargets.Editor) { // @todo Mac: proper platform detection UnrealTargetPlatform EditorPlatform = HostPlatform.Current.HostEditorPlatform; const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development; CrashReportPlatforms.Add(EditorPlatform); Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath); if (Params.EditorTargets.Contains("UnrealHeaderTool") == false) { Agenda.AddTargets(new string[] { "UnrealHeaderTool" }, EditorPlatform, EditorConfiguration); } if (Params.EditorTargets.Contains("ShaderCompileWorker") == false) { Agenda.AddTargets(new string[] { "ShaderCompileWorker" }, EditorPlatform, EditorConfiguration); } if (Params.Pak && Params.EditorTargets.Contains("UnrealPak") == false) { Agenda.AddTargets(new string[] { "UnrealPak" }, EditorPlatform, EditorConfiguration); } if (Params.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false) { Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration); } } // Setup cooked targets if (Params.HasClientCookedTargets && (TargetMask & ProjectBuildTargets.ClientCooked) == ProjectBuildTargets.ClientCooked) { List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList(); foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatformType in UniquePlatformTypes) { string AdditionalArgs = GetBlueprintPluginPathArgument(Params, true, ClientPlatformType); AdditionalArgs += " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\""; if (Params.IsCodeBasedProject == false) { AdditionalArgs += " -project=\"" + Path.GetFullPath(Params.RawProjectPath.FullName) + "\""; } CrashReportPlatforms.Add(ClientPlatformType); Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: AdditionalArgs); } } } if (Params.HasServerCookedTargets && (TargetMask & ProjectBuildTargets.ServerCooked) == ProjectBuildTargets.ServerCooked) { List <UnrealTargetPlatform> UniquePlatformTypes = Params.ServerTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList(); foreach (var BuildConfig in Params.ServerConfigsToBuild) { foreach (var ServerPlatformType in UniquePlatformTypes) { string AdditionalArgs = GetBlueprintPluginPathArgument(Params, false, ServerPlatformType); AdditionalArgs += " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\""; if (Params.IsCodeBasedProject == false) { AdditionalArgs += " -project=\"" + Path.GetFullPath(Params.RawProjectPath.FullName) + "\""; } CrashReportPlatforms.Add(ServerPlatformType); Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: AdditionalArgs); } } } if (!Params.NoBootstrapExe && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Bootstrap) == ProjectBuildTargets.Bootstrap) { UnrealBuildTool.UnrealTargetPlatform[] BootstrapPackagedGamePlatforms = { UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetPlatform.Win64 }; foreach (UnrealBuildTool.UnrealTargetPlatform BootstrapPackagedGamePlatformType in BootstrapPackagedGamePlatforms) { if (Params.ClientTargetPlatforms.Contains(new TargetPlatformDescriptor(BootstrapPackagedGamePlatformType))) { Agenda.AddTarget("BootstrapPackagedGame", BootstrapPackagedGamePlatformType, UnrealBuildTool.UnrealTargetConfiguration.Shipping); } } } if (Params.CrashReporter && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.CrashReporter) == ProjectBuildTargets.CrashReporter) { foreach (var CrashReportPlatform in CrashReportPlatforms) { if (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform)) { Agenda.AddTarget("CrashReportClient", CrashReportPlatform, UnrealTargetConfiguration.Shipping); } } } if (Params.HasProgramTargets && (TargetMask & ProjectBuildTargets.Programs) == ProjectBuildTargets.Programs) { List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList(); foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatformType in UniquePlatformTypes) { Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath); } } } UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0); if (WorkingCL > 0) // only move UAT files if we intend to check in some build products { UE4Build.AddUATFilesToBuildProducts(); } UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles); if (WorkingCL > 0) { // Sign everything we built CodeSign.SignMultipleIfEXEOrDLL(Command, UE4Build.BuildProductFiles); // Open files for add or edit UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles); } Log("********** BUILD COMMAND COMPLETED **********"); }
public override void ExecuteBuild() { int WorkingCL = -1; if (P4Enabled && AllowSubmit) { string CmdLine = ""; foreach (var Arg in Params) { CmdLine += Arg.ToString() + " "; } WorkingCL = P4.CreateChange(P4Env.Client, String.Format("MegaXGE build from changelist {0} - Params: {1}", P4Env.Changelist, CmdLine)); } LogInformation("************************* MegaXGE"); bool Clean = ParseParam("Clean"); string CleanToolLocation = CombinePaths(CmdEnv.LocalRoot, "Engine", "Build", "Batchfiles", "Clean.bat"); bool ShowProgress = ParseParam("Progress"); var UE4Build = new UE4Build(this); var Agenda = new UE4Build.BuildAgenda(); // we need to always build UHT when we use mega XGE var ProgramTargets = new string[] { "UnrealHeaderTool", }; Agenda.AddTargets(ProgramTargets, UnrealTargetPlatform.Win64, UnrealTargetConfiguration.Development); if (Clean) { LogSetProgress(ShowProgress, "Cleaning previous builds..."); foreach (var CurTarget in ProgramTargets) { string Args = String.Format("{0} {1} {2}", CurTarget, UnrealTargetPlatform.Win64.ToString(), UnrealTargetConfiguration.Development.ToString()); RunAndLog(CmdEnv, CleanToolLocation, Args); } } LogInformation("*************************"); for (int Arg = 1; Arg < 100; Arg++) { string Parm = String.Format("Target{0}", Arg); string Target = ParseParamValue(Parm, ""); if (String.IsNullOrEmpty(Target)) { break; } FileReference ProjectFile = null; string ProjectFileParam = ParseParamValue(String.Format("Project{0}", Arg), null); if (ProjectFileParam != null) { ProjectFile = new FileReference(ProjectFileParam); if (!FileReference.Exists(ProjectFile)) { throw new AutomationException("Project file '{0}' could not be found"); } } var Parts = Target.Split(' '); string JustTarget = Parts[0]; if (String.IsNullOrEmpty(JustTarget)) { throw new AutomationException("BUILD FAILED target option '{0}' not parsed.", Target); } var Targets = JustTarget.Split('|'); if (Targets.Length < 1) { throw new AutomationException("BUILD FAILED target option '{0}' not parsed.", Target); } var Platforms = new List <UnrealTargetPlatform>(); var Configurations = new List <UnrealTargetConfiguration>(); for (int Part = 1; Part < Parts.Length; Part++) { if (!String.IsNullOrEmpty(Parts[Part])) { var SubParts = Parts[Part].Split('|'); foreach (var SubPart in SubParts) { UnrealTargetPlatform Platform; if (UnrealTargetPlatform.TryParse(SubPart, out Platform)) { Platforms.Add(Platform); } else { switch (SubPart.ToUpperInvariant()) { case "DEBUG": Configurations.Add(UnrealTargetConfiguration.Debug); break; case "DEBUGGAME": Configurations.Add(UnrealTargetConfiguration.DebugGame); break; case "DEVELOPMENT": Configurations.Add(UnrealTargetConfiguration.Development); break; case "SHIPPING": Configurations.Add(UnrealTargetConfiguration.Shipping); break; case "TEST": Configurations.Add(UnrealTargetConfiguration.Test); break; default: throw new AutomationException("BUILD FAILED target option {0} not recognized.", SubPart); } } } } } if (Platforms.Count < 1) { Platforms.Add(UnrealTargetPlatform.Win64); } if (Configurations.Count < 1) { Configurations.Add(UnrealTargetConfiguration.Development); } foreach (var Platform in Platforms) { foreach (var CurTarget in Targets) { foreach (var Configuration in Configurations) { Agenda.AddTargets(new string[] { CurTarget }, Platform, Configuration, ProjectFile); LogInformation("Target {0} {1} {2}", CurTarget, Platform.ToString(), Configuration.ToString()); if (Clean) { string Args = String.Format("{0} {1} {2}", CurTarget, Platform.ToString(), Configuration.ToString()); RunAndLog(CmdEnv, CleanToolLocation, Args); } } } } } LogInformation("*************************"); UE4Build.Build(Agenda, InUpdateVersionFiles: IsBuildMachine, InUseParallelExecutor: ParseParam("useparallelexecutor"), InShowProgress: ShowProgress); // if (WorkingCL > 0) // only move UAT files if we intend to check in some build products // { // UE4Build.CopyUATFilesAndAddToBuildProducts(); // } UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles); if (WorkingCL > 0) { // Sign everything we built CodeSign.SignMultipleIfEXEOrDLL(this, UE4Build.BuildProductFiles); // Open files for add or edit UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles); int SubmittedCL; P4.Submit(WorkingCL, out SubmittedCL, true, true); } PrintRunTime(); }
public override void ExecuteBuild() { if (ParseParam("BuildEditor")) { UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); Agenda.AddTarget("UE4Editor", HostPlatform.Current.HostEditorPlatform, UnrealTargetConfiguration.Development); Agenda.AddTarget("ShaderCompileWorker", HostPlatform.Current.HostEditorPlatform, UnrealTargetConfiguration.Development); UE4Build Builder = new UE4Build(this); Builder.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true, InForceNoXGE: true); } var EditorExe = CombinePaths(CmdEnv.LocalRoot, @"Engine/Binaries/Win64/UE4Editor-Cmd.exe"); if (P4Enabled) { Log("Sync necessary content to head revision"); P4.Sync(P4Env.Branch + "/Engine/Config/..."); P4.Sync(P4Env.Branch + "/Engine/Content/..."); P4.Sync(P4Env.Branch + "/Engine/Source/..."); P4.Sync(P4Env.Branch + "/Portal/Config/..."); P4.Sync(P4Env.Branch + "/Portal/Content/..."); P4.Sync(P4Env.Branch + "/Portal/Source/..."); } OneSkyConfigData OneSkyConfig = OneSkyConfigHelper.Find("OneSkyConfig_EpicGames"); var oneSkyService = new OneSkyService(OneSkyConfig.ApiKey, OneSkyConfig.ApiSecret); // Export Launcher text from OneSky { var launcherGroup = GetLauncherGroup(oneSkyService); var appProject = GetAppProject(oneSkyService); var appFile = appProject.UploadedFiles.FirstOrDefault(f => f.Filename == "App.po"); //Export if (appFile != null) { ExportFileToDirectory(appFile, new DirectoryInfo(CmdEnv.LocalRoot + "/Portal/Content/Localization/App"), launcherGroup.EnabledCultures); } } // Setup editor arguments for SCC. string EditorArguments = String.Empty; if (P4Enabled) { EditorArguments = String.Format("-SCCProvider={0} -P4Port={1} -P4User={2} -P4Client={3} -P4Passwd={4}", "Perforce", P4Env.ServerAndPort, P4Env.User, P4Env.Client, P4.GetAuthenticationToken()); } else { EditorArguments = String.Format("-SCCProvider={0}", "None"); } // Setup commandlet arguments for SCC. string CommandletSCCArguments = String.Empty; if (P4Enabled) { CommandletSCCArguments += "-EnableSCC"; } if (!AllowSubmit) { CommandletSCCArguments += (string.IsNullOrEmpty(CommandletSCCArguments) ? "" : " ") + "-DisableSCCSubmit"; } // Setup commandlet arguments with configurations. var CommandletArgumentSets = new string[] { String.Format("-config={0}", @"../Portal/Config/Localization/App.ini") + (string.IsNullOrEmpty(CommandletSCCArguments) ? "" : " " + CommandletSCCArguments) }; // Execute commandlet for each set of arguments. foreach (var CommandletArguments in CommandletArgumentSets) { Log("Localization for {0} {1}", EditorArguments, CommandletArguments); Log("Running UE4Editor to generate Localization data"); string Arguments = String.Format("-run=GatherText {0} {1}", EditorArguments, CommandletArguments); var RunResult = Run(EditorExe, Arguments); if (RunResult.ExitCode != 0) { throw new AutomationException("Error while executing localization commandlet '{0}'", Arguments); } } // Upload Launcher text to OneSky UploadDirectoryToProject(GetAppProject(oneSkyService), new DirectoryInfo(CmdEnv.LocalRoot + "/Portal/Content/Localization/App"), "*.po"); }
public override void ExecuteBuild() { Log("************************* BuildCommonTools"); // Get the list of platform names string[] PlatformNames = ParseParamValue("platforms", BuildHostPlatform.Current.Platform.ToString()).Split('+'); // Parse the platforms List <UnrealBuildTool.UnrealTargetPlatform> Platforms = new List <UnrealTargetPlatform>(); foreach (string PlatformName in PlatformNames) { UnrealBuildTool.UnrealTargetPlatform Platform; if (!UnrealBuildTool.UnrealTargetPlatform.TryParse(PlatformName, true, out Platform)) { throw new AutomationException("Unknown platform specified on command line - '{0}' - valid platforms are {1}", PlatformName, String.Join("/", Enum.GetNames(typeof(UnrealBuildTool.UnrealTargetPlatform)))); } Platforms.Add(Platform); } // Add all the platforms if specified if (ParseParam("allplatforms")) { foreach (UnrealTargetPlatform Platform in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (!Platforms.Contains(Platform)) { Platforms.Add(Platform); } } } // Get the agenda List <string> ExtraBuildProducts = new List <string>(); UE4Build.BuildAgenda Agenda = MakeAgenda(Platforms.ToArray(), ExtraBuildProducts); // Build everything. We don't want to touch version files for GitHub builds -- these are "programmer builds" and won't have a canonical build version UE4Build Builder = new UE4Build(this); Builder.Build(Agenda, InUpdateVersionFiles: false); // Add UAT and UBT to the build products Builder.AddUATFilesToBuildProducts(); Builder.AddUBTFilesToBuildProducts(); // Add all the extra build products foreach (string ExtraBuildProduct in ExtraBuildProducts) { Builder.AddBuildProduct(ExtraBuildProduct); } // Make sure all the build products exist UE4Build.CheckBuildProducts(Builder.BuildProductFiles); // Write the manifest if needed string ManifestPath = ParseParamValue("manifest"); if (ManifestPath != null) { SortedSet <string> Files = new SortedSet <string>(); foreach (string BuildProductFile in Builder.BuildProductFiles) { Files.Add(BuildProductFile); } File.WriteAllLines(ManifestPath, Files.ToArray()); } }
public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1) { Params.ValidateAndLog(); if (!Params.Build) { return; } Log("********** BUILD COMMAND STARTED **********"); var UE4Build = new UE4Build(Command); var Agenda = new UE4Build.BuildAgenda(); var CrashReportPlatforms = new HashSet <UnrealTargetPlatform>(); // Setup editor targets if (Params.HasEditorTargets && !Params.Rocket) { // @todo Mac: proper platform detection UnrealTargetPlatform EditorPlatform = HostPlatform.Current.HostEditorPlatform; const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development; CrashReportPlatforms.Add(EditorPlatform); Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath); if (Params.EditorTargets.Contains("UnrealHeaderTool") == false) { Agenda.AddTargets(new string[] { "UnrealHeaderTool" }, EditorPlatform, EditorConfiguration); } if (Params.EditorTargets.Contains("ShaderCompileWorker") == false) { Agenda.AddTargets(new string[] { "ShaderCompileWorker" }, EditorPlatform, EditorConfiguration); } if (Params.Pak && Params.EditorTargets.Contains("UnrealPak") == false) { Agenda.AddTargets(new string[] { "UnrealPak" }, EditorPlatform, EditorConfiguration); } if (Params.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false) { Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration); } } // Setup cooked targets if (Params.HasClientCookedTargets) { foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatform in Params.ClientTargetPlatforms) { CrashReportPlatforms.Add(ClientPlatform); Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Path.GetDirectoryName(Params.RawProjectPath) + "\""); } } } if (Params.HasServerCookedTargets) { foreach (var BuildConfig in Params.ServerConfigsToBuild) { foreach (var ServerPlatform in Params.ServerTargetPlatforms) { CrashReportPlatforms.Add(ServerPlatform); Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Path.GetDirectoryName(Params.RawProjectPath) + "\""); } } } if (Params.CrashReporter && !Params.Rocket) { var CrashReportClientTarget = new[] { "CrashReportClient" }; foreach (var CrashReportPlatform in CrashReportPlatforms) { if (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform)) { Agenda.AddTargets(CrashReportClientTarget, CrashReportPlatform, UnrealTargetConfiguration.Development); } } } if (Params.HasProgramTargets && !Params.Rocket) { foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatform in Params.ClientTargetPlatforms) { Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath); } } } UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0); if (WorkingCL > 0) // only move UAT files if we intend to check in some build products { UE4Build.AddUATFilesToBuildProducts(); } UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles); if (WorkingCL > 0) { // Sign everything we built CodeSign.SignMultipleIfEXEOrDLL(Command, UE4Build.BuildProductFiles); // Open files for add or edit UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles); } Log("********** BUILD COMMAND COMPLETED **********"); }
public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1, ProjectBuildTargets TargetMask = ProjectBuildTargets.All) { Params.ValidateAndLog(); if (!Params.Build) { return; } Log("********** BUILD COMMAND STARTED **********"); var UE4Build = new UE4Build(Command); var Agenda = new UE4Build.BuildAgenda(); var CrashReportPlatforms = new HashSet <UnrealTargetPlatform>(); // Setup editor targets if (Params.HasEditorTargets && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Editor) == ProjectBuildTargets.Editor) { // @todo Mac: proper platform detection UnrealTargetPlatform EditorPlatform = HostPlatform.Current.HostEditorPlatform; const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development; CrashReportPlatforms.Add(EditorPlatform); Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath); if (Params.EditorTargets.Contains("UnrealHeaderTool") == false) { Agenda.AddTargets(new string[] { "UnrealHeaderTool" }, EditorPlatform, EditorConfiguration); } if (Params.EditorTargets.Contains("ShaderCompileWorker") == false) { Agenda.AddTargets(new string[] { "ShaderCompileWorker" }, EditorPlatform, EditorConfiguration); } if (Params.Pak && Params.EditorTargets.Contains("UnrealPak") == false) { Agenda.AddTargets(new string[] { "UnrealPak" }, EditorPlatform, EditorConfiguration); } if (Params.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false) { Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration); } } string ScriptPluginArgs = ""; // if we're utilizing an auto-generated code plugin/module (a product of // the cook process), make sure to compile it along with the targets here if (Params.RunAssetNativization) { // Add every plugin: foreach (var CodePlugin in Params.BlueprintPluginPaths) { ScriptPluginArgs = "-PLUGIN \"" + CodePlugin + "\""; } } // Setup cooked targets if (Params.HasClientCookedTargets && (TargetMask & ProjectBuildTargets.ClientCooked) == ProjectBuildTargets.ClientCooked) { foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatform in Params.ClientTargetPlatforms) { CrashReportPlatforms.Add(ClientPlatform); Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: ScriptPluginArgs + " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\""); } } } if (Params.HasServerCookedTargets && (TargetMask & ProjectBuildTargets.ServerCooked) == ProjectBuildTargets.ServerCooked) { foreach (var BuildConfig in Params.ServerConfigsToBuild) { foreach (var ServerPlatform in Params.ServerTargetPlatforms) { CrashReportPlatforms.Add(ServerPlatform); Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: ScriptPluginArgs + " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\""); } } } if (!Params.NoBootstrapExe && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Bootstrap) == ProjectBuildTargets.Bootstrap) { UnrealBuildTool.UnrealTargetPlatform[] BootstrapPackagedGamePlatforms = { UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetPlatform.Win64 }; foreach (UnrealBuildTool.UnrealTargetPlatform BootstrapPackagedGamePlatform in BootstrapPackagedGamePlatforms) { if (Params.ClientTargetPlatforms.Contains(BootstrapPackagedGamePlatform)) { Agenda.AddTarget("BootstrapPackagedGame", BootstrapPackagedGamePlatform, UnrealBuildTool.UnrealTargetConfiguration.Shipping); } } } if (Params.CrashReporter && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.CrashReporter) == ProjectBuildTargets.CrashReporter) { foreach (var CrashReportPlatform in CrashReportPlatforms) { if (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform)) { Agenda.AddTarget("CrashReportClient", CrashReportPlatform, UnrealTargetConfiguration.Shipping); } } } if (Params.HasProgramTargets && (TargetMask & ProjectBuildTargets.Programs) == ProjectBuildTargets.Programs) { foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatform in Params.ClientTargetPlatforms) { Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath); } } } UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0); if (WorkingCL > 0) // only move UAT files if we intend to check in some build products { UE4Build.AddUATFilesToBuildProducts(); } UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles); if (WorkingCL > 0) { // Sign everything we built CodeSign.SignMultipleIfEXEOrDLL(Command, UE4Build.BuildProductFiles); // Open files for add or edit UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles); } Log("********** BUILD COMMAND COMPLETED **********"); }
public override ExitCode Execute() { string[] Arguments = this.Params; ProjectName = ParseParamValue("project", ProjectName); Targets = ParseParamValue("target", Targets); Platforms = ParseParamValue("platform", Platforms); Configurations = ParseParamValue("configuration", Configurations); Clean = ParseParam("clean") || Clean; if (string.IsNullOrEmpty(Targets)) { throw new AutomationException("No target specified with -target. Use -help to see all options"); } bool NoTools = ParseParam("notools"); IEnumerable <string> TargetList = Targets.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); IEnumerable <UnrealTargetConfiguration> ConfigurationList = null; IEnumerable <UnrealTargetPlatform> PlatformList = null; try { ConfigurationList = Configurations.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries) .Select(C => (UnrealTargetConfiguration)Enum.Parse(typeof(UnrealTargetConfiguration), C, true)).ToArray(); } catch (Exception Ex) { LogError("Failed to parse configuration string. {0}", Ex.Message); return(ExitCode.Error_Arguments); } try { PlatformList = Platforms.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries) .Select(C => { UnrealTargetPlatform Platform; if (!UnrealTargetPlatform.TryParse(C, out Platform)) { throw new AutomationException("No such platform {0}", C); } return(Platform); }).ToArray(); } catch (Exception Ex) { LogError("Failed to parse configuration string. {0}", Ex.Message); return(ExitCode.Error_Arguments); } FileReference ProjectFile = null; if (!string.IsNullOrEmpty(ProjectName)) { ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName); if (ProjectFile == null) { throw new AutomationException("Unable to find uproject file for {0}", ProjectName); } string SourceDirectoryName = Path.Combine(ProjectFile.Directory.FullName, "Source"); if (Directory.Exists(SourceDirectoryName)) { IEnumerable <string> TargetScripts = Directory.EnumerateFiles(SourceDirectoryName, "*.Target.cs"); foreach (string TargetName in TargetList) { string TargetScript = TargetScripts.Where(S => S.IndexOf(TargetName, StringComparison.OrdinalIgnoreCase) >= 0).FirstOrDefault(); if (TargetScript == null && ( TargetName.Equals("Client", StringComparison.OrdinalIgnoreCase) || TargetName.Equals("Game", StringComparison.OrdinalIgnoreCase) ) ) { // if there's no ProjectGame.Target.cs or ProjectClient.Target.cs then // fallback to Project.Target.cs TargetScript = TargetScripts.Where(S => S.IndexOf(ProjectName + ".", StringComparison.OrdinalIgnoreCase) >= 0).FirstOrDefault(); } if (TargetScript == null) { throw new AutomationException("No Target.cs file for target {0} in project {1}", TargetName, ProjectName); } string FullName = Path.GetFileName(TargetScript); TargetNames[TargetName] = Regex.Replace(FullName, ".Target.cs", "", RegexOptions.IgnoreCase); } } } else { Log.TraceWarning("No project specified, will build vanilla UE4 binaries"); } // Handle content-only projects or when no project was specified if (TargetNames.Keys.Count == 0) { foreach (string TargetName in TargetList) { TargetNames[TargetName] = string.Format("UE4{0}", TargetName); } } UE4Build Build = new UE4Build(this); UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); string EditorTarget = TargetList.Where(T => T.EndsWith("Editor", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); IEnumerable <string> OtherTargets = TargetList.Where(T => T != EditorTarget); UnrealTargetPlatform CurrentPlatform = HostPlatform.Current.HostEditorPlatform; if (!NoTools) { Agenda.AddTarget("UnrealHeaderTool", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile); } if (string.IsNullOrEmpty(EditorTarget) == false) { string TargetName = TargetNames[EditorTarget]; Agenda.AddTarget(TargetName, CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile); if (!NoTools) { Agenda.AddTarget("UnrealPak", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile); Agenda.AddTarget("ShaderCompileWorker", CurrentPlatform, UnrealTargetConfiguration.Development); Agenda.AddTarget("UnrealLightmass", CurrentPlatform, UnrealTargetConfiguration.Development); Agenda.AddTarget("CrashReportClient", CurrentPlatform, UnrealTargetConfiguration.Shipping); Agenda.AddTarget("CrashReportClientEditor", CurrentPlatform, UnrealTargetConfiguration.Shipping); } } foreach (string Target in OtherTargets) { string TargetName = TargetNames[Target]; bool IsServer = Target.EndsWith("Server", StringComparison.OrdinalIgnoreCase); IEnumerable <UnrealTargetPlatform> PlatformsToBuild = IsServer ? new UnrealTargetPlatform[] { CurrentPlatform } : PlatformList; foreach (UnrealTargetPlatform Platform in PlatformsToBuild) { foreach (UnrealTargetConfiguration Config in ConfigurationList) { Agenda.AddTarget(TargetName, Platform, Config); } } } // Set clean and log foreach (var Target in Agenda.Targets) { if (Clean) { Target.Clean = Clean; } Log.TraceInformation("Will {0}build {1}", Clean ? "clean and " : "", Target); } Build.Build(Agenda, InUpdateVersionFiles: false); return(ExitCode.Success); }
public override void ExecuteBuild() { // get the project var UProjectFileName = ParseParamValue("Project"); if (UProjectFileName == null) { throw new AutomationException("Project was not specified via the -project argument."); } // Get the list of targets var TargetList = ParseParamList("Target"); if (TargetList == null) { throw new AutomationException("Target was not specified via the -target argument."); } // get the list of platforms var PlatformList = ParseParamList("TargetPlatforms", "Win64"); List <UnrealTargetPlatform> TargetPlatforms = new List <UnrealTargetPlatform>(); foreach (string Platform in PlatformList) { TargetPlatforms.Add((UnrealTargetPlatform)Enum.Parse(typeof(UnrealTargetPlatform), Platform, true)); } // get the list configurations var ConfigList = ParseParamList("Config", "Development"); List <UnrealTargetConfiguration> ConfigsToBuild = new List <UnrealTargetConfiguration>(); foreach (string Config in ConfigList) { ConfigsToBuild.Add((UnrealTargetConfiguration)Enum.Parse(typeof(UnrealTargetConfiguration), Config, true)); } // parse any extra parameters bool bClean = ParseParam("Clean"); int WorkingCL = ParseParamInt("P4Change"); FileReference UProjectFileReference = new FileReference(UProjectFileName); // add the targets to the agenda // verify the targets and add them to the agenda var Properties = ProjectUtils.GetProjectProperties(UProjectFileReference); UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); foreach (string Target in TargetList) { SingleTargetProperties TargetData; if (!Properties.Targets.TryGetValue((TargetRules.TargetType)Enum.Parse(typeof(TargetRules.TargetType), Target), out TargetData)) { throw new AutomationException("Project does not support specified target: {0}", Target); } foreach (UnrealTargetPlatform TargetPlatform in TargetPlatforms) { if (TargetData.Rules.SupportsPlatform(TargetPlatform)) { List <UnrealTargetConfiguration> SupportedConfigurations = new List <UnrealTargetConfiguration>(); TargetData.Rules.GetSupportedConfigurations(ref SupportedConfigurations, true); foreach (UnrealTargetConfiguration TargetConfig in ConfigsToBuild) { if (SupportedConfigurations.Contains(TargetConfig)) { Agenda.AddTarget(TargetData.TargetName, TargetPlatform, TargetConfig, UProjectFileReference); } else { Log("{0} doesn't support the {1} configuration. It will not be built.", TargetData.TargetName, TargetConfig); } } } else { Log("{0} doesn't support the {1} platform. It will not be built.", TargetData.TargetName, TargetPlatform); } } } // build it UE4Build Build = new UE4Build(this); Build.Build(Agenda, InDeleteBuildProducts: bClean, InUpdateVersionFiles: WorkingCL > 0); if (WorkingCL > 0) // only move UAT files if we intend to check in some build products { Build.AddUATFilesToBuildProducts(); } UE4Build.CheckBuildProducts(Build.BuildProductFiles); if (WorkingCL > 0) { // Sign everything we built CodeSign.SignMultipleIfEXEOrDLL(this, Build.BuildProductFiles); // Open files for add or edit UE4Build.AddBuildProductsToChangelist(WorkingCL, Build.BuildProductFiles); } }
public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1, ProjectBuildTargets TargetMask = ProjectBuildTargets.All) { Params.ValidateAndLog(); if (!Params.Build) { return; } if (CommandUtils.IsEngineInstalled() && !Params.IsCodeBasedProject) { return; } LogInformation("********** BUILD COMMAND STARTED **********"); var UE4Build = new UE4Build(Command); var Agenda = new UE4Build.BuildAgenda(); var CrashReportPlatforms = new HashSet <UnrealTargetPlatform>(); // Setup editor targets if (Params.HasEditorTargets && (!Params.SkipBuildEditor) && (TargetMask & ProjectBuildTargets.Editor) == ProjectBuildTargets.Editor) { // @todo Mac: proper platform detection UnrealTargetPlatform EditorPlatform = HostPlatform.Current.HostEditorPlatform; const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development; Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath); if (!CommandUtils.IsEngineInstalled()) { CrashReportPlatforms.Add(EditorPlatform); if (Params.EditorTargets.Contains("UnrealHeaderTool") == false) { Agenda.AddTargets(new string[] { "UnrealHeaderTool" }, EditorPlatform, EditorConfiguration); } if (Params.EditorTargets.Contains("ShaderCompileWorker") == false) { Agenda.AddTargets(new string[] { "ShaderCompileWorker" }, EditorPlatform, EditorConfiguration); } if (Params.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false) { Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration); } } } // allow all involved platforms to hook into the agenda HashSet <UnrealTargetPlatform> UniquePlatforms = new HashSet <UnrealTargetPlatform>(); UniquePlatforms.UnionWith(Params.ClientTargetPlatforms.Select(x => x.Type)); UniquePlatforms.UnionWith(Params.ServerTargetPlatforms.Select(x => x.Type)); foreach (UnrealTargetPlatform TargetPlatform in UniquePlatforms) { Platform.GetPlatform(TargetPlatform).PreBuildAgenda(UE4Build, Agenda); } // Build any tools we need to stage if ((TargetMask & ProjectBuildTargets.UnrealPak) == ProjectBuildTargets.UnrealPak && !CommandUtils.IsEngineInstalled()) { if (Params.EditorTargets.Contains("UnrealPak") == false) { Agenda.AddTargets(new string[] { "UnrealPak" }, HostPlatform.Current.HostEditorPlatform, UnrealTargetConfiguration.Development, Params.CodeBasedUprojectPath); } } // Additional compile arguments string AdditionalArgs = ""; if (string.IsNullOrEmpty(Params.UbtArgs) == false) { string Arg = Params.UbtArgs; Arg = Arg.TrimStart(new char[] { '\"' }); Arg = Arg.TrimEnd(new char[] { '\"' }); AdditionalArgs += " " + Arg; } if (Params.MapFile) { AdditionalArgs += " -mapfile"; } if (Params.Deploy || Params.Package) { AdditionalArgs += " -skipdeploy"; // skip deploy step in UBT if we going to do it later anyway } if (Params.Distribution) { AdditionalArgs += " -distribution"; } // Config overrides (-ini) foreach (string ConfigOverrideParam in Params.ConfigOverrideParams) { AdditionalArgs += " -"; AdditionalArgs += ConfigOverrideParam; } // Setup cooked targets if (Params.HasClientCookedTargets && (!Params.SkipBuildClient) && (TargetMask & ProjectBuildTargets.ClientCooked) == ProjectBuildTargets.ClientCooked) { List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList(); foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatformType in UniquePlatformTypes) { CrashReportPlatforms.Add(ClientPlatformType); Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"" + AdditionalArgs); } } } if (Params.HasServerCookedTargets && (TargetMask & ProjectBuildTargets.ServerCooked) == ProjectBuildTargets.ServerCooked) { List <UnrealTargetPlatform> UniquePlatformTypes = Params.ServerTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList(); foreach (var BuildConfig in Params.ServerConfigsToBuild) { foreach (var ServerPlatformType in UniquePlatformTypes) { CrashReportPlatforms.Add(ServerPlatformType); Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"" + AdditionalArgs); } } } if (!Params.NoBootstrapExe && !CommandUtils.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Bootstrap) == ProjectBuildTargets.Bootstrap) { UnrealBuildTool.UnrealTargetPlatform[] BootstrapPackagedGamePlatforms = { UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetPlatform.Win64 }; foreach (UnrealBuildTool.UnrealTargetPlatform BootstrapPackagedGamePlatformType in BootstrapPackagedGamePlatforms) { if (Params.ClientTargetPlatforms.Contains(new TargetPlatformDescriptor(BootstrapPackagedGamePlatformType))) { Agenda.AddTarget("BootstrapPackagedGame", BootstrapPackagedGamePlatformType, UnrealBuildTool.UnrealTargetConfiguration.Shipping); } } } if (Params.CrashReporter && !CommandUtils.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.CrashReporter) == ProjectBuildTargets.CrashReporter) { foreach (var CrashReportPlatform in CrashReportPlatforms) { if (PlatformSupportsCrashReporter(CrashReportPlatform)) { Agenda.AddTarget("CrashReportClient", CrashReportPlatform, UnrealTargetConfiguration.Shipping, InAddArgs: " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\""); } } } if (Params.HasProgramTargets && (TargetMask & ProjectBuildTargets.Programs) == ProjectBuildTargets.Programs) { List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList(); foreach (var BuildConfig in Params.ClientConfigsToBuild) { foreach (var ClientPlatformType in UniquePlatformTypes) { Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath); } } } UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0); if (WorkingCL > 0) // only move UAT files if we intend to check in some build products { UE4Build.AddUATFilesToBuildProducts(); } UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles); if (WorkingCL > 0) { // Sign everything we built CodeSign.SignMultipleIfEXEOrDLL(Command, UE4Build.BuildProductFiles); // Open files for add or edit UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles); } LogInformation("********** BUILD COMMAND COMPLETED **********"); }
public override void ExecuteBuild() { // Parse the target list string[] Targets = ParseParamValues("Target"); if (Targets.Length == 0) { throw new AutomationException("No targets specified (eg. -Target=\"UE4Editor Win64 Development\")"); } // Parse the archive path string ArchivePath = ParseParamValue("Archive"); if (ArchivePath != null && (!ArchivePath.StartsWith("//") || ArchivePath.Sum(x => (x == '/')? 1 : 0) < 4)) { throw new AutomationException("Archive path is not a valid depot filename"); } // Prepare the build agenda UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); foreach (string Target in Targets) { string[] Tokens = Target.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); UnrealTargetPlatform Platform; UnrealTargetConfiguration Configuration; if (Tokens.Length < 3 || !Enum.TryParse(Tokens[1], true, out Platform) || !Enum.TryParse(Tokens[2], true, out Configuration)) { throw new AutomationException("Invalid target '{0}' - expected <TargetName> <Platform> <Configuration>"); } Agenda.AddTarget(Tokens[0], Platform, Configuration, InAddArgs: String.Join(" ", Tokens.Skip(3))); } // Build everything UE4Build Builder = new UE4Build(this); Builder.Build(Agenda, InUpdateVersionFiles: ArchivePath != null); // Include the build products for UAT and UBT if required if (ParseParam("WithUAT")) { Builder.AddUATFilesToBuildProducts(); } if (ParseParam("WithUBT")) { Builder.AddUBTFilesToBuildProducts(); } // Archive the build products if (ArchivePath != null) { // Create an output folder string OutputFolder = Path.Combine(CommandUtils.CmdEnv.LocalRoot, "ArchiveForUGS"); Directory.CreateDirectory(OutputFolder); // Create a temp folder for storing stripped PDB files string SymbolsFolder = Path.Combine(OutputFolder, "Symbols"); Directory.CreateDirectory(SymbolsFolder); // Get the Windows toolchain Platform WindowsTargetPlatform = Platform.GetPlatform(UnrealTargetPlatform.Win64); // Figure out all the files for the archive string ZipFileName = Path.Combine(OutputFolder, "Archive.zip"); using (Ionic.Zip.ZipFile Zip = new Ionic.Zip.ZipFile()) { Zip.UseZip64WhenSaving = Ionic.Zip.Zip64Option.Always; foreach (string BuildProduct in Builder.BuildProductFiles) { if (!File.Exists(BuildProduct)) { throw new AutomationException("Missing build product: {0}", BuildProduct); } if (BuildProduct.EndsWith(".pdb", StringComparison.InvariantCultureIgnoreCase)) { string StrippedFileName = CommandUtils.MakeRerootedFilePath(BuildProduct, CommandUtils.CmdEnv.LocalRoot, SymbolsFolder); Directory.CreateDirectory(Path.GetDirectoryName(StrippedFileName)); WindowsTargetPlatform.StripSymbols(new FileReference(BuildProduct), new FileReference(StrippedFileName)); Zip.AddFile(StrippedFileName, Path.GetDirectoryName(CommandUtils.StripBaseDirectory(StrippedFileName, SymbolsFolder))); } else { Zip.AddFile(BuildProduct, Path.GetDirectoryName(CommandUtils.StripBaseDirectory(BuildProduct, CommandUtils.CmdEnv.LocalRoot))); } } // Create the zip file Console.WriteLine("Writing {0}...", ZipFileName); Zip.Save(ZipFileName); } // Submit it to Perforce if required if (CommandUtils.AllowSubmit) { // Delete any existing clientspec for submitting string ClientName = Environment.MachineName + "_BuildForUGS"; // Create a brand new one P4ClientInfo Client = new P4ClientInfo(); Client.Owner = CommandUtils.P4Env.User; Client.Host = Environment.MachineName; Client.Stream = ArchivePath.Substring(0, ArchivePath.IndexOf('/', ArchivePath.IndexOf('/', 2) + 1)); Client.RootPath = Path.Combine(OutputFolder, "Perforce"); Client.Name = ClientName; Client.Options = P4ClientOption.NoAllWrite | P4ClientOption.NoClobber | P4ClientOption.NoCompress | P4ClientOption.Unlocked | P4ClientOption.NoModTime | P4ClientOption.RmDir; Client.LineEnd = P4LineEnd.Local; P4.CreateClient(Client, AllowSpew: false); // Create a new P4 connection for this workspace P4Connection SubmitP4 = new P4Connection(Client.Owner, Client.Name, P4Env.ServerAndPort); SubmitP4.Revert("-k //..."); // Figure out where the zip file has to go in Perforce P4WhereRecord WhereZipFile = SubmitP4.Where(ArchivePath, false).FirstOrDefault(x => !x.bUnmap && x.Path != null); if (WhereZipFile == null) { throw new AutomationException("Couldn't locate {0} in this workspace"); } // Get the latest version of it int NewCL = SubmitP4.CreateChange(Description: String.Format("[CL {0}] Updated binaries", P4Env.Changelist)); SubmitP4.Sync(String.Format("-k \"{0}\"", ArchivePath), AllowSpew: false); CommandUtils.CopyFile(ZipFileName, WhereZipFile.Path); SubmitP4.Add(NewCL, String.Format("\"{0}\"", ArchivePath)); SubmitP4.Edit(NewCL, String.Format("\"{0}\"", ArchivePath)); // Submit it int SubmittedCL; SubmitP4.Submit(NewCL, out SubmittedCL); if (SubmittedCL <= 0) { throw new AutomationException("Submit failed."); } Console.WriteLine("Submitted in changelist {0}", SubmittedCL); } } }
public override void ExecuteBuild() { // Get the plugin filename string PluginFileName = ParseParamValue("Plugin"); if (PluginFileName == null) { throw new AutomationException("Plugin file name was not specified via the -plugin argument"); } // Read the plugin PluginDescriptor Plugin = PluginDescriptor.FromFile(PluginFileName); // Clean the intermediate build directory string IntermediateBuildDirectory = Path.Combine(Path.GetDirectoryName(PluginFileName), "Intermediate", "Build"); if (CommandUtils.DirectoryExists(IntermediateBuildDirectory)) { CommandUtils.DeleteDirectory(IntermediateBuildDirectory); } // Get any additional arguments from the commandline string AdditionalArgs = ""; if (ParseParam("Rocket")) { AdditionalArgs += " -Rocket"; } // Build the host platforms List <string> ReceiptFileNames = new List <string>(); UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); UnrealTargetPlatform HostPlatform = BuildHostPlatform.Current.Platform; if (!ParseParam("NoHostPlatform")) { AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Editor", TargetRules.TargetType.Editor, HostPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs); } // Add the game targets List <UnrealTargetPlatform> TargetPlatforms = Rocket.RocketBuild.GetTargetPlatforms(this, HostPlatform); foreach (UnrealTargetPlatform TargetPlatform in TargetPlatforms) { if (Rocket.RocketBuild.IsCodeTargetPlatform(HostPlatform, TargetPlatform)) { AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs); AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Shipping, ReceiptFileNames, AdditionalArgs); } } // Build it UE4Build Build = new UE4Build(this); Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: false); // Package the plugin to the output folder string PackageDirectory = ParseParamValue("Package"); if (PackageDirectory != null) { List <BuildProduct> BuildProducts = GetBuildProductsFromReceipts(ReceiptFileNames); PackagePlugin(PluginFileName, BuildProducts, PackageDirectory); } }
public override ExitCode Execute() { string[] Arguments = this.Params; ProjectName = ParseParamValue("project", ProjectName); Targets = ParseParamValue("target", Targets); Platforms = ParseParamValue("platform", Platforms); Configurations = ParseParamValue("configuration", Configurations); Clean = ParseParam("clean") || Clean; NoTools = ParseParam("NoTools") || NoTools; UBTArgs = ParseParamValue("ubtargs", UBTArgs); Preview = ParseParam("preview") || Preview; if (string.IsNullOrEmpty(Targets)) { throw new AutomationException("No target specified with -target. Use -help to see all options"); } IEnumerable <string> TargetList = Targets.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); IEnumerable <UnrealTargetConfiguration> ConfigurationList = null; IEnumerable <UnrealTargetPlatform> PlatformList = null; try { ConfigurationList = Configurations.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries) .Select(C => (UnrealTargetConfiguration)Enum.Parse(typeof(UnrealTargetConfiguration), C, true)).ToArray(); } catch (Exception Ex) { LogError("Failed to parse configuration string. {0}", Ex.Message); return(ExitCode.Error_Arguments); } try { PlatformList = Platforms.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries) .Select(C => { UnrealTargetPlatform Platform; if (!UnrealTargetPlatform.TryParse(C, out Platform)) { throw new AutomationException("No such platform {0}", C); } return(Platform); }).ToArray(); } catch (Exception Ex) { LogError("Failed to parse configuration string. {0}", Ex.Message); return(ExitCode.Error_Arguments); } FileReference ProjectFile = null; if (!string.IsNullOrEmpty(ProjectName)) { // find the project ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName); if (ProjectFile == null) { throw new AutomationException("Unable to find uproject file for {0}", ProjectName); } } IEnumerable <string> BuildTargets = TargetList.Select(T => ProjectTargetFromTarget(T, ProjectFile)).ToArray(); bool ContainsEditor = BuildTargets.Where(T => T.EndsWith("Editor", StringComparison.OrdinalIgnoreCase)).Any(); bool SingleBuild = BuildTargets.Count() == 1 && PlatformList.Count() == 1 && ConfigurationList.Count() == 1; if (!SingleBuild || (ContainsEditor && !NoTools)) { UE4Build Build = new UE4Build(this); Build.AlwaysBuildUHT = true; UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); string EditorTarget = BuildTargets.Where(T => T.EndsWith("Editor", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); IEnumerable <string> OtherTargets = BuildTargets.Where(T => T != EditorTarget); UnrealTargetPlatform CurrentPlatform = HostPlatform.Current.HostEditorPlatform; if (string.IsNullOrEmpty(EditorTarget) == false) { Agenda.AddTarget(EditorTarget, CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs); if (!NoTools) { Agenda.AddTarget("UnrealPak", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs); Agenda.AddTarget("ShaderCompileWorker", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs); Agenda.AddTarget("UnrealLightmass", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs); Agenda.AddTarget("CrashReportClient", CurrentPlatform, UnrealTargetConfiguration.Shipping, ProjectFile, UBTArgs); Agenda.AddTarget("CrashReportClientEditor", CurrentPlatform, UnrealTargetConfiguration.Shipping, ProjectFile, UBTArgs); } } foreach (string Target in OtherTargets) { bool IsServer = Target.EndsWith("Server", StringComparison.OrdinalIgnoreCase); IEnumerable <UnrealTargetPlatform> PlatformsToBuild = IsServer ? new UnrealTargetPlatform[] { CurrentPlatform } : PlatformList; foreach (UnrealTargetPlatform Platform in PlatformsToBuild) { foreach (UnrealTargetConfiguration Config in ConfigurationList) { Agenda.AddTarget(Target, Platform, Config, ProjectFile, UBTArgs); } } } foreach (var Target in Agenda.Targets) { Log.TraceInformation("Will {0}build {1}", Clean ? "clean and " : "", Target); if (Clean) { Target.Clean = Clean; } } if (!Preview) { Build.Build(Agenda, InUpdateVersionFiles: false); } } else { // Get the path to UBT FileReference InstalledUBT = FileReference.Combine(CommandUtils.EngineDirectory, "Binaries", "DotNET", "UnrealBuildTool.exe"); UnrealTargetPlatform PlatformToBuild = PlatformList.First(); UnrealTargetConfiguration ConfigToBuild = ConfigurationList.First(); string TargetToBuild = BuildTargets.First(); if (!Preview) { // Compile the editor string CommandLine = CommandUtils.UBTCommandline(ProjectFile, TargetToBuild, PlatformToBuild, ConfigToBuild, UBTArgs); if (Clean) { CommandUtils.RunUBT(CommandUtils.CmdEnv, InstalledUBT.FullName, CommandLine + " -clean"); } CommandUtils.RunUBT(CommandUtils.CmdEnv, InstalledUBT.FullName, CommandLine); } else { Log.TraceInformation("Will {0}build {1} {2} {3}", Clean ? "clean and " : "", TargetToBuild, PlatformToBuild, ConfigToBuild); } } return(ExitCode.Success); }