static string GetBlueprintPluginPathArgument(ProjectParams Params, bool Client, UnrealTargetPlatform TargetPlatform)
    {
        string ScriptPluginArgs = "";

        // if we're utilizing an auto-generated code plugin/module (a product of 
        // the cook process), make sure to compile it along with the targets here

        if (Params.RunAssetNativization)
        {
            ProjectParams.BlueprintPluginKey PluginKey = new ProjectParams.BlueprintPluginKey();
            PluginKey.Client = Client;
            PluginKey.TargetPlatform = TargetPlatform;
            FileReference CodePlugin = null;
            if(Params.BlueprintPluginPaths.TryGetValue(PluginKey, out CodePlugin))
            {
                ScriptPluginArgs += "-PLUGIN \"" + CodePlugin + "\" ";
            }
            else
            {
                LogWarning("BlueprintPluginPath for " + TargetPlatform + " " + (Client ? "client" : "server") + " was not found");
            }
        }

        return ScriptPluginArgs;
    }
    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 **********");
        }
    }
    public override void GetFilesToArchive(ProjectParams Params, DeploymentContext SC)
    {
        if (SC.StageTargetConfigurations.Count != 1)
        {
            throw new AutomationException("iOS is currently only able to package one target configuration at a time, but StageTargetConfigurations contained {0} configurations", SC.StageTargetConfigurations.Count);
        }

        string PackagePath = Path.Combine(Path.GetDirectoryName(Params.RawProjectPath), "Binaries", "HTML5");
        string FinalDataLocation = Path.Combine(PackagePath, Params.ShortProjectName) + ".data";

        // copy the "Executable" to the archive directory
        string GameExe = Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename);
        if (Params.ClientConfigsToBuild[0].ToString() != "Development")
        {
            GameExe += "-HTML5-" + Params.ClientConfigsToBuild[0].ToString();
        }
        GameExe += ".js";

        // put the HTML file to the package directory
        string OutputFile = Path.Combine(PackagePath, (Params.ClientConfigsToBuild[0].ToString() != "Development" ? (Params.ShortProjectName + "-HTML5-" + Params.ClientConfigsToBuild[0].ToString()) : Params.ShortProjectName)) + ".html";

        SC.ArchiveFiles(PackagePath, Path.GetFileName(FinalDataLocation));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(FinalDataLocation + ".js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe + ".mem"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName("json2.js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName("jstorage.js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName("moz_binarystring.js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(OutputFile));
    }
	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 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 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 HTMLPakAutomation(ProjectParams InParam, DeploymentContext InSC)
    {
        Params = InParam;
        SC = InSC;

        var PakOrderFileLocationBase = CommandUtils.CombinePaths(SC.ProjectRoot, "Build", SC.FinalCookPlatform, "FileOpenOrder");
        PakOrderFileLocation = CommandUtils.CombinePaths(PakOrderFileLocationBase, "GameOpenOrder.log");
        if (!CommandUtils.FileExists_NoExceptions(PakOrderFileLocation))
        {
            // Use a fall back, it doesn't matter if this file exists or not. GameOpenOrder.log is preferred however
            PakOrderFileLocation = CommandUtils.CombinePaths(PakOrderFileLocationBase, "EditorOpenOrder.log");
        }

        string PakPath = Path.Combine(new string[] { Path.GetDirectoryName(Params.RawProjectPath), "Binaries", "HTML5", SC.ShortProjectName});
        if (Directory.Exists(PakPath))
        {
            Directory.Delete(PakPath,true);
        }

        // read in the json file. 
        string JsonFile = CommandUtils.CombinePaths(new string[] { SC.ProjectRoot, "Saved", "Cooked", "HTML5", Params.ShortProjectName, "MapDependencyGraph.json" });
        string text = File.ReadAllText(JsonFile);

        DependencyJson = fastJSON.JSON.Instance.ToObject<Dictionary<string, object>>(text);

    }
    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 ApplyStagingManifest(ProjectParams Params, DeploymentContext SC)
    {
        MaybeConvertToLowerCase(Params, SC);
        if (SC.Stage && !Params.NoCleanStage && !Params.SkipStage)
        {
            DeleteDirectory(SC.StageDirectory);
        }
        if (ShouldCreatePak(Params, SC))
        {
            if (Params.Manifests && DoesChunkPakManifestExist(Params, SC))
            {
                CreatePaksUsingChunkManifests(Params, SC);
            }
            else
            {
                CreatePakUsingStagingManifest(Params, SC);
            }
        }
        if (!SC.Stage || Params.SkipStage)
        {
            return;
        }
        DumpManifest(SC, CombinePaths(CmdEnv.LogFolder, "FinalCopy" + (SC.DedicatedServer ? "_Server" : "")), !Params.UsePak(SC.StageTargetPlatform));
        CopyUsingStagingManifest(Params, SC);

        var ThisPlatform = SC.StageTargetPlatform;
        ThisPlatform.PostStagingFileCopy(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 override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "*", false, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false);

        if (SC.bStageCrashReporter)
        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "CrashReportClient", false);
        }
    }
	public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
	{
		// Engine non-ufs (binaries)

		if (SC.bStageCrashReporter)
		{
			StageExecutable("exe", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "CrashReportClient.");
		}

		// Stage all the build products
		foreach(TargetReceipt Receipt in SC.StageTargetReceipts)
		{
			SC.StageBuildProductsFromReceipt(Receipt);
		}

		// Copy the splash screen, windows specific
		SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true);

		// Stage the bootstrap executable
		if(!Params.NoBootstrapExe)
		{
			foreach(TargetReceipt Receipt in SC.StageTargetReceipts)
			{
				BuildProduct Executable = Receipt.BuildProducts.FirstOrDefault(x => x.Type == BuildProductType.Executable);
				if(Executable != null)
				{
					// only create bootstraps for executables
					if (SC.NonUFSStagingFiles.ContainsKey(Executable.Path) && Path.GetExtension(Executable.Path) == ".exe")
					{
						string BootstrapArguments = "";
						if (!SC.IsCodeBasedProject && !ShouldStageCommandLine(Params, SC))
						{
							BootstrapArguments = String.Format("..\\..\\..\\{0}\\{0}.uproject", SC.ShortProjectName);
						}

						string BootstrapExeName;
						if(SC.StageTargetConfigurations.Count > 1)
						{
							BootstrapExeName = Path.GetFileName(Executable.Path);
						}
						else if(Params.IsCodeBasedProject)
						{
							BootstrapExeName = Receipt.GetProperty("TargetName", SC.ShortProjectName) + ".exe";
						}
						else
						{
							BootstrapExeName = SC.ShortProjectName + ".exe";
						}

						StageBootstrapExecutable(SC, BootstrapExeName, Executable.Path, SC.NonUFSStagingFiles[Executable.Path], BootstrapArguments);
					}
				}
			}
		}
	}
    public static bool CanCreateMapPaks(ProjectParams Param)
    {
        bool UseAsyncLevelLoading = false;
        var ConfigCache = new UnrealBuildTool.ConfigCacheIni(UnrealTargetPlatform.HTML5, "Engine", Path.GetDirectoryName(Param.RawProjectPath), CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Engine"));
        ConfigCache.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "UseAsyncLevelLoading", out UseAsyncLevelLoading);

        if (Param.Run)
            return false; 

        return UseAsyncLevelLoading;
    }
    public static void CreateArchiveManifest(ProjectParams Params, DeploymentContext SC)
    {
        if (!Params.Archive)
        {
            return;
        }
        var ThisPlatform = SC.StageTargetPlatform;

        ThisPlatform.GetFilesToArchive(Params, SC);

        //@todo add any archive meta data files as needed
    }
    public override void Deploy(ProjectParams Params, DeploymentContext SC)
    {
        string AdbCommand = GetAdbCommand(Params);
        string ApkName = GetFinalApkName(Params, SC.StageExecutables[0], false);
        string DeviceObbName = GetDeviceObbName(ApkName);
        string PackageName = GetPackageInfo(ApkName, false);

        // install the apk
        string UninstallCommandline = AdbCommand + "uninstall " + PackageName;
        RunAndLog(CmdEnv, CmdEnv.CmdExe, UninstallCommandline);

        string InstallCommandline = AdbCommand + "install \"" + ApkName + "\"";
        RunAndLog(CmdEnv, CmdEnv.CmdExe, InstallCommandline);

        // copy files to device if we were staging
        if (SC.Stage)
        {
            // cache some strings
            string BaseCommandline = AdbCommand + "push";
            string RemoteDir = "/mnt/sdcard/" + Params.ShortProjectName;
            string UE4GameRemoteDir = "/mnt/sdcard/" + Params.ShortProjectName;

            // make sure device is at a clean state
            Run(CmdEnv.CmdExe, AdbCommand + "shell rm -rf " + RemoteDir);
            Run(CmdEnv.CmdExe, AdbCommand + "shell rm -rf " + UE4GameRemoteDir);

            string[] Files = Directory.GetFiles(SC.StageDirectory, "*", SearchOption.AllDirectories);
            // copy each UFS file
            foreach (string Filename in Files)
            {
                // don't push the apk, we install it
                if (Path.GetExtension(Filename).Equals(".apk", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                string FinalRemoteDir = RemoteDir;
                // handle the special case of the UE4Commandline.txt when using content only game (UE4Game)
                if (!Params.IsCodeBasedProject &&
                    Path.GetFileName(Filename).Equals("UE4CommandLine.txt", StringComparison.InvariantCultureIgnoreCase))
                {
                    FinalRemoteDir = "/mnt/sdcard/UE4Game";
                }

                string RemoteFilename = Filename.Replace(SC.StageDirectory, FinalRemoteDir).Replace("\\", "/");
         				string Commandline = string.Format("{0} \"{1}\" \"{2}\"", BaseCommandline, Filename, RemoteFilename);
         				Run(CmdEnv.CmdExe, Commandline);
            }

            // delete the .obb file, since it will cause nothing we just deployed to be used
            Run(CmdEnv.CmdExe, AdbCommand + "shell rm -f " + DeviceObbName);
        }
    }
    public static void ApplyStagingManifest(ProjectParams Params, DeploymentContext SC)
    {
        MaybeConvertToLowerCase(Params, SC);
        if (SC.Stage && !Params.NoCleanStage && !Params.SkipStage && !Params.IterativeDeploy)
        {
            try
            {
                DeleteDirectory(SC.StageDirectory);
            }
            catch (Exception Ex)
            {
                // Delete cooked data (if any) as it may be incomplete / corrupted.
                Log("Failed to delete staging directory "+SC.StageDirectory);
                AutomationTool.ErrorReporter.Error("Stage Failed.", (int)AutomationTool.ErrorCodes.Error_FailedToDeleteStagingDirectory);
                throw Ex;
            }
        }
        else
        {
            try
            {
                // delete old pak files
                DeletePakFiles(SC.StageDirectory);
            }
            catch (Exception Ex)
            {
                // Delete cooked data (if any) as it may be incomplete / corrupted.
                Log("Failed to delete pak files in "+SC.StageDirectory);
                AutomationTool.ErrorReporter.Error("Stage Failed.", (int)AutomationTool.ErrorCodes.Error_FailedToDeleteStagingDirectory);
                throw Ex;
            }
        }
        if (ShouldCreatePak(Params, SC))
        {
            if (Params.Manifests && DoesChunkPakManifestExist(Params, SC))
            {
                CreatePaksUsingChunkManifests(Params, SC);
            }
            else
            {
                CreatePakUsingStagingManifest(Params, SC);
            }
        }
        if (!SC.Stage || Params.SkipStage)
        {
            return;
        }
        DumpManifest(SC, CombinePaths(CmdEnv.LogFolder, "FinalCopy" + (SC.DedicatedServer ? "_Server" : "")), !Params.UsePak(SC.StageTargetPlatform));
        CopyUsingStagingManifest(Params, SC);

        var ThisPlatform = SC.StageTargetPlatform;
        ThisPlatform.PostStagingFileCopy(Params, SC);
    }
 public static void ApplyArchiveManifest(ProjectParams Params, DeploymentContext SC)
 {
     if (SC.ArchivedFiles.Count > 0)
     {
         foreach (var Pair in SC.ArchivedFiles)
         {
             string Src = Pair.Key;
             string Dest = CombinePaths(SC.ArchiveDirectory, Pair.Value);
             CopyFileIncremental(Src, Dest);
         }
     }
 }
	public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
	{
		SC.bIsCombiningMultiplePlatforms = true;
		string SavedPlatformDir = SC.PlatformDir;
		foreach (UnrealTargetPlatform DesktopPlatform in GetStagePlatforms())
		{
			Platform SubPlatform = Platform.Platforms[DesktopPlatform];
			SC.PlatformDir = DesktopPlatform.ToString();
			SubPlatform.GetFilesToDeployOrStage(Params, SC);
		}
		SC.PlatformDir = SavedPlatformDir;
		SC.bIsCombiningMultiplePlatforms = false;
	}
	public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
	{
		SC.bIsCombiningMultiplePlatforms = true;
		string SavedPlatformDir = SC.PlatformDir;
		foreach (UnrealTargetPlatform DesktopPlatform in GetStagePlatforms())
		{
			Platform SubPlatform = Platform.GetPlatform(DesktopPlatform);
			SC.PlatformDir = DesktopPlatform.ToString();
			SubPlatform.Package(Params, SC, WorkingCL);
		}
		SC.PlatformDir = SavedPlatformDir;
		SC.bIsCombiningMultiplePlatforms = false;
	}
    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);
            }
        }
    }
    /// <summary>
    /// Deploy the application on the current platform
    /// </summary>
    /// <param name="Params"></param>
    /// <param name="SC"></param>
    public override void Deploy(ProjectParams Params, DeploymentContext SC)
    {
        if (!String.IsNullOrEmpty(Params.ServerDeviceAddress))
        {
            string sourcePath = CombinePaths(Params.BaseStageDirectory, GetCookPlatform(Params.DedicatedServer, false, ""));
            string destPath = Params.DeviceUsername + "@" + Params.ServerDeviceAddress + ":.";
            RunAndLog(CmdEnv, pscpPath, String.Format("-batch -i {0} -r {1} {2}", Params.DevicePassword, sourcePath, destPath));

            List<string> Exes = GetExecutableNames(SC);

            string binPath = CombinePaths(GetCookPlatform(Params.DedicatedServer, false, ""), SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir, Path.GetFileName(Exes[0])).Replace("\\", "/");
            string iconPath = CombinePaths(GetCookPlatform(Params.DedicatedServer, false, ""), SC.RelativeProjectRootForStage, SC.ShortProjectName + ".png").Replace("\\", "/");

            string DesiredGLVersion = "4.3";

            // Begin Bash Shell Script
            string script = String.Format(@"#!/bin/bash
        # Check for OpenGL4 support
        glarg=''
        if command -v glxinfo >/dev/null 2>&1 ; then
        export DISPLAY="":0""
        glversion=$(glxinfo | grep ""OpenGL version string:"" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/')
        glmatch=$(echo -e ""$glversion\n{0}"" | sort -Vr | head -1)
        [[ ""$glmatch"" = ""$glversion"" ]] && glarg=' -opengl4'
        fi

        # Create .desktop file
        cat > $HOME/Desktop/{1}.desktop << EOF
        [Desktop Entry]
        Type=Application
        Name={2}
        Comment=UE4 Game
        Exec=$HOME/{3}{4}$glarg
        Icon=$HOME/{5}
        Terminal=false
        Categories=Game;
        EOF

        # Set permissions
        chmod 755 $HOME/{3}
        chmod 700 $HOME/Desktop/{1}.desktop", DesiredGLVersion, SC.ShortProjectName, SC.ShortProjectName, binPath, (Params.UsePak(SC.StageTargetPlatform) ? " -pak" : ""), iconPath);
            // End Bash Shell Script

            string scriptFile = Path.GetTempFileName();
            File.WriteAllText(scriptFile, script);
            RunAndLog(CmdEnv, plinkPath, String.Format("-ssh -t -batch -l {0} -i {1} {2} -m {3}", Params.DeviceUsername, Params.DevicePassword, Params.ServerDeviceAddress, scriptFile));
            File.Delete(scriptFile);
        }
    }
 /// <summary>
 /// Deploy the application on the current platform
 /// </summary>
 /// <param name="Params"></param>
 /// <param name="SC"></param>
 public override void Deploy(ProjectParams Params, DeploymentContext SC)
 {
     if (!String.IsNullOrEmpty(Params.ServerDeviceAddress))
     {
         string sourcePath = CombinePaths(Params.BaseStageDirectory, GetCookPlatform(Params.DedicatedServer,false,""));
         string destPath = Params.DeviceUsername + "@" + Params.ServerDeviceAddress + ":.";
         RunAndLog(CmdEnv, pscpPath, String.Format("-batch -i {0} -r {1} {2}", Params.DevicePassword, sourcePath, destPath));
         List<String> exes = GetExecutableNames(SC);
         foreach (var exe in exes)
         {
             string exePath = CombinePaths(GetCookPlatform(Params.DedicatedServer,false,""), exe.Replace(sourcePath, "").ToLower()).Replace("\\", "/");
             RunAndLog(CmdEnv, plinkPath, String.Format("-ssh -t -batch -l {0} -i {1} {2} chmod a+x {3}", Params.DeviceUsername, Params.DevicePassword, Params.ServerDeviceAddress, exePath));
         }
     }
 }
    static void AddBlueprintPluginPathArgument(ProjectParams Params, bool Client, UnrealTargetPlatform TargetPlatform, string PlatformToCook)
    {
        if (Params.RunAssetNativization)
        {
            ProjectParams.BlueprintPluginKey PluginKey = new ProjectParams.BlueprintPluginKey();
            PluginKey.Client = Client;
            PluginKey.TargetPlatform = TargetPlatform;

            string ProjectDir = Params.RawProjectPath.Directory.ToString();
            // 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(ProjectDir, "Intermediate", PlatformToCook, "NativizedAssets/NativizedAssets.uplugin");
            Params.BlueprintPluginPaths.Add(PluginKey, new FileReference(GeneratedPluginPath));
        }
    }
	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;
	}
		private static void GetConnectedDevices(ProjectParams Params, Platform TargetPlatform)
		{
			var PlatformName = TargetPlatform.PlatformType.ToString();
			List<string> ConnectedDevices;
			TargetPlatform.GetConnectedDevices(Params, out ConnectedDevices);

			try
			{
				foreach (var DeviceName in ConnectedDevices)
				{
					LogConsole("Device:{0}:{1}", PlatformName, DeviceName);
				}
			}
			catch
			{
				throw new AutomationException("No {0} devices", PlatformName);
			}		
		}
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        List<string> Exes = GetExecutableNames(SC);
        foreach (var Exe in Exes)
        {
            if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir)))
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir, System.IO.Path.GetFileNameWithoutExtension(Exe) + ".app"));
            }
            else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir)))
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, System.IO.Path.GetFileNameWithoutExtension(Exe) + ".app"));
            }
        }

        // Copy the splash screen, Mac specific
        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true);
    }
    public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
    {
        Log("Package {0}", Params.RawProjectPath);

        string FinalDataLocation = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(Params.ProjectGameExeFilename)), Params.ProjectBinariesFolder, Params.ShortProjectName) +".data";

        // we need to operate in the root
        using (new PushedDirectory(Path.Combine(Params.BaseStageDirectory, "HTML5")))
        {

            string BaseSDKPath = "";
        #if !MONO
            RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
            RegistryKey key = localKey.OpenSubKey("Software\\Emscripten64");
            if (key != null)
            {
                string sdkdir = key.GetValue("Install_Dir") as string;
                // emscripten path is the highest numbered directory
                DirectoryInfo dInfo = new DirectoryInfo(sdkdir + "\\emscripten");
                string Latest_Ver = (from S in dInfo.GetDirectories() select S.Name).ToList().Last();
                BaseSDKPath = sdkdir + @"\emscripten\" + Latest_Ver;
            }
            else
            {
                BaseSDKPath = Environment.ExpandEnvironmentVariables("%EMSCRIPTEN%");

            }
        #else
            BaseSDKPath = Environment.ExpandEnvironmentVariables("%EMSCRIPTEN%");
        #endif
            // make the file_packager command line
            string PackagerPath = "\""  + BaseSDKPath + "\\tools\\file_packager.py\"";
            string CmdLine = string.Format("/c {0} {1} --preload . --pre-run --js-output={1}.js", PackagerPath, FinalDataLocation);

            // package it up!
            RunAndLog(CmdEnv, CommandUtils.CombinePaths(Environment.SystemDirectory, "cmd.exe"), CmdLine);
        }

        // put the HTML file to the binaries directory
        string TemplateFile = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5", "Game.html.template");
        string OutputFile = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(Params.ProjectGameExeFilename)), Params.ProjectBinariesFolder, Params.ShortProjectName) + ".html";
        GenerateFileFromTemplate(TemplateFile, OutputFile, Params.ShortProjectName, Params.ClientConfigsToBuild[0].ToString(), Params.StageCommandline, !Params.IsCodeBasedProject);
        PrintRunTime();
    }
	public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
	{
		List<string> Exes = GetExecutableNames(SC);
		foreach (var Exe in Exes)
		{
			string AppBundlePath = "";
			if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir)))
			{
				AppBundlePath = CombinePaths(SC.ShortProjectName, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app");
				StageAppBundle(SC, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"), AppBundlePath);
			}
			else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir)))
			{
				AppBundlePath = CombinePaths("Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app");

				string AbsoluteBundlePath = CombinePaths (SC.LocalRoot, AppBundlePath);
				// ensure the ue4game binary exists, if applicable
				if (!SC.IsCodeBasedProject && !Directory.Exists(AbsoluteBundlePath))
				{
					Log("Failed to find app bundle " + AbsoluteBundlePath);
					AutomationTool.ErrorReporter.Error("Stage Failed.", (int)AutomationTool.ErrorCodes.Error_MissingExecutable);
					throw new AutomationException("Could not find app bundle {0}. You may need to build the UE4 project with your target configuration and platform.", AbsoluteBundlePath);
				}

				StageAppBundle(SC, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"), AppBundlePath);
			}

			if (!string.IsNullOrEmpty(AppBundlePath))
			{
				SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Build/Mac"), "Application.icns", false, null, CombinePaths(AppBundlePath, "Contents/Resources"), true);
			}
		}

		// Copy the splash screen, Mac specific
		SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true);

		// CEF3 files
		if(Params.bUsesCEF3)
		{
			SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/CEF3/Mac/"), "*", true, null, null, true);
			string UnrealCEFSubProcessPath = CombinePaths("Engine/Binaries", SC.PlatformDir, "UnrealCEFSubProcess.app");
			StageAppBundle(SC, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UnrealCEFSubProcess.app"), UnrealCEFSubProcessPath);
		}
	}
    public static void CreateArchiveManifest(ProjectParams Params, DeploymentContext SC)
    {
        if (!Params.Archive)
        {
            return;
        }
        var ThisPlatform = SC.StageTargetPlatform;

        ThisPlatform.GetFilesToArchive(Params, SC);

        //@todo add any archive meta data files as needed

        if (Params.ArchiveMetaData)
        {
            // archive the build.properties for extra info for testing, etc
            string BuildPropertiesFile = CombinePaths(SC.LocalRoot, "Engine", "Build", "build.properties");
            SC.ArchiveFiles(Path.GetDirectoryName(BuildPropertiesFile), Path.GetFileName(BuildPropertiesFile));
        }
    }
