Пример #1
0
 public static void CopySharedCookedBuild(ProjectParams Params)
 {
     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);
             CopySharedCookedBuildForTarget(Params.RawProjectPath.FullName, ClientPlatform.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);
             CopySharedCookedBuildForTarget(Params.RawProjectPath.FullName, ServerPlatform.Type, PlatformToCook);
         }
     }
 }
    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 **********");
    }
    //@todo move this
    public static List <DeploymentContext> CreateDeploymentContext(ProjectParams Params, bool InDedicatedServer, bool DoCleanStage = false)
    {
        ParamList <string> ListToProcess = InDedicatedServer && (Params.Cook || Params.CookOnTheFly) ? Params.ServerCookedTargets : Params.ClientCookedTargets;
        var ConfigsToProcess             = InDedicatedServer && (Params.Cook || Params.CookOnTheFly) ? Params.ServerConfigsToBuild : Params.ClientConfigsToBuild;

        List <UnrealTargetPlatform> PlatformsToStage = Params.ClientTargetPlatforms;

        if (InDedicatedServer && (Params.Cook || Params.CookOnTheFly))
        {
            PlatformsToStage = Params.ServerTargetPlatforms;
        }

        bool prefixArchiveDir = false;

        if (PlatformsToStage.Contains(UnrealTargetPlatform.Win32) && PlatformsToStage.Contains(UnrealTargetPlatform.Win64))
        {
            prefixArchiveDir = true;
        }

        List <DeploymentContext> DeploymentContexts = new List <DeploymentContext>();

        foreach (var StagePlatform in PlatformsToStage)
        {
            // Get the platform to get cooked data from, may differ from the stage platform
            UnrealTargetPlatform CookedDataPlatform = Params.GetCookedDataPlatformForClientTarget(StagePlatform);

            if (InDedicatedServer && (Params.Cook || Params.CookOnTheFly))
            {
                CookedDataPlatform = Params.GetCookedDataPlatformForServerTarget(StagePlatform);
            }

            List <string> ExecutablesToStage = new List <string>();

            string PlatformName = StagePlatform.ToString();
            foreach (var Target in ListToProcess)
            {
                foreach (var Config in ConfigsToProcess)
                {
                    string Exe = Target;
                    if (Config != UnrealTargetConfiguration.Development)
                    {
                        Exe = Target + "-" + PlatformName + "-" + Config.ToString();
                    }
                    ExecutablesToStage.Add(Exe);
                }
            }

            string StageDirectory   = (Params.Stage || !String.IsNullOrEmpty(Params.StageDirectoryParam)) ? Params.BaseStageDirectory : "";
            string ArchiveDirectory = (Params.Archive || !String.IsNullOrEmpty(Params.ArchiveDirectoryParam)) ? Params.BaseArchiveDirectory : "";
            if (prefixArchiveDir && (StagePlatform == UnrealTargetPlatform.Win32 || StagePlatform == UnrealTargetPlatform.Win64))
            {
                if (Params.Stage)
                {
                    StageDirectory = CombinePaths(Params.BaseStageDirectory, StagePlatform.ToString());
                }
                if (Params.Archive)
                {
                    ArchiveDirectory = CombinePaths(Params.BaseArchiveDirectory, StagePlatform.ToString());
                }
            }

            //@todo should pull StageExecutables from somewhere else if not cooked
            var SC = new DeploymentContext(Params.RawProjectPath, CmdEnv.LocalRoot,
                                           StageDirectory,
                                           ArchiveDirectory,
                                           Params.CookFlavor,
                                           Params.GetTargetPlatformInstance(CookedDataPlatform),
                                           Params.GetTargetPlatformInstance(StagePlatform),
                                           ConfigsToProcess,
                                           ExecutablesToStage,
                                           InDedicatedServer,
                                           Params.Cook || Params.CookOnTheFly,
                                           Params.CrashReporter && (StagePlatform != UnrealTargetPlatform.Linux || !Params.Rocket),
                                           Params.Stage,
                                           Params.CookOnTheFly,
                                           Params.Archive,
                                           Params.IsProgramTarget,
                                           Params.HasDedicatedServerAndClient
                                           );
            LogDeploymentContext(SC);

            // If we're a derived platform make sure we're at the end, otherwise make sure we're at the front

            if (CookedDataPlatform != StagePlatform)
            {
                DeploymentContexts.Add(SC);
            }
            else
            {
                DeploymentContexts.Insert(0, SC);
            }
        }

        return(DeploymentContexts);
    }
    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);
                }
                var      ServerLogFile      = CombinePaths(LogFolderOutsideOfSandbox, "Server.log");
                Platform ClientPlatformInst = Params.ClientTargetPlatformInstances[0];
                string   TargetCook         = ClientPlatformInst.GetCookPlatform(false, Params.HasDedicatedServerAndClient, Params.CookFlavor);
                ServerProcess = RunCookOnTheFlyServer(Params.RawProjectPath, Params.NoClient ? "" : ServerLogFile, TargetCook, Params.RunCommandline);

                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
        {
            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 DataPlatform = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
                    PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(false, Params.HasDedicatedServerAndClient, Params.CookFlavor));
                }
            }
            if (Params.DedicatedServer)
            {
                foreach (var ServerPlatform in Params.ServerTargetPlatforms)
                {
                    // Use the data platform, sometimes we will copy another platform's data
                    var DataPlatform = Params.GetCookedDataPlatformForServerTarget(ServerPlatform);
                    PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(true, false, Params.CookFlavor));
                }
            }

            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[] Cultures = null;
            if (Params.HasCulturesToCook)
            {
                Cultures = Params.CulturesToCook.ToArray();
            }

            try
            {
                var CommandletParams = "-buildmachine -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";
                }
                if (Params.CookMapsOnly)
                {
                    CommandletParams += " -mapsonly";
                }
                if (Params.NewCook)
                {
                    CommandletParams += " -newcook";
                }
                if (Params.OldCook)
                {
                    CommandletParams += " -oldcook";
                }
                if (Params.CookAll)
                {
                    CommandletParams += " -cookall";
                }
                if (Params.CookMapsOnly)
                {
                    CommandletParams += " -mapsonly";
                }
                if (Params.HasCreateReleaseVersion)
                {
                    CommandletParams += " -createreleaseversion=" + Params.CreateReleaseVersion;
                }
                if (Params.HasDLCName)
                {
                    CommandletParams += " -dlcname=" + Params.DLCName;
                    if (!Params.DLCIncludeEngineContent)
                    {
                        CommandletParams += " -errorOnEngineContentUse";
                    }
                }
                // 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";
                }
                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 DataPlatform = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
                        CommandletParams += (Params.GetTargetPlatformInstance(DataPlatform).GetCookExtraCommandLine(Params));
                        MapsList.AddRange((Params.GetTargetPlatformInstance(ClientPlatform).GetCookExtraMaps()));
                    }
                    Maps = MapsList.ToArray();
                }

                CookCommandlet(Params.RawProjectPath, Params.UE4Exe, Maps, Dirs, InternationalizationPreset, Cultures, CombineCommandletParams(PlatformsToCook.ToArray()), CommandletParams);
            }
            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);
                    AutomationTool.ErrorReporter.Error("Cook failed.", (int)AutomationTool.ErrorCodes.Error_UnknownCookFailure);
                    throw Ex;
                }
            }
        }

        Log("********** COOK COMMAND COMPLETED **********");
    }
