using System; using System.Collections.Generic; using System.IO; using System.Linq; using AutomationTool; using UnrealBuildTool; using Gauntlet; using System.Net.NetworkInformation; using static AutomationTool.P4Connection; namespace OrionTest { /// /// Performs Build+Cook+Pak+Stage+Test /// /// public class BuildCookTest : BuildCommand { /// /// Checks that all of the required params are present, throws an exception if not /// /// void CheckRequiredParams(params string[] Args) { foreach (string Arg in Args) { if (ParseParamValue(Arg, null) == null) { throw new AutomationException("Param {0} is missing but required. Required params are {1}", Arg, string.Join(",", Args)); } } } /// /// Main entrance point for this script /// /// public override ExitCode Execute() { // If no params, show usage flags if (Params.Length == 0) { Console.WriteLine("Usage: BuildCookTest -platform= -configuration= -test= [-skipbuild -skipcook -skippak -skipcook -skipbc -skiptests -clean -iteratesharedbuild]"); return ExitCode.Success; } // check the essential params are present CheckRequiredParams("platform", "configuration", "test"); // save off params here string Platform = ParseParamValue("platform", null); string Config = ParseParamValue("configuration", null); string Test = ParseParamValue("test", null); bool SkipSync = ParseParam("skipsync"); bool SkipBuild = ParseParam("skipbuild"); bool SkipCook = ParseParam("skipcook"); bool SkipBuildAndCook = ParseParam("skipbc") || (SkipBuild && SkipCook); bool SkipTest = ParseParam("skiptest"); ExitCode Result = ExitCode.Success; // Build/Cook status, assume success because we may skip this... ExitCode BuildCookResult = ExitCode.Success; if (SkipBuildAndCook == false) { BuildCookRun BCR = new BuildCookRun(); // basic arguments string Args = string.Format("-project=OrionGame -platform={0} -config={1} -client -nocompile ", Platform, Config); if (ParseParam("clean")) { Console.WriteLine("Cleaning Data"); Args += " -clean"; } else { Args += " -iterate"; } // UAT params are passed in as an array without the leading '-', so convert our command line to that List ArgList = Args.Split(' ').Select((string S) => { if (S.Length > 0) { S = S.Substring(1); } return S; }).ToList(); ArgList.AddRange(new string[] { "server", "serverplatform=Win64" }); //. Do build? if (!SkipBuild) { if (!ParseParam("skipbuildclient") || !ParseParam("skipbuildeditor")) { ArgList.Add("build"); if (ParseParam("skipbuildclient")) { ArgList.Add("skipbuildclient"); } if (ParseParam("skipbuildeditor")) { ArgList.Add("skipbuildeditor"); } } } // Do cook? for the timebeing cooking is implicitly tied to pak/stage if (SkipCook) { ArgList.AddRange(new string[] { "skipcook", "skippak", "skipstage", "nocompileeditor" }); } else { ArgList.AddRange(new string[] { "cook", "pak", "stage" }); } BCR.Params = ArgList.ToArray(); Console.WriteLine("Running: BuildCookRun " + BCR.Params); BuildCookResult = BCR.Execute(); } // If BuildCook succeeded, or was skipped if (BuildCookResult == ExitCode.Success && SkipTest == false) { } return Result; } } }