Example #30
0
    public override void GetFilesToArchive(ProjectParams Params, DeploymentContext SC)
    {
        if (SC.StageTargetConfigurations.Count != 1)
        {
            throw new AutomationException("iOS is currently only able to package one target configuration at a time, but StageTargetConfigurations contained {0} configurations", SC.StageTargetConfigurations.Count);
        }

        string PackagePath = Path.Combine(Path.GetDirectoryName(Params.RawProjectPath), "Binaries", "HTML5");
        string FinalDataLocation = Path.Combine(PackagePath, Params.ShortProjectName) + ".data";

        // copy the "Executable" to the archive directory
        string GameExe = Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename);
        if (Params.ClientConfigsToBuild[0].ToString() != "Development")
        {
            GameExe += "-HTML5-" + Params.ClientConfigsToBuild[0].ToString();
        }
        GameExe += ".js";

        // put the HTML file to the package directory
        string OutputFile = Path.Combine(PackagePath, (Params.ClientConfigsToBuild[0].ToString() != "Development" ? (Params.ShortProjectName + "-HTML5-" + Params.ClientConfigsToBuild[0].ToString()) : Params.ShortProjectName)) + ".html";

        SC.ArchiveFiles(PackagePath, Path.GetFileName(FinalDataLocation));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(FinalDataLocation + ".js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe + ".mem"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(GameExe + ".symbols"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName("json2.js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName("jStorage.js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName("moz_binarystring.js"));
        SC.ArchiveFiles(PackagePath, Path.GetFileName(OutputFile));

        if (HTMLPakAutomation.CanCreateMapPaks(Params))
        {
            // find all paks.
            string[] Files = Directory.GetFiles(Path.Combine(PackagePath, Params.ShortProjectName), "*",SearchOption.AllDirectories);
            foreach(string PakFile in Files)
            {
                var DestPak = PakFile.Replace(PackagePath,"");
                SC.ArchivedFiles.Add(PakFile, DestPak);
            }
        }
    }