public static void Cook(ProjectParams Params) { if ((!Params.Cook && !(Params.CookOnTheFly && !Params.SkipServer)) || Params.SkipCook) { return; } Params.ValidateAndLog(); Log("********** COOK COMMAND STARTED **********"); string UE4EditorExe = HostPlatform.Current.GetUE4ExePath(Params.UE4Exe); if (!FileExists(UE4EditorExe)) { throw new AutomationException("Missing " + UE4EditorExe + " executable. Needs to be built first."); } if (Params.CookOnTheFly && !Params.SkipServer) { if (Params.HasDLCName) { throw new AutomationException("Cook on the fly doesn't support cooking dlc"); } if (Params.ClientTargetPlatforms.Count > 0) { var LogFolderOutsideOfSandbox = GetLogFolderOutsideOfSandbox(); if (!GlobalCommandLine.Installed) { // In the installed runs, this is the same folder as CmdEnv.LogFolder so delete only in not-installed DeleteDirectory(LogFolderOutsideOfSandbox); CreateDirectory(LogFolderOutsideOfSandbox); } String COTFCommandLine = Params.RunCommandline; if (Params.IterativeCooking) { COTFCommandLine += " -iterate -iteratehash"; } if (Params.UseDebugParamForEditorExe) { COTFCommandLine += " -debug"; } var ServerLogFile = CombinePaths(LogFolderOutsideOfSandbox, "Server.log"); Platform ClientPlatformInst = Params.ClientTargetPlatformInstances[0]; string TargetCook = ClientPlatformInst.GetCookPlatform(false, false); // cook on he fly doesn't support server cook platform... ServerProcess = RunCookOnTheFlyServer(Params.RawProjectPath, Params.NoClient ? "" : ServerLogFile, TargetCook, COTFCommandLine); if (ServerProcess != null) { Log("Waiting a few seconds for the server to start..."); Thread.Sleep(5000); } } else { throw new AutomationException("Failed to run, client target platform not specified"); } } else { string NativizedPluginPath = ""; var PlatformsToCook = new HashSet <string>(); if (!Params.NoClient) { foreach (var ClientPlatform in Params.ClientTargetPlatforms) { // Use the data platform, sometimes we will copy another platform's data var DataPlatformDesc = Params.GetCookedDataPlatformForClientTarget(ClientPlatform); string PlatformToCook = Platform.Platforms[DataPlatformDesc].GetCookPlatform(false, Params.Client); PlatformsToCook.Add(PlatformToCook); NativizedPluginPath = AddBlueprintPluginPathArgument(Params, true, DataPlatformDesc.Type, PlatformToCook); } } if (Params.DedicatedServer) { foreach (var ServerPlatform in Params.ServerTargetPlatforms) { // Use the data platform, sometimes we will copy another platform's data var DataPlatformDesc = Params.GetCookedDataPlatformForServerTarget(ServerPlatform); string PlatformToCook = Platform.Platforms[DataPlatformDesc].GetCookPlatform(true, false); PlatformsToCook.Add(PlatformToCook); NativizedPluginPath = AddBlueprintPluginPathArgument(Params, false, DataPlatformDesc.Type, PlatformToCook); } } if (Params.Clean.HasValue && Params.Clean.Value && !Params.IterativeCooking) { Log("Cleaning cooked data."); CleanupCookedData(PlatformsToCook.ToList(), Params); } // cook the set of maps, or the run map, or nothing string[] Maps = null; if (Params.HasMapsToCook) { Maps = Params.MapsToCook.ToArray(); foreach (var M in Maps) { Log("HasMapsToCook " + M.ToString()); } foreach (var M in Params.MapsToCook) { Log("Params.HasMapsToCook " + M.ToString()); } } string[] Dirs = null; if (Params.HasDirectoriesToCook) { Dirs = Params.DirectoriesToCook.ToArray(); } string InternationalizationPreset = null; if (Params.HasInternationalizationPreset) { InternationalizationPreset = Params.InternationalizationPreset; } string[] CulturesToCook = null; if (Params.HasCulturesToCook) { CulturesToCook = Params.CulturesToCook.ToArray(); } try { var CommandletParams = IsBuildMachine ? "-buildmachine -fileopenlog" : "-fileopenlog"; if (Params.UnversionedCookedContent) { CommandletParams += " -unversioned"; } if (Params.FastCook) { CommandletParams += " -FastCook"; } if (Params.UseDebugParamForEditorExe) { CommandletParams += " -debug"; } if (Params.Manifests) { CommandletParams += " -manifests"; } if (Params.IterativeCooking) { CommandletParams += " -iterate -iterateshash"; } if (Params.IterateSharedCookedBuild) { SharedCookedBuild.CopySharedCookedBuild(Params); CommandletParams += " -iteratesharedcookedbuild"; } if (Params.CookMapsOnly) { CommandletParams += " -mapsonly"; } if (Params.CookAll) { CommandletParams += " -cookall"; } if (Params.HasCreateReleaseVersion) { CommandletParams += " -createreleaseversion=" + Params.CreateReleaseVersion; } if (Params.SkipCookingEditorContent) { CommandletParams += " -skipeditorcontent"; } if (Params.NumCookersToSpawn != 0) { CommandletParams += " -numcookerstospawn=" + Params.NumCookersToSpawn; } if (Params.CookPartialGC) { CommandletParams += " -partialgc"; } if (Params.HasMapIniSectionsToCook) { string MapIniSections = CombineCommandletParams(Params.MapIniSectionsToCook.ToArray()); CommandletParams += " -MapIniSection=" + MapIniSections; } if (Params.HasDLCName) { CommandletParams += " -dlcname=" + Params.DLCFile.GetFileNameWithoutExtension(); if (!Params.DLCIncludeEngineContent) { CommandletParams += " -errorOnEngineContentUse"; } } if (!String.IsNullOrEmpty(Params.CookOutputDir)) { CommandletParams += " -outputdir=" + CommandUtils.MakePathSafeToUseWithCommandLine(Params.CookOutputDir); } // don't include the based on release version unless we are cooking dlc or creating a new release version // in this case the based on release version is used in packaging if (Params.HasBasedOnReleaseVersion && (Params.HasDLCName || Params.HasCreateReleaseVersion)) { CommandletParams += " -basedonreleaseversion=" + Params.BasedOnReleaseVersion; } // if we are not going to pak but we specified compressed then compress in the cooker ;) // otherwise compress the pak files if (!Params.Pak && !Params.SkipPak && Params.Compressed) { CommandletParams += " -compressed"; } // we provide the option for users to run a conversion on certain (script) assets, translating them // into native source code... the cooker needs to if (Params.RunAssetNativization) { CommandletParams += " -NativizeAssets"; if (NativizedPluginPath.Length > 0) { CommandletParams += "=\"" + NativizedPluginPath + "\""; } } if (Params.HasAdditionalCookerOptions) { string FormatedAdditionalCookerParams = Params.AdditionalCookerOptions.TrimStart(new char[] { '\"', ' ' }).TrimEnd(new char[] { '\"', ' ' }); CommandletParams += " "; CommandletParams += FormatedAdditionalCookerParams; } if (!Params.NoClient) { var MapsList = Maps == null ? new List <string>() : Maps.ToList(); foreach (var ClientPlatform in Params.ClientTargetPlatforms) { var DataPlatformDesc = Params.GetCookedDataPlatformForClientTarget(ClientPlatform); CommandletParams += (Platform.Platforms[DataPlatformDesc].GetCookExtraCommandLine(Params)); MapsList.AddRange((Platform.Platforms[ClientPlatform].GetCookExtraMaps())); } Maps = MapsList.ToArray(); } CookCommandlet(Params.RawProjectPath, Params.UE4Exe, Maps, Dirs, InternationalizationPreset, CulturesToCook, CombineCommandletParams(PlatformsToCook.ToArray()), CommandletParams); SharedCookedBuild.WaitForCopy(); } catch (Exception Ex) { if (Params.IgnoreCookErrors) { LogWarning("Ignoring cook failure."); } else { // Delete cooked data (if any) as it may be incomplete / corrupted. Log("Cook failed. Deleting cooked data."); CleanupCookedData(PlatformsToCook.ToList(), Params); throw new AutomationException(ExitCode.Error_UnknownCookFailure, Ex, "Cook failed."); } } if (Params.HasDiffCookedContentPath) { try { DiffCookedContent(Params); } catch (Exception Ex) { // Delete cooked data (if any) as it may be incomplete / corrupted. Log("Cook failed. Deleting cooked data."); CleanupCookedData(PlatformsToCook.ToList(), Params); throw new AutomationException(ExitCode.Error_UnknownCookFailure, Ex, "Cook failed."); } } } Log("********** COOK COMMAND COMPLETED **********"); }
public override void ExecuteBuild() { LogInformation("************************* CopySharedCookedBuild"); // Parse the project filename (as a local path) string CmdLinePlatform = ParseParamValue("Platform", null); bool bOnlyCopyAssetRegistry = ParseParam("onlycopyassetregistry"); string SharedBuildCL = ParseParamValue("buildcl", "usesyncedbuild"); List <UnrealTargetPlatform> TargetPlatforms = new List <UnrealTargetPlatform>(); var PlatformNames = new List <string>(CmdLinePlatform.Split('+')); foreach (var PlatformName in PlatformNames) { // Look for dependent platforms, Source_1.Dependent_1+Source_2.Dependent_2+Standalone_3 var SubPlatformNames = new List <string>(PlatformName.Split('.')); foreach (var SubPlatformName in SubPlatformNames) { UnrealTargetPlatform NewPlatformType = (UnrealTargetPlatform)Enum.Parse(typeof(UnrealTargetPlatform), SubPlatformName, true); TargetPlatforms.Add(NewPlatformType); } } foreach (var PlatformType in TargetPlatforms) { SharedCookedBuild.CopySharedCookedBuildForTarget(ProjectFile.FullName, PlatformType, PlatformType.ToString(), SharedBuildCL, bOnlyCopyAssetRegistry); SharedCookedBuild.WaitForCopy(); } /* * // Build the list of paths that need syncing * List<string> SyncPaths = new List<string>(); * if(bIsProjectFile) * { * SyncPaths.Add(CommandUtils.CombinePaths(PathSeparator.Slash, BranchRoot, "*")); * SyncPaths.Add(CommandUtils.CombinePaths(PathSeparator.Slash, BranchRoot, "Engine", "...")); * SyncPaths.Add(CommandUtils.CombinePaths(PathSeparator.Slash, CommandUtils.GetDirectoryName(ProjectFileRecord.DepotFile), "...")); * } * else * { * SyncPaths.Add(CommandUtils.CombinePaths(PathSeparator.Slash, CommandUtils.GetDirectoryName(ProjectFileRecord.DepotFile), "...")); * } * * // Sync them down * foreach(string SyncPath in SyncPaths) * { * Log("Syncing {0}@{1}", SyncPath, CL); * P4.Sync(String.Format("{0}@{1}", SyncPath, CL)); * } * * // Get the name of the editor target * string EditorTargetName = "UE4Editor"; * if(bIsProjectFile) * { * string SourceDirectoryName = Path.Combine(Path.GetDirectoryName(ProjectFileName), "Source"); * if(Directory.Exists(SourceDirectoryName)) * { * foreach(string EditorTargetFileName in Directory.EnumerateFiles(SourceDirectoryName, "*Editor.Target.cs")) * { * EditorTargetName = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(EditorTargetFileName)); * break; * } * } * } * * // Build everything * UnrealTargetPlatform CurrentPlatform = HostPlatform.Current.HostEditorPlatform; * * UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); * Agenda.AddTarget("UnrealHeaderTool", CurrentPlatform, UnrealTargetConfiguration.Development); * Agenda.AddTarget(EditorTargetName, CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFileName.EndsWith(".uproject", StringComparison.InvariantCultureIgnoreCase)? new FileReference(ProjectFileName) : null); * Agenda.AddTarget("ShaderCompileWorker", CurrentPlatform, UnrealTargetConfiguration.Development); * Agenda.AddTarget("UnrealLightmass", CurrentPlatform, UnrealTargetConfiguration.Development); * Agenda.AddTarget("CrashReportClient", CurrentPlatform, UnrealTargetConfiguration.Shipping); * * UE4Build Build = new UE4Build(this); * Build.UpdateVersionFiles(ActuallyUpdateVersionFiles: true, ChangelistNumberOverride: CL); * Build.Build(Agenda, InUpdateVersionFiles: false);*/ }