public static void CopyBuildToStagingDirectory(ProjectParams Params)
    {
        if (ShouldCreatePak(Params) || (Params.Stage && !Params.SkipStage))
        {
            Params.ValidateAndLog();

            Log("********** STAGE COMMAND STARTED **********");

            if (!Params.NoClient)
            {
                var DeployContextList = CreateDeploymentContext(Params, false, true);
                foreach (var SC in DeployContextList)
                {
                    // write out the commandline file now so it can go into the manifest
                    WriteStageCommandline(Params, SC);
                    CreateStagingManifest(Params, SC);
                    ApplyStagingManifest(Params, SC);
                }
            }

            if (Params.DedicatedServer)
            {
                var DeployContextList = CreateDeploymentContext(Params, true, true);
                foreach (var SC in DeployContextList)
                {
                    CreateStagingManifest(Params, SC);
                    ApplyStagingManifest(Params, SC);
                }
            }
            Log("********** STAGE COMMAND COMPLETED **********");
        }
    }
Ejemplo n.º 2
0
	public static void Package(ProjectParams Params, int WorkingCL=-1)
	{
		Params.ValidateAndLog();
		List<DeploymentContext> DeployContextList = new List<DeploymentContext>();
		if (!Params.NoClient)
		{
			DeployContextList.AddRange(CreateDeploymentContext(Params, false, false));
		}
		if (Params.DedicatedServer)
		{
			DeployContextList.AddRange(CreateDeploymentContext(Params, true, false));
		}
		if (DeployContextList.Count > 0 && !Params.SkipStage)
		{
			Log("********** PACKAGE COMMAND STARTED **********");

			foreach (var SC in DeployContextList)
			{
				if (Params.Package || (SC.StageTargetPlatform.RequiresPackageToDeploy && Params.Deploy))
				{
					SC.StageTargetPlatform.Package(Params, SC, WorkingCL);
				}
			}

			Log("********** PACKAGE COMMAND COMPLETED **********");
		}
	}
    public static void Run(ProjectParams Params)
    {
        Params.ValidateAndLog();
        if (!Params.Run)
        {
            return;
        }

        Log("********** RUN COMMAND STARTED **********");

        var LogFolderOutsideOfSandbox = GetLogFolderOutsideOfSandbox();
        if (!GlobalCommandLine.Installed && ServerProcess == null)
        {
            // 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");
        var ClientLogFile = CombinePaths(LogFolderOutsideOfSandbox, Params.EditorTest ? "Editor.log" : "Client.log");

        try
        {
            RunInternal(Params, ServerLogFile, ClientLogFile);
        }
        catch
        {
            throw;
        }
        finally
        {
            CopyLogsBackToLogFolder();
        }

        Log("********** RUN COMMAND COMPLETED **********");
    }
    public static void Archive(ProjectParams Params)
    {
        Params.ValidateAndLog();
        if (!Params.Archive)
        {
            return;
        }

        Log("********** ARCHIVE COMMAND STARTED **********");

        if (!Params.NoClient)
        {
            var DeployContextList = CreateDeploymentContext(Params, false, false);
            foreach ( var SC in DeployContextList )
            {
                CreateArchiveManifest(Params, SC);
                ApplyArchiveManifest(Params, SC);
                SC.StageTargetPlatform.ProcessArchivedProject(Params, SC);
            }
        }
        if (Params.DedicatedServer)
        {
            ProjectParams ServerParams = new ProjectParams(Params);
            ServerParams.Device = ServerParams.ServerDevice;
            var DeployContextList = CreateDeploymentContext(ServerParams, true, false);
            foreach ( var SC in DeployContextList )
            {
                CreateArchiveManifest(Params, SC);
                ApplyArchiveManifest(Params, SC);
                SC.StageTargetPlatform.ProcessArchivedProject(Params, SC);
            }
        }
        Log("********** ARCHIVE COMMAND COMPLETED **********");
    }
 public static void Archive(ProjectParams Params)
 {
     Params.ValidateAndLog();
     if (!Params.Archive)
     {
         return;
     }
     if (!Params.NoClient)
     {
         var DeployContextList = CreateDeploymentContext(Params, false, false);
         foreach ( var SC in DeployContextList )
         {
             CreateArchiveManifest(Params, SC);
             ApplyArchiveManifest(Params, SC);
         }
     }
     if (Params.DedicatedServer)
     {
         ProjectParams ServerParams = new ProjectParams(Params);
         ServerParams.Device = ServerParams.ServerDevice;
         var DeployContextList = CreateDeploymentContext(ServerParams, true, false);
         foreach ( var SC in DeployContextList )
         {
             CreateArchiveManifest(Params, SC);
             ApplyArchiveManifest(Params, SC);
         }
     }
 }
	public static void Deploy(ProjectParams Params)
	{
		Params.ValidateAndLog();
		if (!Params.Deploy)
		{
			return;
		}

		Log("********** DEPLOY COMMAND STARTED **********");
		
		if (!Params.NoClient)
		{
			var DeployContextList = CreateDeploymentContext(Params, false, false);
			foreach ( var SC in DeployContextList )
			{
				if (SC.StageTargetPlatform.DeployViaUFE)
				{
					string ClientCmdLine = "-run=Deploy ";
					ClientCmdLine += "-Device=" + string.Join("+", Params.Devices) + " ";
					ClientCmdLine += "-Targetplatform=" + SC.StageTargetPlatform.PlatformType.ToString() + " ";
					ClientCmdLine += "-SourceDir=\"" + CombinePaths(Params.BaseStageDirectory, SC.StageTargetPlatform.PlatformType.ToString()) + "\" ";
					string ClientApp = CombinePaths(CmdEnv.LocalRoot, "Engine/Binaries/Win64/UnrealFrontend.exe");

					Log("Deploying via UFE:");
					Log("\tClientCmdLine: " + ClientCmdLine + "");

					//@todo UAT: Consolidate running of external applications like UFE (See 'RunProjectCommand' for other instances)
					PushDir(Path.GetDirectoryName(ClientApp));
					// Always start client process and don't wait for exit.
					IProcessResult ClientProcess = Run(ClientApp, ClientCmdLine, null, ERunOptions.NoWaitForExit);
					PopDir();
					if (ClientProcess != null)
					{
						do
						{
							Thread.Sleep(100);
						}
						while (ClientProcess.HasExited == false);
					}
				}
				else
				{
					SC.StageTargetPlatform.Deploy(Params, SC);
				}
			}
		}
		if (Params.DedicatedServer)
		{
			ProjectParams ServerParams = new ProjectParams(Params);
			ServerParams.Devices = new ParamList<string>(ServerParams.ServerDevice);
			var DeployContextList = CreateDeploymentContext(ServerParams, true, false);
			foreach ( var SC in DeployContextList )
			{
				SC.StageTargetPlatform.Deploy(ServerParams, SC);
			}
		}

		Log("********** DEPLOY COMMAND COMPLETED **********");
	}
    public static void Package(ProjectParams Params, int WorkingCL=-1)
    {
        Params.ValidateAndLog();
        if (!Params.Package)
        {
            return;
        }
        if (!Params.NoClient)
        {
            var DeployContextList = CreateDeploymentContext(Params, false, false);
            foreach ( var SC in DeployContextList )
            {
                if (SC.StageTargetPlatform.PackageViaUFE)
                {
                    string ClientCmdLine = "-run=Package ";
                    ClientCmdLine += "-Targetplatform=" + SC.StageTargetPlatform.PlatformType.ToString() + " ";
                    ClientCmdLine += "-SourceDir=" + CombinePaths(Params.BaseStageDirectory, SC.StageTargetPlatform.PlatformType.ToString()) + " ";
                    string ClientApp = CombinePaths(CmdEnv.LocalRoot, "Engine/Binaries/Win64/UnrealFrontend.exe");

                    Log("Packaging via UFE:");
                    Log("\tClientCmdLine: " + ClientCmdLine + "");

                    //@todo UAT: Consolidate running of external applications like UFE (See 'RunProjectCommand' for other instances)
                    PushDir(Path.GetDirectoryName(ClientApp));
                    // Always start client process and don't wait for exit.
                    ProcessResult ClientProcess = Run(ClientApp, ClientCmdLine, null, ERunOptions.NoWaitForExit);
                    PopDir();
                    if (ClientProcess != null)
                    {
                        do
                        {
                            Thread.Sleep(100);
                        }
                        while (ClientProcess.HasExited == false);
                    }
                }
                else
                {
                    SC.StageTargetPlatform.Package(Params, SC, WorkingCL);
                }
            }
        }
        if (Params.DedicatedServer)
        {
            var DeployContextList = CreateDeploymentContext(Params, true, false);
            foreach (var SC in DeployContextList)
            {
                SC.StageTargetPlatform.Package(Params, SC, WorkingCL);
            }
        }
    }
	public static void CopyBuildToStagingDirectory(ProjectParams Params)
	{
		if (ShouldCreatePak(Params) || (Params.Stage && !Params.SkipStage))
		{
			Params.ValidateAndLog();

			LogConsole("********** STAGE COMMAND STARTED **********");

			if (!Params.NoClient)
			{
				var DeployContextList = CreateDeploymentContext(Params, false, true);
				foreach (var SC in DeployContextList)
				{
					// write out the commandline file now so it can go into the manifest
					WriteStageCommandline(Params, SC);
					CreateStagingManifest(Params, SC);
					ApplyStagingManifest(Params, SC);

					if (Params.Deploy)
					{
						// get the deployed file data
						Dictionary<string, string> DeployedUFSFiles = new Dictionary<string, string>();
						Dictionary<string, string> DeployedNonUFSFiles = new Dictionary<string, string>();
						List<string> UFSManifests;
						List<string> NonUFSManifests;
						if (SC.StageTargetPlatform.RetrieveDeployedManifests(Params, SC, out UFSManifests, out NonUFSManifests))
						{
							DeployedUFSFiles = ReadDeployedManifest(Params, SC, UFSManifests);
							DeployedNonUFSFiles = ReadDeployedManifest(Params, SC, NonUFSManifests);
						}

						// get the staged file data
						Dictionary<string, string> StagedUFSFiles = ReadStagedManifest(Params, SC, DeploymentContext.UFSDeployedManifestFileName);
						Dictionary<string, string> StagedNonUFSFiles = ReadStagedManifest(Params, SC, DeploymentContext.NonUFSDeployedManifestFileName);

						WriteObsoleteManifest(Params, SC, DeployedUFSFiles, StagedUFSFiles, DeploymentContext.UFSDeployObsoleteFileName);
						WriteObsoleteManifest(Params, SC, DeployedNonUFSFiles, StagedNonUFSFiles, DeploymentContext.NonUFSDeployObsoleteFileName);

						if (Params.IterativeDeploy)
						{
							
							// write out the delta file data
							WriteDeltaManifest(Params, SC, DeployedUFSFiles, StagedUFSFiles, DeploymentContext.UFSDeployDeltaFileName);
							WriteDeltaManifest(Params, SC, DeployedNonUFSFiles, StagedNonUFSFiles, DeploymentContext.NonUFSDeployDeltaFileName);
						}
					}

					if (Params.bCodeSign)
					{
						SC.StageTargetPlatform.SignExecutables(SC, Params);
					}
				}
			}

			if (Params.DedicatedServer)
			{
				var DeployContextList = CreateDeploymentContext(Params, true, true);
				foreach (var SC in DeployContextList)
				{
					CreateStagingManifest(Params, SC);
					ApplyStagingManifest(Params, SC);
				}
			}
			LogConsole("********** STAGE COMMAND COMPLETED **********");
		}
	}
	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 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[] 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, 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 **********");
    }