Пример #5
0
    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.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);
                }
                var      ServerLogFile      = CombinePaths(LogFolderOutsideOfSandbox, "Server.log");
                Platform ClientPlatformInst = Params.ClientTargetPlatformInstances[0];
                string   TargetCook         = ClientPlatformInst.GetCookPlatform(false, Params.HasDedicatedServerAndClient, Params.CookFlavor);
                ServerProcess = RunCookOnTheFlyServer(Params.RawProjectPath, Params.NoClient ? "" : ServerLogFile, TargetCook, Params.RunCommandline);

                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
        {
            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 DataPlatform = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
                    PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(false, Params.HasDedicatedServerAndClient, Params.CookFlavor));
                }
            }
            if (Params.DedicatedServer)
            {
                foreach (var ServerPlatform in Params.ServerTargetPlatforms)
                {
                    // Use the data platform, sometimes we will copy another platform's data
                    var DataPlatform = Params.GetCookedDataPlatformForServerTarget(ServerPlatform);
                    PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(true, false, Params.CookFlavor));
                }
            }

            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();
            }

            string[] Dirs = null;
            if (Params.HasDirectoriesToCook)
            {
                Dirs = Params.DirectoriesToCook.ToArray();
            }

            string InternationalizationPreset = null;
            if (Params.HasInternationalizationPreset)
            {
                InternationalizationPreset = Params.InternationalizationPreset;
            }

            string[] Cultures = null;
            if (Params.HasCulturesToCook)
            {
                Cultures = Params.CulturesToCook.ToArray();
            }

            try
            {
                var CommandletParams = "-buildmachine -Unversioned -fileopenlog";
                if (Params.UseDebugParamForEditorExe)
                {
                    CommandletParams += " -debug";
                }
                if (Params.Manifests)
                {
                    CommandletParams += " -manifests";
                }
                if (Params.IterativeCooking)
                {
                    CommandletParams += " -iterate";
                }
                CookCommandlet(Params.RawProjectPath, Params.UE4Exe, Maps, Dirs, InternationalizationPreset, Cultures, CombineCommandletParams(PlatformsToCook.ToArray()), CommandletParams);
            }
            catch (Exception Ex)
            {
                // Delete cooked data (if any) as it may be incomplete / corrupted.
                Log("Cook failed. Deleting cooked data.");
                CleanupCookedData(PlatformsToCook.ToList(), Params);
                AutomationTool.ErrorReporter.Error("Cook failed.", (int)AutomationTool.ErrorCodes.Error_UnknownCookFailure);
                throw Ex;
            }
        }

        Log("********** COOK COMMAND COMPLETED **********");
    }