Ejemplo n.º 11
0
	public static void Cook(ProjectParams Params)
	{
		if ((!Params.Cook && !(Params.CookOnTheFly && !Params.SkipServer)) || Params.SkipCook)
		{
			return;
		}
		Params.ValidateAndLog();

		LogConsole("********** 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";
				}

				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, COTFCommandLine);

				if (ServerProcess != null)
				{
					LogConsole("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)
			{
				LogConsole("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)
                {
					LogConsole("HasMapsToCook " + M.ToString());
                }
                foreach (var M in Params.MapsToCook)
                {
					LogConsole("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 = 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.CookMapsOnly)
                {
                    CommandletParams += " -mapsonly";
                }
                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";
                }
                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.
					LogConsole("Cook failed. Deleting cooked data.");
					CleanupCookedData(PlatformsToCook.ToList(), Params);
					throw new AutomationException(ErrorCodes.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.
                    LogConsole("Cook failed. Deleting cooked data.");
                    CleanupCookedData(PlatformsToCook.ToList(), Params);
                    throw new AutomationException(ErrorCodes.Error_UnknownCookFailure, Ex, "Cook failed.");
                }
            }
            
		}


		LogConsole("********** COOK COMMAND COMPLETED **********");
	}
Ejemplo n.º 12
0
    protected ProjectParams SetupParams()
    {
        Log("Setting up ProjectParams for {0}", ProjectPath);

        var Params = new ProjectParams
        (
            Command: this,
            // Shared
            RawProjectPath: ProjectPath
        );

        // Initialize map
        var Map = ParseParamValue("map");
        if (Map == null)
        {
            LogVerbose("-map command line param not found, trying to find DefaultMap in INI.");
            Map = GetDefaultMap(Params);
        }

        if (!String.IsNullOrEmpty(Map))
        {
            if (ParseParam("allmaps"))
            {
                Log("Cooking all maps");
            }
            else
            {
                Params.MapsToCook = new ParamList<string>(Map);
            }

            Params.MapToRun = GetFirstMap(Map);
        }

        // @rocket hack: non-code projects cannot run in Debug
        if (Params.Rocket && !ProjectUtils.IsCodeBasedUProjectFile(ProjectPath))
        {
            if (Params.ClientConfigsToBuild.Contains(UnrealTargetConfiguration.Debug))
            {
                Log("Non-code projects cannot run in Debug game clients. Defaulting to Development.");

                Params.ClientConfigsToBuild.Remove(UnrealTargetConfiguration.Debug);
                Params.ClientConfigsToBuild.Add(UnrealTargetConfiguration.Development);
            }

            if (Params.ClientConfigsToBuild.Contains(UnrealTargetConfiguration.Debug))
            {
                Log("Non-code projects cannot run in Debug game servers. Defaulting to Development.");

                Params.ServerConfigsToBuild.Remove(UnrealTargetConfiguration.Debug);
                Params.ServerConfigsToBuild.Add(UnrealTargetConfiguration.Development);
            }
        }

        var DirectoriesToCook = ParseParamValue("cookdir");
        if (!String.IsNullOrEmpty(DirectoriesToCook))
        {
            Params.DirectoriesToCook = new ParamList<string>(DirectoriesToCook.Split('+'));
        }

        var InternationalizationPreset = ParseParamValue("i18npreset");
        if (!String.IsNullOrEmpty(InternationalizationPreset))
        {
            Params.InternationalizationPreset = InternationalizationPreset;
        }

        var CulturesToCook = ParseParamValue("cookcultures");
        if (!String.IsNullOrEmpty(CulturesToCook))
        {
            Params.CulturesToCook = new ParamList<string>(CulturesToCook.Split('+'));
        }

        if (Params.DedicatedServer)
        {
            foreach (var ServerPlatformInstance in Params.ServerTargetPlatformInstances)
            {
                ServerPlatformInstance.PlatformSetupParams(ref Params);
            }
        }
        else
        {
            foreach (var ClientPlatformInstance in Params.ClientTargetPlatformInstances)
            {
                ClientPlatformInstance.PlatformSetupParams(ref Params);
            }
        }

        Params.ValidateAndLog();
        return Params;
    }
	protected ProjectParams SetupParams()
	{
		Log("Setting up ProjectParams for {0}", ProjectPath);

		var Params = new ProjectParams
		(
			Command: this,
			// Shared
			RawProjectPath: ProjectPath
		);

		var DirectoriesToCook = ParseParamValue("cookdir");
		if (!String.IsNullOrEmpty(DirectoriesToCook))
		{
			Params.DirectoriesToCook = new ParamList<string>(DirectoriesToCook.Split('+'));
		}

        var InternationalizationPreset = ParseParamValue("i18npreset");
        if (!String.IsNullOrEmpty(InternationalizationPreset))
        {
            Params.InternationalizationPreset = InternationalizationPreset;
        }

        var CulturesToCook = ParseParamValue("cookcultures");
        if (!String.IsNullOrEmpty(CulturesToCook))
        {
            Params.CulturesToCook = new ParamList<string>(CulturesToCook.Split('+'));
        }

		if (Params.DedicatedServer)
		{
			foreach (var ServerPlatformInstance in Params.ServerTargetPlatformInstances)
			{
				ServerPlatformInstance.PlatformSetupParams(ref Params);
			}
		}
		else
		{
			foreach (var ClientPlatformInstance in Params.ClientTargetPlatformInstances)
			{
				ClientPlatformInstance.PlatformSetupParams(ref Params);
			}
		}

		Params.ValidateAndLog();
		return Params;
	}
    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 ScriptPluginArgs = GetBlueprintPluginPathArgument(Params, true, ClientPlatformType);
                    CrashReportPlatforms.Add(ClientPlatformType);
					Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: ScriptPluginArgs + " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"");
				}
			}
		}
		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 ScriptPluginArgs = GetBlueprintPluginPathArgument(Params, false, ServerPlatformType);
                    CrashReportPlatforms.Add(ServerPlatformType);
					Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatformType, 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 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 static void Cook(ProjectParams Params)
    {
        if (!Params.Cook || Params.SkipCook)
        {
            return;
        }
        Params.ValidateAndLog();

        string UE4EditorExe = HostPlatform.Current.GetUE4ExePath(Params.UE4Exe);
        if (!FileExists(UE4EditorExe))
        {
            throw new AutomationException("Missing " + Params.UE4Exe + " executable. Needs to be built first.");
        }

        var PlatformsToCook = new List<string>();

        if (!Params.NoClient)
        {
            foreach ( var ClientPlatformInstance in Params.ClientTargetPlatformInstances )
            {
                PlatformsToCook.Add(ClientPlatformInstance.GetCookPlatform(false, Params.HasDedicatedServerAndClient, Params.CookFlavor));
            }
        }
        if (Params.DedicatedServer)
        {
            foreach ( var ServerPlatformInstance in Params.ServerTargetPlatformInstances )
            {
                PlatformsToCook.Add(ServerPlatformInstance.GetCookPlatform(true, false, Params.CookFlavor));
            }
        }

        if (Params.Clean.HasValue && Params.Clean.Value && !Params.IterativeCooking)
        {
            Log("Cleaning cooked data.");
            CleanupCookedData(PlatformsToCook, 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();
        }

        try
        {
            var CommandletParams = "-unattended -buildmachine -forcelogflush -AllowStdOutTraceEventType -Unversioned";
            if (Params.Compressed)
            {
                CommandletParams += " -Compressed";
            }
            if (Params.UseDebugParamForEditorExe)
            {
                CommandletParams += " -debug";
            }
            if (Params.Manifests)
            {
                CommandletParams += " -manifests";
            }
            if (Params.IterativeCooking)
            {
                CommandletParams += " -iterate";
            }
            CookCommandlet(Params.RawProjectPath, Params.UE4Exe, Maps, Dirs, 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, Params);
            throw Ex;
        }
    }
    public static void Run(ProjectParams Params)
    {
        Params.ValidateAndLog();
        if (!Params.Run)
        {
            return;
        }

        var ServerLogFile = CombinePaths(CmdEnv.LogFolder, "Server.log");
        var ClientLogFile = CombinePaths(CmdEnv.LogFolder, Params.EditorTest ? "Editor.log" : "Client.log");

        // Setup server process if required.
        ProcessResult ServerProcess = null;
        if (Params.CookOnTheFly && !Params.SkipServer)
        {
            if (Params.ClientTargetPlatforms.Count > 0)
            {
                UnrealTargetPlatform ClientPlatform = Params.ClientTargetPlatforms[0];
                Platform ClientPlatformInst = Params.ClientTargetPlatformInstances[0];
                string TargetCook = ClientPlatformInst.GetCookPlatform( false, Params.HasDedicatedServerAndClient, Params.CookFlavor );
                ServerProcess = RunCookOnTheFlyServer(Params.RawProjectPath, Params.NoClient ? "" : ServerLogFile, TargetCook, Params.RunCommandline);
            }
            else
            {
                throw new AutomationException("Failed to run, client target platform not specified");
            }
        }
        else if (Params.DedicatedServer && !Params.SkipServer)
        {
            if (Params.ServerTargetPlatforms.Count > 0)
            {
                UnrealTargetPlatform ServerPlatform = Params.ServerTargetPlatforms[0];
                ServerProcess = RunDedicatedServer(Params, ServerLogFile, Params.RunCommandline);
                // With dedicated server, the client connects to local host to load a map.
                if (ServerPlatform == UnrealTargetPlatform.Linux)
                {
                    Params.MapToRun = Params.ServerDeviceAddress;
                }
                else
                {
                    Params.MapToRun = "127.0.0.1";
                }
            }
            else
            {
                throw new AutomationException("Failed to run, server target platform not specified");
            }
        }
        else if (Params.FileServer && !Params.SkipServer)
        {
            ServerProcess = RunFileServer(Params, ServerLogFile, Params.RunCommandline);
        }

        if (ServerProcess != null)
        {
            Log("Waiting a few seconds for the server to start...");
            Thread.Sleep(5000);
        }

        if (!Params.NoClient)
        {
            Log("Starting Client....");

            var SC = CreateDeploymentContext(Params, false);

            ERunOptions ClientRunFlags;
            string ClientApp;
            string ClientCmdLine;
            SetupClientParams(SC, Params, ClientLogFile, out ClientRunFlags, out ClientApp, out ClientCmdLine);

            // Run the client.
            if (ServerProcess != null)
            {
                RunClientWithServer(ServerLogFile, ServerProcess, ClientApp, ClientCmdLine, ClientRunFlags, ClientLogFile, Params);
            }
            else
            {
                RunStandaloneClient(SC, ClientLogFile, ClientRunFlags, ClientApp, ClientCmdLine, Params);
            }
        }
    }