Пример #6
0
    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";
                }
                if (Params.UseDebugParamForEditorExe)
                {
                    COTFCommandLine += " -debug";
                }

                var      ServerLogFile      = CombinePaths(LogFolderOutsideOfSandbox, "Server.log");
                Platform ClientPlatformInst = Params.ClientTargetPlatformInstances[0];
                string   TargetCook         = ClientPlatformInst.GetCookPlatform(false, false, Params.CookFlavor);       // cook ont 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
        {
            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 DataPlatform = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
                    PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(false, Params.Client, Params.CookFlavor));
                }
            }
            if (Params.DedicatedServer)
            {
                foreach (var ServerPlatform in Params.ServerTargetPlatforms)
                {
                    // Use the data platform, sometimes we will copy another platform's data
                    var DataPlatform = Params.GetCookedDataPlatformForServerTarget(ServerPlatform);
                    PlatformsToCook.Add(Params.GetTargetPlatformInstance(DataPlatform).GetCookPlatform(true, false, Params.CookFlavor));
                }
            }

            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";
                }
                if (Params.CookMapsOnly)
                {
                    CommandletParams += " -mapsonly";
                }
                if (Params.NewCook)
                {
                    CommandletParams += " -newcook";
                }
                if (Params.OldCook)
                {
                    CommandletParams += " -oldcook";
                }
                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.HasDLCName)
                {
                    CommandletParams += " -dlcname=" + Params.DLCName;
                    if (!Params.DLCIncludeEngineContent)
                    {
                        CommandletParams += " -errorOnEngineContentUse";
                    }
                }
                // 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";

                    // Store plugin paths now, it's easiest to do so while PlatformsToCook is still available:
                    string ProjectDir = Params.RawProjectPath.Directory.ToString();
                    foreach (var Platform in PlatformsToCook)
                    {
                        // If you change this target path you must also update logic in CookOnTheFlyServer.cpp. Passing a single directory around is cumbersome for testing, so I have hard coded it.
                        // Similarly if you change the .uplugin name you must update DefaultPluginName in BlueprintNativeCodeGenModule.cpp
                        string GeneratedPluginPath = CombinePaths(GetDirectoryName(ProjectDir), "Intermediate", Platform, "NativizedAssets/NativizedAssets.uplugin");
                        Params.BlueprintPluginPaths.Add(new FileReference(GeneratedPluginPath));
                    }
                }
                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 DataPlatform = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
                        CommandletParams += (Params.GetTargetPlatformInstance(DataPlatform).GetCookExtraCommandLine(Params));
                        MapsList.AddRange((Params.GetTargetPlatformInstance(ClientPlatform).GetCookExtraMaps()));
                    }
                    Maps = MapsList.ToArray();
                }

                CookCommandlet(Params.RawProjectPath, Params.UE4Exe, Maps, Dirs, InternationalizationPreset, CulturesToCook, CombineCommandletParams(PlatformsToCook.ToArray()), CommandletParams);
            }
            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 **********");
    }