예제 #1
0
    public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
    {
        Log("Package {0}", Params.RawProjectPath);

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

        if (!Directory.Exists(PackagePath))
        {
            Directory.CreateDirectory(PackagePath);
        }
        string FinalDataLocation = Path.Combine(PackagePath, Params.ShortProjectName) + ".data";

        var ConfigCache = new UnrealBuildTool.ConfigCacheIni(UnrealTargetPlatform.HTML5, "Engine", Path.GetDirectoryName(Params.RawProjectPath), CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Engine"));

        if (HTMLPakAutomation.CanCreateMapPaks(Params))
        {
            HTMLPakAutomation PakAutomation = new HTMLPakAutomation(Params, SC);

            // Create Necessary Paks.
            PakAutomation.CreateEnginePak();
            PakAutomation.CreateGamePak();
            PakAutomation.CreateContentDirectoryPak();

            // Create Emscripten Package from Necessary Paks. - This will be the VFS.
            PakAutomation.CreateEmscriptenDataPackage(PackagePath, FinalDataLocation);

            // Create All Map Paks which  will be downloaded on the fly.
            PakAutomation.CreateMapPak();

            // Create Delta Paks if setup.
            List <string> Paks = new List <string>();
            ConfigCache.GetArray("/Script/HTML5PlatformEditor.HTML5TargetSettings", "LevelTransitions", out Paks);

            if (Paks != null)
            {
                foreach (var Pak in Paks)
                {
                    var    Matched = Regex.Matches(Pak, "\"[^\"]+\"", RegexOptions.IgnoreCase);
                    string MapFrom = Path.GetFileNameWithoutExtension(Matched[0].ToString().Replace("\"", ""));
                    string MapTo   = Path.GetFileNameWithoutExtension(Matched[1].ToString().Replace("\"", ""));
                    PakAutomation.CreateDeltaMapPaks(MapFrom, MapTo);
                }
            }
        }
        else
        {
            // we need to operate in the root
            using (new PushedDirectory(Path.Combine(Params.BaseStageDirectory, "HTML5")))
            {
                string PythonPath   = HTML5SDKInfo.PythonPath();
                string PackagerPath = HTML5SDKInfo.EmscriptenPackager();

                string CmdLine = string.Format("\"{0}\" \"{1}\" --preload . --js-output=\"{1}.js\"", PackagerPath, FinalDataLocation);
                RunAndLog(CmdEnv, PythonPath, CmdLine);
            }
        }

        // copy the "Executable" to the package directory
        string GameExe = Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename);

        if (Params.ClientConfigsToBuild[0].ToString() != "Development")
        {
            GameExe += "-HTML5-" + Params.ClientConfigsToBuild[0].ToString();
        }
        GameExe += ".js";

        // ensure the ue4game binary exists, if applicable
        string FullGameExePath = Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe);

        if (!SC.IsCodeBasedProject && !FileExists_NoExceptions(FullGameExePath))
        {
            Log("Failed to find game application " + FullGameExePath);
            AutomationTool.ErrorReporter.Error("Stage Failed.", (int)AutomationTool.ErrorCodes.Error_MissingExecutable);
            throw new AutomationException("Could not find application {0}. You may need to build the UE4 project with your target configuration and platform.", FullGameExePath);
        }

        if (Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) != Path.Combine(PackagePath, GameExe))
        {
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe), Path.Combine(PackagePath, GameExe), true);
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) + ".mem", Path.Combine(PackagePath, GameExe) + ".mem", true);
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) + ".symbols", Path.Combine(PackagePath, GameExe) + ".symbols", true);
        }
        File.SetAttributes(Path.Combine(PackagePath, GameExe), FileAttributes.Normal);
        File.SetAttributes(Path.Combine(PackagePath, GameExe) + ".mem", FileAttributes.Normal);
        File.SetAttributes(Path.Combine(PackagePath, GameExe) + ".symbols", FileAttributes.Normal);


        // put the HTML file to the package directory

        bool UseExperimentalTemplate = false;

        ConfigCache.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "UseExperimentalTemplate", out UseExperimentalTemplate);
        string TemplateFileName = UseExperimentalTemplate ? "GameX.html.template" : "Game.html.template";

        string TemplateFile = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5", TemplateFileName);
        string OutputFile   = Path.Combine(PackagePath, (Params.ClientConfigsToBuild[0].ToString() != "Development" ? (Params.ShortProjectName + "-HTML5-" + Params.ClientConfigsToBuild[0].ToString()) : Params.ShortProjectName)) + ".html";

        // find Heap Size.
        ulong HeapSize;

        int ConfigHeapSize = 0;
        // Valuer set by Editor UI
        var bGotHeapSize = ConfigCache.GetInt32("/Script/HTML5PlatformEditor.HTML5TargetSettings", "HeapSize" + Params.ClientConfigsToBuild[0].ToString(), out ConfigHeapSize);

        // Fallback if the previous method failed
        if (!bGotHeapSize && !ConfigCache.GetInt32("BuildSettings", "HeapSize" + Params.ClientConfigsToBuild[0].ToString(), out ConfigHeapSize)) // in Megs.
        {
            // we couldn't find a per config heap size, look for a common one.
            if (!ConfigCache.GetInt32("BuildSettings", "HeapSize", out ConfigHeapSize))
            {
                ConfigHeapSize = Params.IsCodeBasedProject ? 1024 : 512;
                Log("Could not find Heap Size setting in .ini for Client config {0}", Params.ClientConfigsToBuild[0].ToString());
            }
        }

        HeapSize = (ulong)ConfigHeapSize * 1024L * 1024L; // convert to bytes.
        Log("Setting Heap size to {0} Mb ", ConfigHeapSize);


        GenerateFileFromTemplate(TemplateFile, OutputFile, Params.ShortProjectName, Params.ClientConfigsToBuild[0].ToString(), Params.StageCommandline, !Params.IsCodeBasedProject, HeapSize);

        // copy the jstorage files to the binaries directory
        string JSDir  = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5");
        string OutDir = PackagePath;

        File.Copy(JSDir + "/json2.js", OutDir + "/json2.js", true);
        File.SetAttributes(OutDir + "/json2.js", FileAttributes.Normal);
        File.Copy(JSDir + "/jStorage.js", OutDir + "/jStorage.js", true);
        File.SetAttributes(OutDir + "/jStorage.js", FileAttributes.Normal);
        File.Copy(JSDir + "/moz_binarystring.js", OutDir + "/moz_binarystring.js", true);
        File.SetAttributes(OutDir + "/moz_binarystring.js", FileAttributes.Normal);
        PrintRunTime();
    }
예제 #2
0
    public static UE4Build.BuildAgenda MakeAgenda(UnrealBuildTool.UnrealTargetPlatform[] Platforms, List <string> ExtraBuildProducts)
    {
        // Create the build agenda
        UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();

        // C# binaries
        Agenda.SwarmProject = @"Engine\Source\Programs\UnrealSwarm\UnrealSwarm.sln";
        Agenda.DotNetProjects.Add(@"Engine/Source/Editor/SwarmInterface/DotNET/SwarmInterface.csproj");
        Agenda.DotNetProjects.Add(@"Engine/Source/Programs/DotNETCommon/DotNETUtilities/DotNETUtilities.csproj");
        Agenda.DotNetProjects.Add(@"Engine/Source/Programs/RPCUtility/RPCUtility.csproj");
        Agenda.DotNetProjects.Add(@"Engine/Source/Programs/UnrealControls/UnrealControls.csproj");

        // Windows binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.Win64))
        {
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealHeaderTool", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealPak", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealLightmass", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealVersionSelector", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
            Agenda.AddTarget("BootstrapPackagedGame", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
            Agenda.AddTarget("BootstrapPackagedGame", UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetConfiguration.Development);
        }

        // Mac binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.Mac))
        {
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UnrealPak", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UnrealLightmass", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UE4EditorServices", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
        }

        // Linux binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.Linux))
        {
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Linux, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Linux, UnrealBuildTool.UnrealTargetConfiguration.Development);
        }

        // iOS binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.IOS))
        {
            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/iPhonePackager/iPhonePackager.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/iPhonePackager.exe"));

            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/DeploymentServer/DeploymentServer.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/DeploymentServer.exe"));

            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/DeploymentInterface/DeploymentInterface.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/DeploymentInterface.dll"));

            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/MobileDeviceInterface/MobileDeviceInterface.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/MobileDeviceInterface.dll"));
        }

        // PS4 binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.PS4))
        {
            Agenda.AddTarget("PS4MapFileUtil", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);

            Agenda.DotNetProjects.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Source/Programs/PS4/PS4DevKitUtil/PS4DevKitUtil.csproj"));
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/PS4/PS4DevKitUtil.exe"));

            Agenda.DotNetProjects.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Source/Programs/PS4/PS4SymbolTools/PS4SymbolTool.csproj"));
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/PS4/PS4SymbolTool.exe"));
        }

        // Xbox One binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.XboxOne))
        {
            Agenda.AddTarget("XboxOnePDBFileUtil", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
        }

        // HTML5 binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.HTML5))
        {
            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/HTML5/HTML5LaunchHelper/HTML5LaunchHelper.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/HTML5LaunchHelper.exe"));
        }

        return(Agenda);
    }
예제 #3
0
        /// <summary>
        /// Retrieves and saves all artifacts from the provided session role. Artifacts are saved to the destination path
        /// </summary>
        /// <param name="InContext"></param>
        /// <param name="InRunningRole"></param>
        /// <param name="InDestArtifactPath"></param>
        /// <returns></returns>
        public UnrealRoleArtifacts SaveRoleArtifacts(UnrealTestContext InContext, UnrealSessionInstance.RoleInstance InRunningRole, string InDestArtifactPath)
        {
            bool   IsServer = InRunningRole.Role.RoleType.IsServer();
            string RoleName = (InRunningRole.Role.IsDummy() ? "Dummy" : "") + InRunningRole.Role.RoleType.ToString();
            UnrealTargetPlatform?Platform = InRunningRole.Role.Platform;
            string RoleConfig             = InRunningRole.Role.Configuration.ToString();

            Directory.CreateDirectory(InDestArtifactPath);

            // Don't archive editor data, there can be a *lot* of stuff in that saved folder!
            bool IsEditor = InRunningRole.Role.RoleType.UsesEditor();

            bool IsDevBuild = InContext.TestParams.ParseParam("dev");

            string DestSavedDir   = Path.Combine(InDestArtifactPath, "Saved");
            string SourceSavedDir = "";

            // save the contents of the saved directory
            SourceSavedDir = InRunningRole.AppInstance.ArtifactPath;

            // save the output from TTY
            string ArtifactLogPath = Path.Combine(InDestArtifactPath, RoleName + "Output.log");

            // Write a brief Gauntlet header to aid debugging
            StringBuilder LogOut = new StringBuilder();

            LogOut.AppendLine("------ Gauntlet Test ------");
            LogOut.AppendFormat("Role: {0}\r\n", InRunningRole.Role);
            LogOut.AppendFormat("Automation Command: {0}\r\n", Environment.CommandLine);
            LogOut.AppendLine("---------------------------");

            // Write instance stdout stream
            LogOut.Append(InRunningRole.AppInstance.StdOut);

            File.WriteAllText(ArtifactLogPath, LogOut.ToString());
            Log.Info("Wrote Log to {0}", ArtifactLogPath);

            if (IsServer == false)
            {
                // gif-ify and jpeg-ify any screenshots
                try
                {
                    string ScreenshotPath = Path.Combine(SourceSavedDir, "Screenshots", Platform.ToString()).ToLower();

                    if (Directory.Exists(ScreenshotPath) && Directory.GetFiles(ScreenshotPath).Length > 0)
                    {
                        Log.Info("Downsizing and gifying session images at {0}", ScreenshotPath);

                        // downsize first so gif-step is quicker and takes less resoruces.
                        Utils.Image.ConvertImages(ScreenshotPath, ScreenshotPath, "jpg", true);

                        string GifPath = Path.Combine(InDestArtifactPath, RoleName + "Test.gif");
                        if (Utils.Image.SaveImagesAsGif(ScreenshotPath, GifPath))
                        {
                            Log.Info("Saved gif to {0}", GifPath);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    Log.Info("Failed to downsize and gif-ify images! {0}", Ex);
                }
            }

            // don't archive data in dev mode, because peoples saved data could be huuuuuuuge!
            if (IsEditor == false)
            {
                LogLevel OldLevel = Log.Level;
                Log.Level = LogLevel.Normal;

                if (Directory.Exists(SourceSavedDir))
                {
                    Utils.SystemHelpers.CopyDirectory(SourceSavedDir, DestSavedDir);
                    Log.Info("Archived artifacts to to {0}", DestSavedDir);
                }
                else
                {
                    Log.Info("Archive path '{0}' was not found!", SourceSavedDir);
                }

                Log.Level = OldLevel;
            }
            else
            {
                if (IsEditor)
                {
                    Log.Info("Skipping archival of assets for editor {0}", RoleName);
                }
                else if (IsDevBuild)
                {
                    Log.Info("Skipping archival of assets for dev build");
                }
            }

            foreach (EIntendedBaseCopyDirectory ArtifactDir in InRunningRole.Role.AdditionalArtifactDirectories)
            {
                if (InRunningRole.AppInstance.Device.GetPlatformDirectoryMappings().ContainsKey(ArtifactDir))
                {
                    string SourcePath = InRunningRole.AppInstance.Device.GetPlatformDirectoryMappings()[ArtifactDir];
                    var    DirToCopy  = new DirectoryInfo(SourcePath);
                    if (DirToCopy.Exists)
                    {
                        // Grab the final dir name to copy everything into so everything's not just going into root artifact dir.
                        string IntendedCopyLocation = Path.Combine(InDestArtifactPath, DirToCopy.Name);
                        Utils.SystemHelpers.CopyDirectory(SourcePath, IntendedCopyLocation);
                    }
                }
            }
            // TODO REMOVEME- this should go elsewhere, likely a util that can be called or inserted by relevant test nodes.
            if (IsServer == false)
            {
                // Copy over PSOs
                try
                {
                    if (InContext.Options.LogPSO)
                    {
                        foreach (var ThisFile in CommandUtils.FindFiles_NoExceptions(true, "*.rec.upipelinecache", true, DestSavedDir))
                        {
                            bool Copied   = false;
                            var  JustFile = Path.GetFileName(ThisFile);
                            if (JustFile.StartsWith("++"))
                            {
                                var Parts = JustFile.Split(new Char[] { '+', '-' }).Where(A => A != "").ToArray();
                                if (Parts.Count() >= 2)
                                {
                                    string ProjectName = Parts[0].ToString();
                                    string BuildRoot   = CommandUtils.CombinePaths(CommandUtils.RootBuildStorageDirectory());

                                    string SrcBuildPath  = CommandUtils.CombinePaths(BuildRoot, ProjectName);
                                    string SrcBuildPath2 = CommandUtils.CombinePaths(BuildRoot, ProjectName.Replace("Game", "").Replace("game", ""));

                                    if (!CommandUtils.DirectoryExists(SrcBuildPath))
                                    {
                                        SrcBuildPath = SrcBuildPath2;
                                    }
                                    if (CommandUtils.DirectoryExists(SrcBuildPath))
                                    {
                                        var JustBuildFolder = JustFile.Replace("-" + Parts.Last(), "");

                                        string PlatformStr   = Platform.ToString();
                                        string SrcCLMetaPath = CommandUtils.CombinePaths(SrcBuildPath, JustBuildFolder, PlatformStr, "MetaData");
                                        if (CommandUtils.DirectoryExists(SrcCLMetaPath))
                                        {
                                            string SrcCLMetaPathCollected = CommandUtils.CombinePaths(SrcCLMetaPath, "CollectedPSOs");
                                            if (!CommandUtils.DirectoryExists(SrcCLMetaPathCollected))
                                            {
                                                Log.Info("Creating Directory {0}", SrcCLMetaPathCollected);
                                                CommandUtils.CreateDirectory(SrcCLMetaPathCollected);
                                            }
                                            if (CommandUtils.DirectoryExists(SrcCLMetaPathCollected))
                                            {
                                                string DestFile = CommandUtils.CombinePaths(SrcCLMetaPathCollected, JustFile);
                                                CommandUtils.CopyFile_NoExceptions(ThisFile, DestFile, true);
                                                if (CommandUtils.FileExists(true, DestFile))
                                                {
                                                    Log.Info("Deleting local file, copied to {0}", DestFile);
                                                    CommandUtils.DeleteFile_NoExceptions(ThisFile, true);
                                                    Copied = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (!Copied)
                            {
                                Log.Warning("Could not find anywhere to put this file {0}", JustFile);
                            }
                        }
                    }
                }
                catch (Exception Ex)
                {
                    Log.Info("Failed to copy upipelinecaches to the network {0}", Ex);
                }
            }
            // END REMOVEME


            UnrealLogParser LogParser = new UnrealLogParser(InRunningRole.AppInstance.StdOut);

            int ExitCode = InRunningRole.AppInstance.ExitCode;

            LogParser.GetTestExitCode(out ExitCode);

            UnrealRoleArtifacts Artifacts = new UnrealRoleArtifacts(InRunningRole.Role, InRunningRole.AppInstance, InDestArtifactPath, ArtifactLogPath, LogParser);

            return(Artifacts);
        }
예제 #4
0
    public DeploymentContext(
        FileReference RawProjectPathOrName,
        string InLocalRoot,
        string BaseStageDirectory,
        string BaseArchiveDirectory,
        Platform InSourcePlatform,
        Platform InTargetPlatform,
        List <UnrealTargetConfiguration> InTargetConfigurations,
        IEnumerable <StageTarget> InStageTargets,
        List <String> InStageExecutables,
        bool InServer,
        bool InCooked,
        bool InStageCrashReporter,
        bool InStage,
        bool InCookOnTheFly,
        bool InArchive,
        bool InProgram,
        bool IsClientInsteadOfNoEditor,
        bool InForceChunkManifests,
        bool bInUseWebsocketNetDriver = false
        )
    {
        bStageCrashReporter       = InStageCrashReporter;
        RawProjectPath            = RawProjectPathOrName;
        DedicatedServer           = InServer;
        LocalRoot                 = CommandUtils.CombinePaths(InLocalRoot);
        CookSourcePlatform        = InSourcePlatform;
        StageTargetPlatform       = InTargetPlatform;
        StageTargetConfigurations = new List <UnrealTargetConfiguration>(InTargetConfigurations);
        StageTargets              = new List <StageTarget>(InStageTargets);
        StageExecutables          = InStageExecutables;
        IsCodeBasedProject        = ProjectUtils.IsCodeBasedUProjectFile(RawProjectPath);
        ShortProjectName          = ProjectUtils.GetShortProjectName(RawProjectPath);
        Stage   = InStage;
        Archive = InArchive;
        bUseWebsocketNetDriver = bInUseWebsocketNetDriver;

        if (CookSourcePlatform != null && InCooked)
        {
            CookPlatform = CookSourcePlatform.GetCookPlatform(DedicatedServer, IsClientInsteadOfNoEditor);
        }
        else if (CookSourcePlatform != null && InProgram)
        {
            CookPlatform = CookSourcePlatform.GetCookPlatform(false, false);
        }
        else
        {
            CookPlatform = "";
        }

        if (StageTargetPlatform != null && InCooked)
        {
            FinalCookPlatform = StageTargetPlatform.GetCookPlatform(DedicatedServer, IsClientInsteadOfNoEditor);
        }
        else if (StageTargetPlatform != null && InProgram)
        {
            FinalCookPlatform = StageTargetPlatform.GetCookPlatform(false, false);
        }
        else
        {
            FinalCookPlatform = "";
        }

        PlatformDir = StageTargetPlatform.PlatformType.ToString();

        StageDirectory   = CommandUtils.CombinePaths(BaseStageDirectory, FinalCookPlatform);
        ArchiveDirectory = CommandUtils.CombinePaths(BaseArchiveDirectory, FinalCookPlatform);

        if (!CommandUtils.FileExists(RawProjectPath.FullName))
        {
            throw new AutomationException("Can't find uproject file {0}.", RawProjectPathOrName);
        }

        ProjectRoot = CommandUtils.CombinePaths(CommandUtils.GetDirectoryName(RawProjectPath.FullName));

        if (!CommandUtils.DirectoryExists(ProjectRoot))
        {
            throw new AutomationException("Project Directory {0} doesn't exist.", ProjectRoot);
        }

        RelativeProjectRootForStage = ShortProjectName;

        ProjectArgForCommandLines = CommandUtils.MakePathSafeToUseWithCommandLine(RawProjectPath.FullName);
        CookSourceRuntimeRootDir  = RuntimeRootDir = LocalRoot;
        RuntimeProjectRootDir     = ProjectRoot;

        RelativeProjectRootForUnrealPak = CommandUtils.CombinePaths(RelativeProjectRootForStage).Replace("\\", "/");
        if (RelativeProjectRootForUnrealPak.StartsWith("/"))
        {
            RelativeProjectRootForUnrealPak = RelativeProjectRootForUnrealPak.Substring(1);
            RelativeProjectRootForStage     = RelativeProjectRootForStage.Substring(1);
        }

        SourceRelativeProjectRoot = RelativeProjectRootForStage; // for foreign projects this doesn't make much sense, but it turns into a noop on staging files
        if (ProjectRoot.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase))
        {
            SourceRelativeProjectRoot = ProjectRoot.Substring(LocalRoot.Length);
        }
        if (SourceRelativeProjectRoot.StartsWith("/") || SourceRelativeProjectRoot.StartsWith("\\"))
        {
            SourceRelativeProjectRoot = SourceRelativeProjectRoot.Substring(1);
        }

        if (Stage)
        {
            CommandUtils.CreateDirectory(StageDirectory);
            StageProjectRoot = CommandUtils.CombinePaths(StageDirectory, RelativeProjectRootForStage);

            RuntimeRootDir            = StageDirectory;
            CookSourceRuntimeRootDir  = CommandUtils.CombinePaths(BaseStageDirectory, CookPlatform);
            RuntimeProjectRootDir     = StageProjectRoot;
            ProjectArgForCommandLines = CommandUtils.MakePathSafeToUseWithCommandLine(UProjectCommandLineArgInternalRoot + RelativeProjectRootForStage + "/" + ShortProjectName + ".uproject");
        }
        if (Archive)
        {
            CommandUtils.CreateDirectory(ArchiveDirectory);
        }
        ProjectArgForCommandLines = ProjectArgForCommandLines.Replace("\\", "/");
        ProjectBinariesFolder     = CommandUtils.CombinePaths(ProjectUtils.GetClientProjectBinariesRootPath(RawProjectPath, TargetRules.TargetType.Game, IsCodeBasedProject), PlatformDir);

        // If we were configured to use manifests across the whole project, then this platform should use manifests.
        // Otherwise, read whether we are generating chunks from the ProjectPackagingSettings ini.
        if (InForceChunkManifests)
        {
            PlatformUsesChunkManifests = true;
        }
        else
        {
            ConfigCacheIni GameIni  = ConfigCacheIni.CreateConfigCacheIni(InTargetPlatform.PlatformType, "Game", RawProjectPath.Directory);
            String         IniPath  = "/Script/UnrealEd.ProjectPackagingSettings";
            bool           bSetting = false;
            if (GameIni.GetBool(IniPath, "bGenerateChunks", out bSetting))
            {
                PlatformUsesChunkManifests = bSetting;
            }
        }
    }
예제 #5
0
    private static bool CopySharedCookedBuildForTargetInternal(string CookedBuildPath, string CookPlatform, string LocalPath, bool bOnlyCopyAssetRegistry)
    {
        string BuildRoot = CommandUtils.P4Enabled ? CommandUtils.P4Env.Branch.Replace("/", "+") : "";
        string RecentCL  = CommandUtils.P4Enabled ? CommandUtils.P4Env.Changelist.ToString() : "";

        BuildVersion Version;

        if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version))
        {
            RecentCL  = Version.Changelist.ToString();
            BuildRoot = Version.BranchName;
        }
        System.GC.Collect();

        // check to see if we have already synced this build ;)
        var    SyncedBuildFile = CommandUtils.CombinePaths(LocalPath, "SyncedBuild.txt");
        string BuildCL         = "Invalid";

        if (File.Exists(SyncedBuildFile))
        {
            BuildCL = File.ReadAllText(SyncedBuildFile);
        }

        if (RecentCL == "" && CookedBuildPath.Contains("[CL]"))
        {
            CommandUtils.Log("Unable to copy shared cooked build: Unable to determine CL number from P4 or UGS, and is required by SharedCookedBuildPath");
            return(false);
        }

        if (RecentCL == "" && CookedBuildPath.Contains("[BRANCHNAME]"))
        {
            CommandUtils.Log("Unable to copy shared cooked build: Unable to determine BRANCHNAME number from P4 or UGS, and is required by SharedCookedBuildPath");
            return(false);
        }


        CookedBuildPath = CookedBuildPath.Replace("[CL]", RecentCL.ToString());
        CookedBuildPath = CookedBuildPath.Replace("[BRANCHNAME]", BuildRoot);
        CookedBuildPath = CookedBuildPath.Replace("[PLATFORM]", CookPlatform);

        if (Directory.Exists(CookedBuildPath) == false)
        {
            CommandUtils.Log("Unable to copy shared cooked build: Unable to find shared build at location {0} check SharedCookedBuildPath in Engine.ini SharedCookedBuildSettings is correct", CookedBuildPath);
            return(false);
        }

        CommandUtils.Log("Attempting download of latest shared build CL {0} from location {1}", RecentCL, CookedBuildPath);

        if (BuildCL == RecentCL.ToString())
        {
            CommandUtils.Log("Already downloaded latest shared build at CL {0}", RecentCL);
            return(false);
        }

        if (bOnlyCopyAssetRegistry)
        {
            RecentCL += "RegistryOnly";
        }

        if (BuildCL == RecentCL)
        {
            CommandUtils.Log("Already downloaded latest shared build at CL {0}", RecentCL);
            return(false);
        }

        // delete all the stuff
        CommandUtils.Log("Deleting previous shared build because it was out of date");
        CommandUtils.DeleteDirectory(LocalPath);
        Directory.CreateDirectory(LocalPath);



        string CookedBuildMetadataDirectory = Path.Combine(CookedBuildPath, "Metadata");

        CookedBuildMetadataDirectory = Path.GetFullPath(CookedBuildMetadataDirectory);
        string LocalBuildMetadataDirectory = Path.Combine(LocalPath, "Metadata");

        LocalBuildMetadataDirectory = Path.GetFullPath(LocalBuildMetadataDirectory);
        if (Directory.Exists(CookedBuildMetadataDirectory))
        {
            foreach (string FileName in Directory.EnumerateFiles(CookedBuildMetadataDirectory, "*.*", SearchOption.AllDirectories))
            {
                string SourceFileName = Path.GetFullPath(FileName);
                string DestFileName   = SourceFileName.Replace(CookedBuildMetadataDirectory, LocalBuildMetadataDirectory);
                Directory.CreateDirectory(Path.GetDirectoryName(DestFileName));
                File.Copy(SourceFileName, DestFileName);
            }
        }

        if (CopySharedCookedBuildTask != null)
        {
            WaitForCopy();
        }

        if (bOnlyCopyAssetRegistry == false)
        {
            CopySharedCookedBuildTask = Task.Run(() =>
            {
                // find all the files in the staged directory
                string CookedBuildStagedDirectory = Path.GetFullPath(Path.Combine(CookedBuildPath, "Staged"));
                string LocalBuildStagedDirectory  = Path.GetFullPath(Path.Combine(LocalPath, "Staged"));
                if (Directory.Exists(CookedBuildStagedDirectory))
                {
                    foreach (string FileName in Directory.EnumerateFiles(CookedBuildStagedDirectory, "*.*", SearchOption.AllDirectories))
                    {
                        string SourceFileName = Path.GetFullPath(FileName);
                        string DestFileName   = SourceFileName.Replace(CookedBuildStagedDirectory, LocalBuildStagedDirectory);
                        Directory.CreateDirectory(Path.GetDirectoryName(DestFileName));
                        File.Copy(SourceFileName, DestFileName);
                    }
                }
                File.WriteAllText(SyncedBuildFile, RecentCL.ToString());
            }
                                                 );
        }
        else
        {
            File.WriteAllText(SyncedBuildFile, RecentCL.ToString());
        }


        return(true);
    }
예제 #6
0
    public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
    {
        Log("Package {0}", Params.RawProjectPath);

        Log("Setting Emscripten SDK for packaging..");
        HTML5SDKInfo.SetupEmscriptenTemp();
        HTML5SDKInfo.SetUpEmscriptenConfigFile();

        string PackagePath = Path.Combine(Path.GetDirectoryName(Params.RawProjectPath.FullName), "Binaries", "HTML5");

        if (!Directory.Exists(PackagePath))
        {
            Directory.CreateDirectory(PackagePath);
        }
        string FinalDataLocation = Path.Combine(PackagePath, Params.ShortProjectName) + ".data";

        var ConfigCache = new UnrealBuildTool.ConfigCacheIni(UnrealTargetPlatform.HTML5, "Engine", Path.GetDirectoryName(Params.RawProjectPath.FullName), CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Engine"));

        if (HTMLPakAutomation.CanCreateMapPaks(Params))
        {
            HTMLPakAutomation PakAutomation = new HTMLPakAutomation(Params, SC);

            // Create Necessary Paks.
            PakAutomation.CreateEnginePak();
            PakAutomation.CreateGamePak();
            PakAutomation.CreateContentDirectoryPak();

            // Create Emscripten Package from Necessary Paks. - This will be the VFS.
            PakAutomation.CreateEmscriptenDataPackage(PackagePath, FinalDataLocation);

            // Create All Map Paks which  will be downloaded on the fly.
            PakAutomation.CreateMapPak();

            // Create Delta Paks if setup.
            List <string> Paks = new List <string>();
            ConfigCache.GetArray("/Script/HTML5PlatformEditor.HTML5TargetSettings", "LevelTransitions", out Paks);

            if (Paks != null)
            {
                foreach (var Pak in Paks)
                {
                    var    Matched = Regex.Matches(Pak, "\"[^\"]+\"", RegexOptions.IgnoreCase);
                    string MapFrom = Path.GetFileNameWithoutExtension(Matched[0].ToString().Replace("\"", ""));
                    string MapTo   = Path.GetFileNameWithoutExtension(Matched[1].ToString().Replace("\"", ""));
                    PakAutomation.CreateDeltaMapPaks(MapFrom, MapTo);
                }
            }
        }
        else
        {
            // we need to operate in the root
            string PythonPath   = HTML5SDKInfo.Python();
            string PackagerPath = HTML5SDKInfo.EmscriptenPackager();

            using (new ScopedEnvVar("EM_CONFIG", HTML5SDKInfo.DOT_EMSCRIPTEN))
            {
                using (new PushedDirectory(Path.Combine(Params.BaseStageDirectory, "HTML5")))
                {
                    string CmdLine = string.Format("\"{0}\" \"{1}\" --preload . --js-output=\"{1}.js\"", PackagerPath, FinalDataLocation);
                    RunAndLog(CmdEnv, PythonPath, CmdLine);
                }
            }
        }

        // copy the "Executable" to the package directory
        string GameExe = Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename);

        if (Params.ClientConfigsToBuild[0].ToString() != "Development")
        {
            GameExe += "-HTML5-" + Params.ClientConfigsToBuild[0].ToString();
        }
        GameExe += ".js";

        // ensure the ue4game binary exists, if applicable
        string FullGameExePath = Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe);

        if (!SC.IsCodeBasedProject && !FileExists_NoExceptions(FullGameExePath))
        {
            Log("Failed to find game application " + FullGameExePath);
            throw new AutomationException(ExitCode.Error_MissingExecutable, "Stage Failed. Could not find application {0}. You may need to build the UE4 project with your target configuration and platform.", FullGameExePath);
        }

        if (Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) != Path.Combine(PackagePath, GameExe))
        {
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe), Path.Combine(PackagePath, GameExe), true);
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) + ".mem", Path.Combine(PackagePath, GameExe) + ".mem", true);
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) + ".symbols", Path.Combine(PackagePath, GameExe) + ".symbols", true);
        }

        File.SetAttributes(Path.Combine(PackagePath, GameExe), FileAttributes.Normal);
        File.SetAttributes(Path.Combine(PackagePath, GameExe) + ".mem", FileAttributes.Normal);
        File.SetAttributes(Path.Combine(PackagePath, GameExe) + ".symbols", FileAttributes.Normal);


        // put the HTML file to the package directory
        string TemplateFileName = "GameX.html.template";
        string TemplateFile     = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5", TemplateFileName);
        string OutputFile       = Path.Combine(PackagePath, (Params.ClientConfigsToBuild[0].ToString() != "Development" ? (Params.ShortProjectName + "-HTML5-" + Params.ClientConfigsToBuild[0].ToString()) : Params.ShortProjectName)) + ".html";

        // find Heap Size.
        ulong HeapSize;

        int ConfigHeapSize = 0;
        // Valuer set by Editor UI
        var bGotHeapSize = ConfigCache.GetInt32("/Script/HTML5PlatformEditor.HTML5TargetSettings", "HeapSize" + Params.ClientConfigsToBuild[0].ToString(), out ConfigHeapSize);

        // Fallback if the previous method failed
        if (!bGotHeapSize && !ConfigCache.GetInt32("/Script/BuildSettings.BuildSettings", "HeapSize" + Params.ClientConfigsToBuild[0].ToString(), out ConfigHeapSize))         // in Megs.
        {
            // we couldn't find a per config heap size, look for a common one.
            if (!ConfigCache.GetInt32("/Script/BuildSettings.BuildSettings", "HeapSize", out ConfigHeapSize))
            {
                ConfigHeapSize = Params.IsCodeBasedProject ? 1024 : 512;
                Log("Could not find Heap Size setting in .ini for Client config {0}", Params.ClientConfigsToBuild[0].ToString());
            }
        }

        HeapSize = (ulong)ConfigHeapSize * 1024L * 1024L;         // convert to bytes.
        Log("Setting Heap size to {0} Mb ", ConfigHeapSize);


        GenerateFileFromTemplate(TemplateFile, OutputFile, Params.ShortProjectName, Params.ClientConfigsToBuild[0].ToString(), Params.StageCommandline, !Params.IsCodeBasedProject, HeapSize);

        string MacBashTemplateFile = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5", "RunMacHTML5LaunchHelper.command.template");
        string MacBashOutputFile   = Path.Combine(PackagePath, "RunMacHTML5LaunchHelper.command");
        string MonoPath            = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "BatchFiles", "Mac", "SetupMono.sh");

        GenerateMacCommandFromTemplate(MacBashTemplateFile, MacBashOutputFile, MonoPath);

        string htaccessTemplate = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5", "htaccess.template");
        string htaccesspath     = Path.Combine(PackagePath, ".htaccess");

        if (File.Exists(htaccesspath))
        {
            FileAttributes attributes = File.GetAttributes(htaccesspath);
            if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
            {
                attributes &= ~FileAttributes.ReadOnly;
                File.SetAttributes(htaccesspath, attributes);
            }
        }
        File.Copy(htaccessTemplate, htaccesspath, true);

        string JSDir  = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5");
        string OutDir = PackagePath;

        // Gather utlity .js files and combine into one file
        string[] UtilityJavaScriptFiles = Directory.GetFiles(JSDir, "*.js");

        string DestinationFile = OutDir + "/Utility.js";

        File.Delete(DestinationFile);
        foreach (var UtilityFile in UtilityJavaScriptFiles)
        {
            string Data = File.ReadAllText(UtilityFile);
            File.AppendAllText(DestinationFile, Data);
        }

        // Compress all files. These are independent tasks which can be threaded.
        Task[] CompressionTasks = new Task[6];
        //data file.
        CompressionTasks[0] = Task.Factory.StartNew(() => CompressFile(FinalDataLocation, FinalDataLocation + "gz"));
        // data file .js driver.
        CompressionTasks[1] = Task.Factory.StartNew(() => CompressFile(FinalDataLocation + ".js", FinalDataLocation + ".jsgz"));
        // main js.
        CompressionTasks[2] = Task.Factory.StartNew(() => CompressFile(Path.Combine(PackagePath, GameExe), Path.Combine(PackagePath, GameExe) + "gz"));
        // mem init file.
        CompressionTasks[3] = Task.Factory.StartNew(() => CompressFile(Path.Combine(PackagePath, GameExe) + ".mem", Path.Combine(PackagePath, GameExe) + ".memgz"));
        // symbols file.
        CompressionTasks[4] = Task.Factory.StartNew(() => CompressFile(Path.Combine(PackagePath, GameExe) + ".symbols", Path.Combine(PackagePath, GameExe) + ".symbolsgz"));
        // Utility
        CompressionTasks[5] = Task.Factory.StartNew(() => CompressFile(OutDir + "/Utility.js", OutDir + "/Utility.jsgz"));

        File.Copy(CombinePaths(CmdEnv.LocalRoot, "Engine/Binaries/DotNET/HTML5LaunchHelper.exe"), CombinePaths(OutDir, "HTML5LaunchHelper.exe"), true);
        Task.WaitAll(CompressionTasks);
        PrintRunTime();
    }
예제 #7
0
        private void DownloadLatestPOFile(XLocApiClient XLocApiClient, string AuthToken, string Culture, ProjectImportExportInfo ProjectImportInfo, int XLocDownloadedPOChangeList)
        {
            var XLocFilename = GetXLocFilename(ProjectImportInfo.PortableObjectName);

            // This will throw if the requested culture is invalid, but we don't want to let that kill the whole gather
            var LatestBuildXml = "";

            try
            {
                var EpicCultureToXLocLanguageId = GetEpicCultureToXLocLanguageId();
                LatestBuildXml = RequestLatestBuild(XLocApiClient, AuthToken, EpicCultureToXLocLanguageId[Culture]);
            }
            catch (Exception Ex)
            {
                BuildCommand.LogWarning("RequestLatestBuild failed for {0}. {1}", Culture, Ex);
                return;
            }

            var POFileUri    = "";
            var BuildsXmlDoc = new XmlDocument();

            BuildsXmlDoc.LoadXml(LatestBuildXml);

            var BuildElem = BuildsXmlDoc["Build"];

            if (BuildElem != null)
            {
                var BuildFilesElem = BuildElem["BuildFiles"];
                if (BuildFilesElem != null)
                {
                    foreach (XmlNode BuildFile in BuildFilesElem)
                    {
                        bool IsCorrectFile = false;

                        // Is this the file we want?
                        var GameFileElem = BuildFile["GameFile"];
                        if (GameFileElem != null)
                        {
                            var GameFileNameElem = GameFileElem["Name"];
                            if (GameFileNameElem != null && GameFileNameElem.InnerText == XLocFilename)
                            {
                                IsCorrectFile = true;
                            }
                        }

                        if (IsCorrectFile)
                        {
                            var BuildFileDownloadUriElem = BuildFile["DownloadUri"];
                            if (BuildFileDownloadUriElem != null)
                            {
                                POFileUri = BuildFileDownloadUriElem.InnerText;
                                break;
                            }
                        }
                    }
                }
            }

            if (!String.IsNullOrEmpty(POFileUri))
            {
                var DestinationDirectory = new DirectoryInfo(CommandUtils.CombinePaths(RootWorkingDirectory, ProjectImportInfo.DestinationPath));
                var CultureDirectory     = (ProjectImportInfo.bUseCultureDirectory) ? new DirectoryInfo(Path.Combine(DestinationDirectory.FullName, Culture)) : DestinationDirectory;
                if (!CultureDirectory.Exists)
                {
                    CultureDirectory.Create();
                }

                var HTTPRequest = WebRequest.Create(POFileUri);
                HTTPRequest.Method = "GET";
                using (var Response = (HttpWebResponse)XLocUtils.GetWebResponse(HTTPRequest))
                {
                    if (Response.StatusCode != HttpStatusCode.OK)
                    {
                        BuildCommand.LogWarning("HTTP Request to '{0}' failed. {1}", POFileUri, Response.StatusDescription);
                        return;
                    }

                    using (var ResponseStream = Response.GetResponseStream())
                    {
                        var ExportFile = new FileInfo(Path.Combine(CultureDirectory.FullName, ProjectImportInfo.PortableObjectName));

                        // Write out the updated PO file so that the gather commandlet will import the new data from it
                        {
                            var ExportFileWasReadOnly = false;
                            if (ExportFile.Exists)
                            {
                                // We're going to clobber the existing PO file, so make sure it's writable (it may be read-only if in Perforce)
                                ExportFileWasReadOnly = ExportFile.IsReadOnly;
                                ExportFile.IsReadOnly = false;
                            }

                            using (var FileStream = ExportFile.Open(FileMode.Create))
                            {
                                ResponseStream.CopyTo(FileStream);
                                Console.WriteLine("[SUCCESS] Exporting: '{0}' as '{1}' ({2})", XLocFilename, ExportFile.FullName, Culture);
                            }

                            if (ExportFileWasReadOnly)
                            {
                                ExportFile.IsReadOnly = true;
                            }
                        }

                        // Also update the back-up copy so we can diff against what we got from XLoc, and what the gather commandlet produced
                        {
                            var ExportFileCopy = new FileInfo(Path.Combine(ExportFile.DirectoryName, String.Format("{0}_FromXLoc{1}", Path.GetFileNameWithoutExtension(ExportFile.Name), ExportFile.Extension)));

                            var ExportFileCopyWasReadOnly = false;
                            if (ExportFileCopy.Exists)
                            {
                                // We're going to clobber the existing PO file, so make sure it's writable (it may be read-only if in Perforce)
                                ExportFileCopyWasReadOnly = ExportFileCopy.IsReadOnly;
                                ExportFileCopy.IsReadOnly = false;
                            }

                            ExportFile.CopyTo(ExportFileCopy.FullName, true);

                            if (ExportFileCopyWasReadOnly)
                            {
                                ExportFileCopy.IsReadOnly = true;
                            }

                            // Add/check out backed up POs from OneSky.
                            if (CommandUtils.P4Enabled)
                            {
                                UE4Build.AddBuildProductsToChangelist(XLocDownloadedPOChangeList, new List <string>()
                                {
                                    ExportFileCopy.FullName
                                });
                            }
                        }
                    }
                }
            }
        }
    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[] 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";
                }
                // 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)
                {
                    string GeneratedPluginName      = "NativizedScript";
                    string ProjectDir               = Params.RawProjectPath.Directory.ToString();
                    string GeneratedPluginDirectory = Path.GetFullPath(CommandUtils.CombinePaths(ProjectDir, "Intermediate", "Plugins", GeneratedPluginName));
                    string PluginDescFilename       = GeneratedPluginName + ".uplugin";
                    string GeneratedPluginPath      = Path.GetFullPath(CommandUtils.CombinePaths(GeneratedPluginDirectory, PluginDescFilename));

                    CommandletParams += " -NativizeAssets -NativizedAssetPlugin=\"" + GeneratedPluginPath + "\"";

                    // fill out this, so as to coordinate with build automation
                    // (the builder now needs to compile in the generated assets)
                    Params.NativizedScriptPlugin = 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, 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);
                    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 **********");
    }
예제 #9
0
    public List <ISharedCookedBuild> FindBestBuilds()
    {
        // Attempt manifest searching first
        ConfigHierarchy Hierarchy = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(ProjectFile), UnrealTargetPlatform.Win64);

        IEnumerable <string> RawSharedCookedSources = null;

        Hierarchy.TryGetValues("SharedCookedBuildSettings", "SharedCookedSources", out RawSharedCookedSources);
        if (RawSharedCookedSources == null)
        {
            throw new AutomationException("Unable to locate shared cooked builds. SharedCookedSources not set in Engine.ini [SharedCookedBuildSettings]");
        }

        List <Dictionary <string, string> > ParsedSharedCookSources = new List <Dictionary <string, string> >();

        foreach (string RawConfig in RawSharedCookedSources)
        {
            Dictionary <string, string> ParsedSource = null;
            if (ConfigHierarchy.TryParse(RawConfig, out ParsedSource))
            {
                ParsedSharedCookSources.Add(ParsedSource);
            }
        }

        List <ISharedCookedBuild> CandidateBuilds = new List <ISharedCookedBuild>();

        // If existing sync is present, stick to it. Read version out of sync file
        foreach (string Platform in TargetPlatforms)
        {
            FileReference SyncedBuildFile = new FileReference(CommandUtils.CombinePaths(InstallPath.FullName, Platform, SyncedBuildFileName));
            if (FileReference.Exists(SyncedBuildFile))
            {
                string[] SyncedBuildInfo = FileReference.ReadAllLines(SyncedBuildFile);
                int      SyncedCL        = int.Parse(SyncedBuildInfo[0]);
                if (IsValidCL(SyncedCL, BuildType, LocalSync))
                {
                    CandidateBuilds.Add(new ExistingSharedCookedBuild()
                    {
                        CL = SyncedCL, Platform = Platform
                    });
                }
            }
        }

        foreach (Dictionary <string, string> Source in ParsedSharedCookSources)
        {
            SharedCookSource SourceType = (SharedCookSource)Enum.Parse(typeof(SharedCookSource), Source["Type"], true);
            foreach (string Platform in TargetPlatforms)
            {
                if (SourceType == SharedCookSource.Manifest)
                {
                    CandidateBuilds.AddRange(FindValidManifestBuilds(Source["Path"], Platform));
                }
                else if (SourceType == SharedCookSource.LooseFiles)
                {
                    CandidateBuilds.AddRange(FindValidLooseBuilds(Source["Path"], Platform));
                }
            }
        }

        // Strip all failed searches
        CandidateBuilds.RemoveAll(x => x == null);

        // Make sure we have a matching CL for all target platforms, regardless of source
        List <int> OrderedDistinctCLs = CandidateBuilds.Select(x => x.CL).Distinct().OrderByDescending(i => i).ToList();
        int        BestCL             = -1;

        foreach (int CL in OrderedDistinctCLs)
        {
            // Ensure we have a platform for each
            HashSet <string> CLPlatforms = new HashSet <string>(CandidateBuilds.Where(x => x.CL == CL).Select(x => x.Platform).ToList());
            if (CLPlatforms.SetEquals(TargetPlatforms))
            {
                BestCL = CL;
                break;
            }
        }

        if (BestCL < 0)
        {
            CommandUtils.LogError("Could not locate valid shared cooked build for all target platforms");
            CommandUtils.LogError("Current CL: {0}, Current Code CL: {1}", LocalSync.Changelist, LocalSync.CompatibleChangelist);
        }

        return(CandidateBuilds.Where(x => x.CL == BestCL).ToList());
    }
예제 #10
0
    public void StageFile(StagedFileType FileType, string InputPath, string OutputPath = null, bool bRemap = true)
    {
        InputPath = InputPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

        if (OutputPath == null)
        {
            if (InputPath.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase))
            {
                OutputPath = CommandUtils.CombinePaths(RelativeProjectRootForStage, InputPath.Substring(ProjectRoot.Length).TrimStart('/', '\\'));
            }
            else if (InputPath.EndsWith(".uplugin", StringComparison.InvariantCultureIgnoreCase))
            {
                if (InputPath.StartsWith(CommandUtils.CombinePaths(LocalRoot + "/Engine"), StringComparison.InvariantCultureIgnoreCase))
                {
                    OutputPath = CommandUtils.CombinePaths(InputPath.Substring(LocalRoot.Length).TrimStart('/', '\\'));
                }
                else
                {
                    // This is a plugin that lives outside of the Engine/Plugins or Game/Plugins directory so needs to be remapped for staging/packaging
                    // We need to remap C:\SomePath\PluginName\PluginName.uplugin to RemappedPlugins\PluginName\PluginName.uplugin
                    int Index = InputPath.LastIndexOf(Path.DirectorySeparatorChar);
                    if (Index != -1)
                    {
                        int PluginDirIndex = InputPath.LastIndexOf(Path.DirectorySeparatorChar, Index - 1);
                        if (PluginDirIndex != -1)
                        {
                            OutputPath = CommandUtils.CombinePaths("RemappedPlugins", InputPath.Substring(PluginDirIndex));
                        }
                    }
                    if (OutputPath == null)
                    {
                        throw new AutomationException("Can't deploy {0} because the plugin path is non-standard, so could not be remapped", InputPath);
                    }
                }
            }
            else if (InputPath.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase))
            {
                OutputPath = CommandUtils.CombinePaths(InputPath.Substring(LocalRoot.Length).TrimStart('/', '\\'));
            }
            else
            {
                throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputPath, ProjectRoot, LocalRoot);
            }
        }

        if (bRemap)
        {
            OutputPath = StageTargetPlatform.Remap(OutputPath);
        }

        if (FileType == StagedFileType.UFS)
        {
            AddUniqueStagingFile(UFSStagingFiles, InputPath, OutputPath);
        }
        else if (FileType == StagedFileType.NonUFS)
        {
            AddStagingFile(NonUFSStagingFiles, InputPath, OutputPath);
        }
        else if (FileType == StagedFileType.DebugNonUFS)
        {
            AddStagingFile(NonUFSStagingFilesDebug, InputPath, OutputPath);
        }
    }
예제 #11
0
    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);
    }
예제 #12
0
    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.");
        }

        // Hairworks DLL
        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Hairworks"), "*.", true);

        // WaveWorks DLL
        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/WaveWorks"), "*.", true);

        // NVCHANGE_BEGIN: Add VXGI
        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/GameWorks/VXGI"), "*.", true);
        // NVCHANGE_END: Add VXGI

        // NVCHANGE_BEGIN: Add HBAO+
        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/GameWorks/GFSDK_SSAO"), "*.", true);
        // NVCHANGE_END: Add HBAO+

        // Stage all the build products
        foreach (BuildReceipt 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 (BuildReceipt 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);
                    }
                }
            }
        }
    }
예제 #13
0
    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.");
        }

        //todo we need to support shipping and test executables
        //todo this should all be partially based on UBT manifests and not hard coded
        //monolithic assumption
        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Ogg", SC.PlatformDir), "*.", true);
        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Vorbis", SC.PlatformDir), "*.", true);
        string PhysXVer = "VS" + WindowsPlatform.GetVisualStudioCompilerVersionName();
        string ApexVer  = "VS" + WindowsPlatform.GetVisualStudioCompilerVersionName();
        string PhysXMaskForDebugConfiguration = Params.bDebugBuildsActuallyUseDebugCRT ? "*DEBUG*.*" : "*PROFILE*.*";

        if (SC.StageTargetConfigurations.Contains(UnrealTargetConfiguration.Debug) && !Params.Rocket)
        {
            StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/PhysX/APEX-1.3", SC.PlatformDir, ApexVer), PhysXMaskForDebugConfiguration, true);
            StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/PhysX/PhysX-3.3", SC.PlatformDir, PhysXVer), PhysXMaskForDebugConfiguration, true);
            StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/PhysX/PhysX-3.3", SC.PlatformDir, PhysXVer), "nvToolsExt*.", true);
        }
        if (SC.StageTargetConfigurations.Any(x => x != UnrealTargetConfiguration.Debug) || Params.Rocket)
        {
            StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/PhysX/APEX-1.3", SC.PlatformDir, ApexVer), "*.", true, new string[] { "*DEBUG*.*", "*CHECKED*.*" });
            StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/PhysX/PhysX-3.3", SC.PlatformDir, PhysXVer), "*.", true, new string[] { "*DEBUG*.*", "*CHECKED*.*" });
        }

        if (Params.bUsesSteam)
        {
            string SteamVersion = "Steamv130";

            // Check that the TPS directory exists. We don't distribute binaries for Steam in Rocket.
            if (Directory.Exists(CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion)))
            {
                if (SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Win32)
                {
                    StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "steam_api.");
                    if (SC.DedicatedServer)
                    {
                        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "steamclient.");
                        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "tier0_s.");
                        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "vstdlib_s.");
                    }
                }
                else
                {
                    StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "steam_api64.");
                    if (SC.DedicatedServer)
                    {
                        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "steamclient64.");
                        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "tier0_s64.");
                        StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "vstdlib_s64.");
                    }
                }
            }
        }

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

        if (Params.StageNonMonolithic)
        {
            if (SC.DedicatedServer)
            {
                StageExecutable("exe", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4Server.");
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4Server-*.");
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Plugins"), "UE4Server-*.", true);
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4Server-*.");
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.ProjectRoot, "Plugins"), "UE4Server-*.", true);

                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/ICU/icu4c-53_1", SC.PlatformDir, "VS2013"), "*.");
            }
            else
            {
                StageExecutable("exe", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4.");
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4-*.");
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Plugins"), "UE4-*.", true);
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4-*.");
                StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.ProjectRoot, "Plugins"), "UE4-*.", true);
            }
        }
        else
        {
            List <string> Exes = GetExecutableNames(SC);

            // the first exe is the "main" one, the rest are marked as debug files
            StagedFileType WorkingFileType = StagedFileType.NonUFS;

            foreach (var Exe in Exes)
            {
                if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir)))
                {
                    // remap the project root.
                    string SourceFile = CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir, Path.GetFileName(Exe));
                    StageExecutable("exe", SC, Path.GetDirectoryName(SourceFile), Path.GetFileNameWithoutExtension(SourceFile) + ".", true, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false, WorkingFileType);
                    if (Exe == Exes[0] && !Params.NoBootstrapExe)
                    {
                        StageBootstrapExecutable(SC, SourceFile, CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir, Path.GetFileName(Exe)), "");
                    }
                }
                else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir)))
                {
                    // keep it in the engine directory.
                    string SourceFile = CombinePaths(SC.LocalRoot, "Engine", "Binaries", SC.PlatformDir, Path.GetFileName(Exe));
                    StageExecutable("exe", SC, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(SourceFile) + ".", true, null, null, false, WorkingFileType);
                    if (Exe == Exes[0] && !Params.NoBootstrapExe)
                    {
                        StageBootstrapExecutable(SC, SourceFile, CombinePaths("Engine", "Binaries", SC.PlatformDir, Path.GetFileName(Exe)), String.Format("..\\..\\..\\{0}\\{0}.uproject", SC.ShortProjectName));
                    }
                }
                else
                {
                    throw new AutomationException("Can't stage the exe {0} because it doesn't start with {1} or {2}", Exe, CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir), CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir));
                }
                // the first exe is the "main" one, the rest are marked as debug files
                WorkingFileType = StagedFileType.DebugNonUFS;
            }
        }
    }
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        if (SC.bStageCrashReporter)
        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "CrashReportClient", false);
        }

        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/ICU/icu4c-53_1/", SC.PlatformDir, "x86_64-unknown-linux-gnu"), Params.bDebugBuildsActuallyUseDebugCRT ? "*d.so*" : "*.so*", false, new[] { Params.bDebugBuildsActuallyUseDebugCRT ? "*.so*" : "*d.so*" }, CombinePaths("Engine/Binaries", SC.PlatformDir));
        }

        // assume that we always have to deploy Steam (FIXME: should be automatic)
        {
            string SteamVersion = "Steamv130";

            // Check if the Steam directory exists. We need it for Steam controller support, so we include it whenever we can.
            if (Directory.Exists(CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion)))
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "libsteam_api.so", false, null, CombinePaths("Engine/Binaries", SC.PlatformDir));
            }

            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Config"), "controller.vdf", false, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Saved/Config"));
            // copy optional perfcounters definition file
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Config"), "PerfCounters.json", false, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Saved/Config"), true);
        }

        // assume that we always have to deploy OpenAL (FIXME: should be automatic)
        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/OpenAL/", SC.PlatformDir), "libopenal.so.1", false, null, CombinePaths("Engine/Binaries", SC.PlatformDir));
        }

        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true);
        SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Content/Localization/ICU"), "*", true, null, null, false, !Params.UsePak(SC.StageTargetPlatform));


        if (Params.StageNonMonolithic)
        {
            if (SC.DedicatedServer)
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4Server");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "libUE4Server-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "libUE4Server-*.so", true, null, null, true);
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "libUE4Server-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Plugins"), "libUE4Server-*.so", true, null, null, true);
            }
            else
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "libUE4-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "libUE4-*.so", true, null, null, true);
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "libUE4-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Plugins"), "libUE4-*.so", true, null, null, true);
            }
        }
        else
        {
            List <string> Exes = GetExecutableNames(SC);

            foreach (var Exe in Exes)
            {
                if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir)))
                {
                    // remap the project root. For content-only projects, rename the executable to the project name.
                    if (!Params.IsCodeBasedProject && Exe == Exes[0])
                    {
                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false, true, SC.ShortProjectName);
                    }
                    else
                    {
                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false);
                    }
                }
                else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir)))
                {
                    // Move the executable for content-only projects into the project directory, using the project name, so it can figure out the UProject to look for and is consistent with code projects.
                    if (!Params.IsCodeBasedProject && Exe == Exes[0])
                    {
                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false, true, SC.ShortProjectName);
                    }
                    else
                    {
                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, null, false);
                    }
                }
                else
                {
                    throw new AutomationException("Can't stage the exe {0} because it doesn't start with {1} or {2}", Exe, CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir), CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir));
                }
            }
        }
    }
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        // FIXME: use build architecture
        string BuildArchitecture = "x86_64-unknown-linux-gnu";

        if (SC.bStageCrashReporter)
        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "CrashReportClient", false, null, null, true);
        }

        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/ICU/icu4c-53_1/", SC.PlatformDir, BuildArchitecture), Params.bDebugBuildsActuallyUseDebugCRT ? "*d.so*" : "*.so*", false, new[] { Params.bDebugBuildsActuallyUseDebugCRT ? "*.so*" : "*d.so*" }, CombinePaths("Engine/Binaries", SC.PlatformDir));
        }

        // assume that we always have to deploy Steam (FIXME: should be automatic - UEPLAT-807)
        {
            string SteamVersion = "Steamv132";

            // Check if the Steam directory exists. We need it for Steam controller support, so we include it whenever we can.
            if (Directory.Exists(CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion)))
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/Steamworks/" + SteamVersion, SC.PlatformDir), "libsteam_api.so", false, null, CombinePaths("Engine/Binaries", SC.PlatformDir));
            }

            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Config"), "controller.vdf", false, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Saved/Config"));
            // copy optional perfcounters definition file
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Config"), "PerfCounters.json", false, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Saved/Config"), true);
        }

        // stage libLND (omit it for dedservers and Rocket - proper resolution is to use build receipts, see UEPLAT-807)
        if (!SC.DedicatedServer && !GlobalCommandLine.Rocket)
        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/LinuxNativeDialogs/", SC.PlatformDir, BuildArchitecture), "libLND*.so");
        }

        // assume that we always have to deploy OpenAL (FIXME: should be automatic - UEPLAT-807)
        {
            SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/OpenAL/", SC.PlatformDir), "libopenal.so.1", false, null, CombinePaths("Engine/Binaries", SC.PlatformDir));
        }

        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true);

        if (Params.StageNonMonolithic)
        {
            if (SC.DedicatedServer)
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4Server*");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "libUE4Server-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "libUE4Server-*.so", true, null, null, true);
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "libUE4Server-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Plugins"), "libUE4Server-*.so", true, null, null, true);
            }
            else
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "UE4*");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), "libUE4-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "libUE4-*.so", true, null, null, true);
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "libUE4-*.so");
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Plugins"), "libUE4-*.so", true, null, null, true);
            }
        }
        else
        {
            List <string> Exes = GetExecutableNames(SC);

            foreach (var Exe in Exes)
            {
                if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir)))
                {
                    // remap the project root. For content-only projects, rename the executable to the project name.
                    if (!Params.IsCodeBasedProject && Exe == Exes[0])
                    {
                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false, true, SC.ShortProjectName);
                    }
                    else
                    {
                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false);
                    }
                }
                else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir)))
                {
                    // Move the executable for content-only projects into the project directory, using the project name, so it can figure out the UProject to look for and is consistent with code projects.
                    if (!Params.IsCodeBasedProject && Exe == Exes[0])
                    {
                        // ensure the ue4game binary exists, if applicable
                        if (!SC.IsCodeBasedProject && !FileExists_NoExceptions(Params.ProjectGameExeFilename) && !SC.bIsCombiningMultiplePlatforms)
                        {
                            Log("Failed to find game binary " + Params.ProjectGameExeFilename);
                            AutomationTool.ErrorReporter.Error("Stage Failed.", (int)AutomationTool.ErrorCodes.Error_MissingExecutable);
                            throw new AutomationException("Could not find game binary {0}. You may need to build the UE4 project with your target configuration and platform.", Params.ProjectGameExeFilename);
                        }

                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, CommandUtils.CombinePaths(SC.RelativeProjectRootForStage, "Binaries", SC.PlatformDir), false, true, SC.ShortProjectName);
                    }
                    else
                    {
                        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir), Path.GetFileNameWithoutExtension(Exe), true, null, null, false);
                    }
                }
                else
                {
                    throw new AutomationException("Can't stage the exe {0} because it doesn't start with {1} or {2}", Exe, CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir), CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir));
                }
            }
        }
    }
예제 #16
0
    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 (BuildReceipt 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);


        /*foreach (string StageExePath in GetExecutableNames(SC))
         * {
         *  // set the icon on the original exe this will be used in the task bar when the bootstrap exe runs
         *  if (InternalUtils.SafeFileExists(CombinePaths(SC.ProjectRoot, "Build/Windows/Application.ico")))
         *  {
         *      GroupIconResource GroupIcon = null;
         *      GroupIcon = GroupIconResource.FromIco(CombinePaths(SC.ProjectRoot, "Build/Windows/Application.ico"));
         *
         *      // Update the icon on the original exe because this will be used when the game is running in the task bar
         *      using (ModuleResourceUpdate Update = new ModuleResourceUpdate(StageExePath, false))
         *      {
         *          const int IconResourceId = 101;
         *          if (GroupIcon != null)
         *          {
         *              Update.SetIcons(IconResourceId, GroupIcon);
         *          }
         *      }
         *  }
         * }*/

        // Stage the bootstrap executable
        if (!Params.NoBootstrapExe)
        {
            foreach (BuildReceipt 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 override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        // Engine non-ufs (binaries)

        if (SC.bStageCrashReporter)
        {
            string ReceiptFileName = TargetReceipt.GetDefaultPath(UnrealBuildTool.UnrealBuildTool.EngineDirectory.FullName, "CrashReportClient", SC.StageTargetPlatform.PlatformType, UnrealTargetConfiguration.Shipping, null);
            if (File.Exists(ReceiptFileName))
            {
                TargetReceipt Receipt = TargetReceipt.Read(ReceiptFileName);
                Receipt.ExpandPathVariables(UnrealBuildTool.UnrealBuildTool.EngineDirectory, (Params.RawProjectPath == null)? UnrealBuildTool.UnrealBuildTool.EngineDirectory : Params.RawProjectPath.Directory);
                SC.StageBuildProductsFromReceipt(Receipt, true, false);
            }
        }

        // NVCHANGE_BEGIN: Add HBAO+
        //StageExecutable("dll", SC, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/GameWorks/GFSDK_SSAO"), "*.", true);
        //SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Plugins", DLCName, "Binaries"), "UE4-*.dll", true, null, null, true);
        SC.StageFiles(StagedFileType.NonUFS, CommandUtils.CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/GameWorks/GFSDK_SSAO"), "*.dll", true);
        // NVCHANGE_END: Add HBAO+

        // Stage all the build products
        foreach (StageTarget Target in SC.StageTargets)
        {
            SC.StageBuildProductsFromReceipt(Target.Receipt, Target.RequireFilesExist, Params.bTreatNonShippingBinariesAsDebugFiles);
        }

        // 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 (StageTarget Target in SC.StageTargets)
            {
                BuildProduct Executable = Target.Receipt.BuildProducts.FirstOrDefault(x => x.Type == BuildProductType.Executable);
                if (Executable != null)
                {
                    // only create bootstraps for executables
                    string FullExecutablePath = Path.GetFullPath(Executable.Path);
                    if (SC.NonUFSStagingFiles.ContainsKey(FullExecutablePath) && Path.GetExtension(FullExecutablePath) == ".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(FullExecutablePath);
                        }
                        else if (Params.IsCodeBasedProject)
                        {
                            BootstrapExeName = Target.Receipt.TargetName + ".exe";
                        }
                        else
                        {
                            BootstrapExeName = SC.ShortProjectName + ".exe";
                        }

                        foreach (string StagePath in SC.NonUFSStagingFiles[FullExecutablePath])
                        {
                            StageBootstrapExecutable(SC, BootstrapExeName, FullExecutablePath, StagePath, BootstrapArguments);
                        }
                    }
                }
            }
        }
    }
    public override ExitCode Execute()
    {
        LogInformation("************************* SyncProject");

        // These are files that should always be synced because tools update them
        string[] ForceSyncFiles = new string[]
        {
            "Engine/Build/Build.version",
            "Engine/Source/Programs/DotNETCommon/MetaData.cs"
        };

        // Parse the project filename (as a local path)
        string ProjectArg = ParseParamValue("Project", null);

        // Parse the changelist to sync to. -1 will sync to head.
        int  CL          = ParseParamInt("CL", -1);
        int  Threads     = ParseParamInt("threads", 2);
        bool ForceSync   = ParseParam("force");
        bool PreviewOnly = ParseParam("preview");

        bool ProjectOnly = ParseParam("projectonly");

        int  Retries     = ParseParamInt("retries", 3);
        bool Unversioned = ParseParam("unversioned");

        bool BuildProject    = ParseParam("build");
        bool OpenProject     = ParseParam("open");
        bool GenerateProject = ParseParam("generate");

        string PathArg = ParseParamValue("paths", "");

        IEnumerable <string> ExplicitPaths = PathArg.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).Select(S => S.Trim());

        if (CL == 0)
        {
            if (!ForceSync)
            {
                throw new AutomationException("If using 0 CL to remove files -force must also be specified");
            }

            // Cannot unsync the engine folder
            ProjectOnly = true;
        }
        else if (CL == -1)
        {
            // find most recent change
            List <P4Connection.ChangeRecord> Records;

            string Cmd = string.Format("-s submitted -m1 //{0}/...", P4Env.Client);
            if (!P4.Changes(out Records, Cmd, false))
            {
                throw new AutomationException("p4 changes failed. Cannot find most recent CL");
            }

            CL = Records.First().CL;
        }

        bool EngineOnly = string.IsNullOrEmpty(ProjectArg);

        // Will be the full local path to the project file once resolved
        FileReference ProjectFile = null;

        // Will be the full workspace path to the project in P4 (if a project was specified)
        string P4ProjectPath = null;

        // Will be the full workspace path to the engine in P4 (If projectonly wasn't specified);
        string P4EnginePath = null;

        // If we're syncing a project find where it is in P4
        if (!EngineOnly)
        {
            ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectArg);

            if (ProjectFile != null)
            {
                // get the path in P4
                P4WhereRecord Record = P4.Where(ProjectFile.FullName, AllowSpew: false).FirstOrDefault(x => x.DepotFile != null && !x.bUnmap);
                P4ProjectPath = Record.ClientFile;
            }
            else
            {
                // if they provided a name and not a path then find the file (requires that it's synced).
                string RelativePath = ProjectArg;

                if (Path.GetExtension(RelativePath).Length == 0)
                {
                    RelativePath = Path.ChangeExtension(RelativePath, "uproject");
                }

                if (!RelativePath.Contains(Path.DirectorySeparatorChar) && !RelativePath.Contains(Path.AltDirectorySeparatorChar))
                {
                    RelativePath = CommandUtils.CombinePaths(PathSeparator.Slash, Path.GetFileNameWithoutExtension(RelativePath), RelativePath);
                }

                Log.TraceInformation("{0} not on disk. Searching P4 for {1}", ProjectArg, RelativePath);

                List <string> SearchPaths = new List <string>();
                SearchPaths.Add("");
                string ProjectDirsFile = Directory.EnumerateFiles(CommandUtils.CombinePaths(CmdEnv.LocalRoot), "*.uprojectdirs").FirstOrDefault();
                if (ProjectDirsFile != null)
                {
                    foreach (string FilePath in File.ReadAllLines(ProjectDirsFile))
                    {
                        string Trimmed = FilePath.Trim();
                        if (!Trimmed.StartsWith("./", StringComparison.OrdinalIgnoreCase) &&
                            !Trimmed.StartsWith(";", StringComparison.OrdinalIgnoreCase) &&
                            Trimmed.IndexOfAny(Path.GetInvalidPathChars()) < 0)
                        {
                            SearchPaths.Add(Trimmed);
                        }
                    }
                }

                // Get the root of the branch containing the selected file
                foreach (string SearchPath in SearchPaths)
                {
                    string P4Path = CommandUtils.CombinePaths(PathSeparator.Slash, P4Env.ClientRoot, SearchPath, RelativePath);

                    if (P4.FileExistsInDepot(P4Path))
                    {
                        P4WhereRecord Record = P4.Where(P4Path, AllowSpew: false).FirstOrDefault(x => x.DepotFile != null && !x.bUnmap);
                        // make sure to sync with //workspace/path as it cleans up files if the user has stream switched
                        P4ProjectPath = Record.ClientFile;
                        Log.TraceInformation("Found project at {0}", P4ProjectPath);
                        break;
                    }
                }
            }

            if (string.IsNullOrEmpty(P4ProjectPath))
            {
                throw new AutomationException("Could not find project file for {0} locally or in P4. Provide a full path or check the subdirectory is listed in UE4Games.uprojectdirs", ProjectArg);
            }

            Log.TraceVerbose("Resolved {0} to P4 Path {1}", ProjectArg, P4ProjectPath);
        }

        // Build the list of paths that need syncing
        List <string> SyncPaths = new List <string>();


        //
        if (ExplicitPaths.Any())
        {
            // Add all explicit paths as <root>/Path/...
            ExplicitPaths.ToList().ForEach(P => SyncPaths.Add(CommandUtils.CombinePaths(PathSeparator.Slash, P4Env.ClientRoot, P, "...")));
        }
        else
        {
            // See if the engine is in P4 too by checking the p4 location of a local file
            string        LocalEngineFile = CommandUtils.CombinePaths(CmdEnv.LocalRoot, "Engine", "Source", "UE4Editor.target.cs");
            P4WhereRecord EngineRecord    = P4.Where(LocalEngineFile, AllowSpew: false).FirstOrDefault(x => x.DepotFile != null && !x.bUnmap);

            if (!ProjectOnly && P4.FileExistsInDepot(EngineRecord.DepotFile))
            {
                // make sure to sync with //workspace/path as it cleans up files if the user has stream switched
                P4EnginePath = EngineRecord.ClientFile.Replace("Engine/Source/UE4Editor.target.cs", "");
                SyncPaths.Add(CommandUtils.CombinePaths(PathSeparator.Slash, P4EnginePath + "*"));
                SyncPaths.Add(CommandUtils.CombinePaths(PathSeparator.Slash, P4EnginePath, "Engine", "..."));
            }

            if (!string.IsNullOrEmpty(P4ProjectPath))
            {
                string P4ProjectDir = Regex.Replace(P4ProjectPath, @"[^/]+\.uproject", "...", RegexOptions.IgnoreCase);
                SyncPaths.Add(P4ProjectDir);
            }
        }

        // Force these files as they can be overwritten by tools
        if (!PreviewOnly && !string.IsNullOrEmpty(P4EnginePath) && !ProjectOnly)
        {
            IEnumerable <string> ForceSyncList = ForceSyncFiles.Select(F => CommandUtils.CombinePaths(PathSeparator.Slash, P4EnginePath, F));

            foreach (var F in ForceSyncList)
            {
                LogInformation("Force-updating {0}", F);

                string SyncCommand = string.Format("-f {0}@{1}", F, CL);

                // sync with retries
                P4.Sync(SyncCommand, true, false, Retries);
            }
        }

        // Sync all the things
        foreach (string SyncPath in SyncPaths)
        {
            string SyncCommand = "";

            if (Threads > 1)
            {
                SyncCommand = string.Format(" --parallel \"threads={0}\" {1}", Threads, SyncCommand);
            }

            if (ForceSync)
            {
                SyncCommand = SyncCommand + " -f";
            }

            SyncCommand += string.Format(" {0}@{1}", SyncPath, CL);

            if (!PreviewOnly)
            {
                // sync with retries
                P4.Sync(SyncCommand, true, false, Retries);
            }
            else
            {
                LogInformation("sync {0}", SyncCommand);
            }
        }

        // P4 utils don't return errors :(
        ExitCode ExitStatus = ExitCode.Success;

        // Sync is complete so do the actions
        if (!PreviewOnly && CL > 0)
        {
            // Argument to pass to the editor (could be null with no project).
            string ProjectArgForEditor = "";

            if (!string.IsNullOrEmpty(ProjectArg))
            {
                // If we synced the project from P4 we couldn't resolve this earlier
                if (ProjectFile == null)
                {
                    NativeProjects.ClearCache();
                    ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectArg);
                }

                ProjectArgForEditor = ProjectFile.FullName;
            }

            if (GenerateProject)
            {
                Log.TraceVerbose("Generating project files for {0}", ProjectArgForEditor);

                if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64 ||
                    BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win32)
                {
                    CommandUtils.Run("GenerateProjectFiles.bat", ProjectArgForEditor);
                }
                else
                {
                    CommandUtils.Run("GenerateProjectFiles.sh", ProjectArgForEditor);
                }
            }

            UE4Build Build = new UE4Build(this);
            if (!Unversioned && !ProjectOnly)
            {
                Build.UpdateVersionFiles(ActuallyUpdateVersionFiles: true, ChangelistNumberOverride: CL, IsPromotedOverride: false);
            }

            // Build everything
            if (BuildProject && ExitStatus == ExitCode.Success)
            {
                Log.TraceVerbose("Building Editor for {0}", ProjectArgForEditor);

                BuildEditor BuildCmd = new BuildEditor();
                BuildCmd.Clean       = ParseParam("clean");
                BuildCmd.ProjectName = ProjectArgForEditor;
                ExitStatus           = BuildCmd.Execute();
            }

            if (OpenProject && ExitStatus == ExitCode.Success)
            {
                Log.TraceVerbose("Opening Editor for {0}", ProjectArgForEditor);

                OpenEditor OpenCmd = new OpenEditor();
                OpenCmd.ProjectName = ProjectArgForEditor;
                ExitStatus          = OpenCmd.Execute();
            }
        }

        return(ExitCode.Success);
    }
    public static UE4Build.BuildAgenda MakeAgenda(UnrealBuildTool.UnrealTargetPlatform[] Platforms, List <string> ExtraBuildProducts)
    {
        // Create the build agenda
        UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();

        // C# binaries
        Agenda.SwarmAgentProject       = @"Engine\Source\Programs\UnrealSwarm\SwarmAgent.sln";
        Agenda.SwarmCoordinatorProject = @"Engine\Source\Programs\UnrealSwarm\SwarmCoordinator.sln";
        Agenda.DotNetProjects.Add(@"Engine/Source/Editor/SwarmInterface/DotNET/SwarmInterface.csproj");
        Agenda.DotNetProjects.Add(@"Engine/Source/Programs/DotNETCommon/DotNETUtilities/DotNETUtilities.csproj");
        Agenda.DotNetProjects.Add(@"Engine/Source/Programs/UnrealControls/UnrealControls.csproj");

        // Windows binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.Win64))
        {
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealHeaderTool", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealPak", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealLightmass", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealVersionSelector", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
            Agenda.AddTarget("BootstrapPackagedGame", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
            Agenda.AddTarget("BootstrapPackagedGame", UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Win64, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetConfiguration.Development);
        }

        // Mac binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.Mac))
        {
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UnrealPak", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UnrealLightmass", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("ShaderCompileWorker", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UE4EditorServices", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Mac, UnrealBuildTool.UnrealTargetConfiguration.Development, InAddArgs: "-CopyAppBundleBackToDevice");
        }

        // Linux binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.Linux))
        {
            Agenda.AddTarget("CrashReportClient", UnrealBuildTool.UnrealTargetPlatform.Linux, UnrealBuildTool.UnrealTargetConfiguration.Development);
            Agenda.AddTarget("UnrealCEFSubProcess", UnrealBuildTool.UnrealTargetPlatform.Linux, UnrealBuildTool.UnrealTargetConfiguration.Development);
        }

        // iOS binaries
        if (Platforms.Contains(UnrealBuildTool.UnrealTargetPlatform.IOS))
        {
            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/iPhonePackager/iPhonePackager.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/iPhonePackager.exe"));

            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/DeploymentServer/DeploymentServer.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/DeploymentServer.exe"));

            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/DeploymentInterface/DeploymentInterface.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/DeploymentInterface.dll"));

            Agenda.DotNetProjects.Add(@"Engine/Source/Programs/iOS/MobileDeviceInterface/MobileDeviceInterface.csproj");
            ExtraBuildProducts.Add(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, @"Engine/Binaries/DotNET/iOS/MobileDeviceInterface.dll"));
        }

        // Platform extensions
        foreach (UnrealBuildTool.UnrealTargetPlatform UBTPlatform in Platforms)
        {
            AutomationTool.Platform AutomationPlatform = Platform.GetPlatform(UBTPlatform);
            AutomationPlatform.MakeAgenda(Agenda, ExtraBuildProducts);
        }

        return(Agenda);
    }
예제 #20
0
    public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
    {
        Log("Package {0}", Params.RawProjectPath);
        var EmscriptenSettings = ReadEmscriptenSettings();

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

        if (!Directory.Exists(PackagePath))
        {
            Directory.CreateDirectory(PackagePath);
        }
        string FinalDataLocation = Path.Combine(PackagePath, Params.ShortProjectName) + ".data";


        // we need to operate in the root
        using (new PushedDirectory(Path.Combine(Params.BaseStageDirectory, "HTML5")))
        {
            string BaseSDKPath = Environment.GetEnvironmentVariable("EMSCRIPTEN");
            string PythonPath  = null;

            // Check the .emscripten file for a possible python path
            if (EmscriptenSettings.ContainsKey("PYTHON"))
            {
                PythonPath = EmscriptenSettings["PYTHON"];
                Log("Found python path {0} in emscripten file", PythonPath);
            }
            // The AutoSDK defines this env var as part of its install. See setup.bat/unsetup.bat
            // If it's missing then just assume that python lives on the path
            if (PythonPath == null && Environment.GetEnvironmentVariable("PYTHON") != null)
            {
                PythonPath = Environment.GetEnvironmentVariable("PYTHON");
                Log("Found python path {0} in PYTHON Environment Variable", PythonPath);
            }

            // Check if the exe exists
            if (!System.IO.File.Exists(PythonPath))
            {
                PythonPath = null;
            }

            if (PythonPath == null)
            {
                Log("Either no python path can be found or it doesn't exist. Using python on PATH");
            }

            // make the file_packager command line
            if (Utils.IsRunningOnMono)
            {
                string PackagerPath = BaseSDKPath + "/tools/file_packager.py";
                if (PythonPath == null)
                {
                    string CmdLine = string.Format("-c \" python {0} '{1}' --preload . --js-output='{1}.js' \" ", PackagerPath, FinalDataLocation);
                    RunAndLog(CmdEnv, "/bin/bash", CmdLine);
                }
                else
                {
                    string CmdLine = string.Format("{0} '{1}' --preload . --js-output='{1}.js' ", PackagerPath, FinalDataLocation);
                    RunAndLog(CmdEnv, PythonPath, CmdLine);
                }
            }
            else
            {
                string PackagerPath = "\"" + BaseSDKPath + "\\tools\\file_packager.py\"";
                if (PythonPath == null)
                {
                    string CmdLine = string.Format("/c python {0} \"{1}\" --preload . --js-output=\"{1}.js\"", PackagerPath, FinalDataLocation);
                    RunAndLog(CmdEnv, CommandUtils.CombinePaths(Environment.SystemDirectory, "cmd.exe"), CmdLine);
                }
                else
                {
                    string CmdLine = string.Format("{0} \"{1}\" --preload . --js-output=\"{1}.js\"", PackagerPath, FinalDataLocation);
                    RunAndLog(CmdEnv, PythonPath, CmdLine);
                }
            }
        }

        // copy the "Executable" to the package directory
        string GameExe = Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename);

        if (Params.ClientConfigsToBuild[0].ToString() != "Development")
        {
            GameExe += "-HTML5-" + Params.ClientConfigsToBuild[0].ToString();
        }
        GameExe += ".js";
        if (Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) != Path.Combine(PackagePath, GameExe))
        {
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe), Path.Combine(PackagePath, GameExe), true);
            File.Copy(Path.Combine(Path.GetDirectoryName(Params.ProjectGameExeFilename), GameExe) + ".mem", Path.Combine(PackagePath, GameExe) + ".mem", true);
        }
        File.SetAttributes(Path.Combine(PackagePath, GameExe), FileAttributes.Normal);
        File.SetAttributes(Path.Combine(PackagePath, GameExe) + ".mem", FileAttributes.Normal);

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

        // find Heap Size.
        ulong HeapSize;
        var   ConfigCache = new UnrealBuildTool.ConfigCacheIni(UnrealTargetPlatform.HTML5, "Engine", Path.GetDirectoryName(Params.RawProjectPath), CombinePaths(CmdEnv.LocalRoot, "Engine"));

        int ConfigHeapSize;

        if (!ConfigCache.GetInt32("BuildSettings", "HeapSize" + Params.ClientConfigsToBuild[0].ToString(), out ConfigHeapSize))         // in Megs.
        {
            // we couldn't find a per config heap size, look for a common one.
            if (!ConfigCache.GetInt32("BuildSettings", "HeapSize", out ConfigHeapSize))
            {
                ConfigHeapSize = Params.IsCodeBasedProject ? 1024 : 512;
                Log("Could not find Heap Size setting in .ini for Client config {0}", Params.ClientConfigsToBuild[0].ToString());
            }
        }

        HeapSize = (ulong)ConfigHeapSize * 1024L * 1024L;         // convert to bytes.
        Log("Setting Heap size to {0} Mb ", ConfigHeapSize);


        GenerateFileFromTemplate(TemplateFile, OutputFile, Params.ShortProjectName, Params.ClientConfigsToBuild[0].ToString(), Params.StageCommandline, !Params.IsCodeBasedProject, HeapSize);

        // copy the jstorage files to the binaries directory
        string JSDir  = Path.Combine(CombinePaths(CmdEnv.LocalRoot, "Engine"), "Build", "HTML5");
        string OutDir = PackagePath;

        File.Copy(JSDir + "/json2.js", OutDir + "/json2.js", true);
        File.SetAttributes(OutDir + "/json2.js", FileAttributes.Normal);
        File.Copy(JSDir + "/jstorage.js", OutDir + "/jstorage.js", true);
        File.SetAttributes(OutDir + "/jstorage.js", FileAttributes.Normal);
        File.Copy(JSDir + "/moz_binarystring.js", OutDir + "/moz_binarystring.js", true);
        File.SetAttributes(OutDir + "/moz_binarystring.js", FileAttributes.Normal);
        PrintRunTime();
    }
예제 #21
0
        virtual protected bool ResolveBuildReference(string InBuildReference, Func <string, string> ResolutionDelegate, out IEnumerable <string> OutBuildPaths, out string OutBuildName)
        {
            OutBuildName  = null;
            OutBuildPaths = null;

            if (string.IsNullOrEmpty(InBuildReference))
            {
                return(false);
            }

            if (InBuildReference.Equals("AutoP4", StringComparison.InvariantCultureIgnoreCase))
            {
                if (!CommandUtils.P4Enabled)
                {
                    throw new AutomationException("-Build=AutoP4 requires -P4");
                }
                if (CommandUtils.P4Env.Changelist < 1000)
                {
                    throw new AutomationException("-Build=AutoP4 requires a CL from P4 and we have {0}", CommandUtils.P4Env.Changelist);
                }

                string BuildRoot = CommandUtils.CombinePaths(CommandUtils.RootBuildStorageDirectory());
                string CachePath = InternalUtils.GetEnvironmentVariable("UE-BuildCachePath", "");

                string SrcBuildPath  = CommandUtils.CombinePaths(BuildRoot, ProjectName);
                string SrcBuildPath2 = CommandUtils.CombinePaths(BuildRoot, ProjectName.Replace("Game", "").Replace("game", ""));

                string SrcBuildPath_Cache  = CommandUtils.CombinePaths(CachePath, ProjectName);
                string SrcBuildPath2_Cache = CommandUtils.CombinePaths(CachePath, ProjectName.Replace("Game", "").Replace("game", ""));

                if (!InternalUtils.SafeDirectoryExists(SrcBuildPath))
                {
                    if (!InternalUtils.SafeDirectoryExists(SrcBuildPath2))
                    {
                        throw new AutomationException("-Build=AutoP4: Neither {0} nor {1} exists.", SrcBuildPath, SrcBuildPath2);
                    }
                    SrcBuildPath       = SrcBuildPath2;
                    SrcBuildPath_Cache = SrcBuildPath2_Cache;
                }
                string SrcCLPath       = CommandUtils.CombinePaths(SrcBuildPath, CommandUtils.EscapePath(CommandUtils.P4Env.Branch) + "-CL-" + CommandUtils.P4Env.Changelist.ToString());
                string SrcCLPath_Cache = CommandUtils.CombinePaths(SrcBuildPath_Cache, CommandUtils.EscapePath(CommandUtils.P4Env.Branch) + "-CL-" + CommandUtils.P4Env.Changelist.ToString());
                if (!InternalUtils.SafeDirectoryExists(SrcCLPath))
                {
                    throw new AutomationException("-Build=AutoP4: {0} does not exist.", SrcCLPath);
                }

                if (InternalUtils.SafeDirectoryExists(SrcCLPath_Cache))
                {
                    InBuildReference = SrcCLPath_Cache;
                }
                else
                {
                    InBuildReference = SrcCLPath;
                }
                Log.Verbose("Using AutoP4 path {0}", InBuildReference);
            }

            // BuildParam could be a path, a name that we should resolve to a path, Staged, or Editor
            DirectoryInfo BuildDir = new DirectoryInfo(InBuildReference);

            if (BuildDir.Exists)
            {
                // Easy option first - is this a full path?
                OutBuildName  = BuildDir.Name;
                OutBuildPaths = new string[] { BuildDir.FullName };
            }
            else if (BuildDir.Name.Equals("local", StringComparison.OrdinalIgnoreCase) || BuildDir.Name.Equals("staged", StringComparison.OrdinalIgnoreCase))
            {
                // First special case - "Staged" means use whats locally staged
                OutBuildName = "Local";
                string StagedPath = Path.Combine(ProjectPath.Directory.FullName, "Saved", "StagedBuilds");

                if (Directory.Exists(StagedPath) == false)
                {
                    Log.Error("BuildReference was Staged but staged directory {0} not found", StagedPath);
                    return(false);
                }

                // include binaries path for packaged builds if it exists
                string BinariesPath = Path.Combine(ProjectPath.Directory.FullName, "Binaries");
                OutBuildPaths = Directory.Exists(BinariesPath) ? new string[] { StagedPath, BinariesPath } : new string[] { StagedPath };
            }
            else if (BuildDir.Name.Equals("editor", StringComparison.OrdinalIgnoreCase))
            {
                // Second special case - "Editor" means run using the editor, no path needed
                OutBuildName  = "Editor";
                OutBuildPaths = new string[] { Environment.CurrentDirectory };
            }
            else
            {
                // todo - make this more generic
                if (BuildDir.Name.Equals("usesyncedbuild", StringComparison.OrdinalIgnoreCase))
                {
                    BuildVersion Version;
                    if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version))
                    {
                        InBuildReference = Version.BranchName + "-CL-" + Version.Changelist.ToString();
                    }
                }

                // See if it's in the passed locations
                if (ResolutionDelegate != null)
                {
                    string FullPath = ResolutionDelegate(InBuildReference);

                    if (string.IsNullOrEmpty(FullPath) == false)
                    {
                        DirectoryInfo Di = new DirectoryInfo(FullPath);

                        if (Di.Exists == false)
                        {
                            throw new AutomationException("Resolution delegate returned non existent path");
                        }

                        OutBuildName  = Di.Name;
                        OutBuildPaths = new string[] { Di.FullName };
                    }
                }
            }

            if (string.IsNullOrEmpty(OutBuildName) || (OutBuildPaths == null || OutBuildPaths.Count() == 0))
            {
                Log.Error("Unable to resolve build argument '{0}'", InBuildReference);
                return(false);
            }

            return(true);
        }
예제 #22
0
    public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null)
    {
        int FilesAdded = 0;

        if (CommandUtils.DirectoryExists(InPath))
        {
            var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath);

            var Exclude = new HashSet <string>();
            if (ExcludeWildcard != null)
            {
                foreach (var Excl in ExcludeWildcard)
                {
                    var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath);
                    foreach (var File in Remove)
                    {
                        Exclude.Add(CommandUtils.CombinePaths(File));
                    }
                }
            }
            foreach (var AllFile in All)
            {
                var FileToCopy = CommandUtils.CombinePaths(AllFile);
                if (Exclude.Contains(FileToCopy))
                {
                    continue;
                }

                if (!bIsCombiningMultiplePlatforms)
                {
                    bool OtherPlatform = false;
                    foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
                    {
                        if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown)
                        {
                            var Search = FileToCopy;
                            if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/"))
                                {
                                    Search = Search.Substring(LocalRoot.Length - 1);
                                }
                                else
                                {
                                    Search = Search.Substring(LocalRoot.Length);
                                }
                            }
                            if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/"))
                                {
                                    Search = Search.Substring(ProjectRoot.Length - 1);
                                }
                                else
                                {
                                    Search = Search.Substring(ProjectRoot.Length);
                                }
                            }
                            if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0)
                            {
                                OtherPlatform = true;
                                break;
                            }
                        }
                    }
                    if (OtherPlatform)
                    {
                        continue;
                    }
                }

                string Dest;
                if (!FileToCopy.StartsWith(InPath))
                {
                    throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath);
                }
                Dest = FileToCopy.Substring(InPath.Length);

                if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                {
                    Dest = Dest.Substring(1);
                }

                if (ArchivedFiles.ContainsKey(FileToCopy))
                {
                    if (ArchivedFiles[FileToCopy] != Dest)
                    {
                        throw new AutomationException("Can't archive {0}: it was already in the files to archive with a different destination '{1}'", FileToCopy, Dest);
                    }
                }
                else
                {
                    ArchivedFiles.Add(FileToCopy, Dest);
                }

                FilesAdded++;
            }
        }

        return(FilesAdded);
    }
예제 #23
0
    public void StageFiles(StagedFileType FileType, string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null, bool bAllowNone = false, bool bRemap = true, string NewName = null, bool bAllowNotForLicenseesFiles = true, bool bStripFilesForOtherPlatforms = true, bool bConvertToLower = false)
    {
        int FilesAdded = 0;

        // make sure any ..'s are removed
        Utils.CollapseRelativeDirectories(ref InPath);

        if (CommandUtils.DirectoryExists(InPath))
        {
            var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath);

            var Exclude = new HashSet <string>();
            if (ExcludeWildcard != null)
            {
                foreach (var Excl in ExcludeWildcard)
                {
                    var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath);
                    foreach (var File in Remove)
                    {
                        Exclude.Add(CommandUtils.CombinePaths(File));
                    }
                }
            }
            foreach (var AllFile in All)
            {
                var FileToCopy = CommandUtils.CombinePaths(AllFile);
                if (Exclude.Contains(FileToCopy))
                {
                    continue;
                }

                if (!bAllowNotForLicenseesFiles && (FileToCopy.Contains("NotForLicensees") || FileToCopy.Contains("NoRedist")))
                {
                    continue;
                }

                if (bStripFilesForOtherPlatforms && !bIsCombiningMultiplePlatforms)
                {
                    bool OtherPlatform = false;
                    foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
                    {
                        bool bMatchesIniPlatform    = (AllFile.EndsWith(".ini") && Plat == StageTargetPlatform.IniPlatformType);                      // filter ini files for the ini file platform
                        bool bMatchesTargetPlatform = (Plat == StageTargetPlatform.PlatformType || Plat == UnrealTargetPlatform.Unknown);             // filter platform files for the target platform
                        if (!bMatchesIniPlatform && !bMatchesTargetPlatform)
                        {
                            var Search = FileToCopy;
                            if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/"))
                                {
                                    Search = Search.Substring(LocalRoot.Length - 1);
                                }
                                else
                                {
                                    Search = Search.Substring(LocalRoot.Length);
                                }
                            }
                            if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/"))
                                {
                                    Search = Search.Substring(ProjectRoot.Length - 1);
                                }
                                else
                                {
                                    Search = Search.Substring(ProjectRoot.Length);
                                }
                            }
                            if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0)
                            {
                                OtherPlatform = true;
                                break;
                            }
                        }
                    }
                    if (OtherPlatform)
                    {
                        continue;
                    }
                }

                string Dest;
                if (!FileToCopy.StartsWith(InPath))
                {
                    throw new AutomationException("Can't deploy {0}; it was supposed to start with {1}", FileToCopy, InPath);
                }
                string FileToRemap = FileToCopy;

                // If the specified a new directory, first we deal with that, then apply the other things
                // this is used to collapse the sandbox, among other things
                if (NewPath != null)
                {
                    Dest = FileToRemap.Substring(InPath.Length);
                    if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                    {
                        Dest = Dest.Substring(1);
                    }
                    Dest = CommandUtils.CombinePaths(NewPath, Dest);
#if false // if the cooker rebases, I don't think we need to ever rebase while staging to a new path
                    if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                    {
                        Dest = Dest.Substring(1);
                    }
                    // project relative stuff in a collapsed sandbox
                    if (Dest.StartsWith(SourceRelativeProjectRoot, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Dest = Dest.Substring(SourceRelativeProjectRoot.Length);
                        if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                        {
                            Dest = Dest.Substring(1);
                        }
                        Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest);
                    }
#endif
                }

                // project relative file
                else if (FileToRemap.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase))
                {
                    Dest = FileToRemap.Substring(ProjectRoot.Length);
                    if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                    {
                        Dest = Dest.Substring(1);
                    }
                    Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest);
                }
                // engine relative file
                else if (FileToRemap.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase))
                {
                    Dest = CommandUtils.CombinePaths(FileToRemap.Substring(LocalRoot.Length));
                }
                else
                {
                    throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", FileToRemap, ProjectRoot, LocalRoot);
                }

                if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                {
                    Dest = Dest.Substring(1);
                }

                if (NewName != null)
                {
                    Dest = CommandUtils.CombinePaths(Path.GetDirectoryName(Dest), NewName);
                }

                if (bRemap)
                {
                    Dest = StageTargetPlatform.Remap(Dest);
                }

                if (bConvertToLower)
                {
                    Dest = Dest.ToLowerInvariant();
                }

                if (FileType == StagedFileType.UFS)
                {
                    AddUniqueStagingFile(UFSStagingFiles, FileToCopy, Dest);
                }
                else if (FileType == StagedFileType.NonUFS)
                {
                    AddStagingFile(NonUFSStagingFiles, FileToCopy, Dest);
                }
                else if (FileType == StagedFileType.DebugNonUFS)
                {
                    AddStagingFile(NonUFSStagingFilesDebug, FileToCopy, Dest);
                }
                FilesAdded++;
            }
        }

        if (FilesAdded == 0 && !bAllowNone && !bIsCombiningMultiplePlatforms)
        {
            throw new AutomationException(ExitCode.Error_StageMissingFile, "No files found to deploy for {0} with wildcard {1} and exclusions {2}", InPath, Wildcard, ExcludeWildcard);
        }
    }
예제 #24
0
    public DeploymentContext(
        string RawProjectPathOrName,
        string InLocalRoot,
        string BaseStageDirectory,
        string BaseArchiveDirectory,
        string CookFlavor,
        Platform InSourcePlatform,
        Platform InTargetPlatform,
        List <UnrealTargetConfiguration> InTargetConfigurations,
        List <String> InStageExecutables,
        bool InServer,
        bool InCooked,
        bool InStageCrashReporter,
        bool InStage,
        bool InCookOnTheFly,
        bool InArchive,
        bool InProgram,
        bool bHasDedicatedServerAndClient
        )
    {
        bStageCrashReporter       = InStageCrashReporter;
        RawProjectPath            = RawProjectPathOrName;
        DedicatedServer           = InServer;
        LocalRoot                 = CommandUtils.CombinePaths(InLocalRoot);
        CookSourcePlatform        = InSourcePlatform;
        StageTargetPlatform       = InTargetPlatform;
        StageTargetConfigurations = new List <UnrealTargetConfiguration>(InTargetConfigurations);
        StageExecutables          = InStageExecutables;
        IsCodeBasedProject        = ProjectUtils.IsCodeBasedUProjectFile(RawProjectPath);
        ShortProjectName          = ProjectUtils.GetShortProjectName(RawProjectPath);
        Stage   = InStage;
        Archive = InArchive;

        if (CookSourcePlatform != null && InCooked)
        {
            CookPlatform = CookSourcePlatform.GetCookPlatform(DedicatedServer, bHasDedicatedServerAndClient, CookFlavor);
        }
        else if (CookSourcePlatform != null && InProgram)
        {
            CookPlatform = CookSourcePlatform.GetCookPlatform(false, false, "");
        }
        else
        {
            CookPlatform = "";
        }

        if (StageTargetPlatform != null && InCooked)
        {
            FinalCookPlatform = StageTargetPlatform.GetCookPlatform(DedicatedServer, bHasDedicatedServerAndClient, CookFlavor);
        }
        else if (StageTargetPlatform != null && InProgram)
        {
            FinalCookPlatform = StageTargetPlatform.GetCookPlatform(false, false, "");
        }
        else
        {
            FinalCookPlatform = "";
        }

        PlatformDir = StageTargetPlatform.PlatformType.ToString();

        StageDirectory   = CommandUtils.CombinePaths(BaseStageDirectory, FinalCookPlatform);
        ArchiveDirectory = CommandUtils.CombinePaths(BaseArchiveDirectory, FinalCookPlatform);

        if (!CommandUtils.FileExists(RawProjectPath))
        {
            throw new AutomationException("Can't find uproject file {0}.", RawProjectPathOrName);
        }

        ProjectRoot = CommandUtils.CombinePaths(CommandUtils.GetDirectoryName(Path.GetFullPath(RawProjectPath)));

        if (!CommandUtils.DirectoryExists(ProjectRoot))
        {
            throw new AutomationException("Project Directory {0} doesn't exist.", ProjectRoot);
        }

        RelativeProjectRootForStage = ShortProjectName;

        ProjectArgForCommandLines = CommandUtils.MakePathSafeToUseWithCommandLine(RawProjectPath);
        CookSourceRuntimeRootDir  = RuntimeRootDir = LocalRoot;
        RuntimeProjectRootDir     = ProjectRoot;

        RelativeProjectRootForUnrealPak = CommandUtils.CombinePaths(RelativeProjectRootForStage).Replace("\\", "/");
        if (RelativeProjectRootForUnrealPak.StartsWith("/"))
        {
            RelativeProjectRootForUnrealPak = RelativeProjectRootForUnrealPak.Substring(1);
            RelativeProjectRootForStage     = RelativeProjectRootForStage.Substring(1);
        }

        SourceRelativeProjectRoot = RelativeProjectRootForStage; // for foreign projects this doesn't make much sense, but it turns into a noop on staging files
        if (ProjectRoot.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase))
        {
            SourceRelativeProjectRoot = ProjectRoot.Substring(LocalRoot.Length);
        }
        if (SourceRelativeProjectRoot.StartsWith("/") || SourceRelativeProjectRoot.StartsWith("\\"))
        {
            SourceRelativeProjectRoot = SourceRelativeProjectRoot.Substring(1);
        }

        if (Stage)
        {
            CommandUtils.CreateDirectory(StageDirectory);
            StageProjectRoot = CommandUtils.CombinePaths(StageDirectory, RelativeProjectRootForStage);

            RuntimeRootDir            = StageDirectory;
            CookSourceRuntimeRootDir  = CommandUtils.CombinePaths(BaseStageDirectory, CookPlatform);
            RuntimeProjectRootDir     = StageProjectRoot;
            ProjectArgForCommandLines = CommandUtils.MakePathSafeToUseWithCommandLine(UProjectCommandLineArgInternalRoot + RelativeProjectRootForStage + "/" + ShortProjectName + ".uproject");
        }
        if (Archive)
        {
            CommandUtils.CreateDirectory(ArchiveDirectory);
        }
        ProjectArgForCommandLines = ProjectArgForCommandLines.Replace("\\", "/");
    }
예제 #25
0
    public override void ExecuteBuild()
    {
        // Get the list of platform names
        string[]             FeaturePacks    = ParseParamValue("FeaturePacks").Split(';');
        string               TempDir         = ParseParamValue("TempDir");
        UnrealTargetPlatform HostPlatform    = BuildHostPlatform.Current.Platform;
        string               TargetPlatforms = ParseParamValue("TargetPlatforms");
        string               SavedDir        = ParseParamValue("SavedDir");
        string               BackendName     = ParseParamValue("BackendName", "CreateInstalledEnginePak");
        string               RelativePakPath = ParseParamValue("RelativePakPath", "Engine/DerivedDataCache/Compressed.ddp");
        bool bSkipEngine = ParseParam("SkipEngine");


        // Get paths to everything within the temporary directory
        string EditorExe     = CommandUtils.GetEditorCommandletExe(TempDir, HostPlatform);
        string OutputPakFile = CommandUtils.CombinePaths(TempDir, RelativePakPath);
        string OutputCsvFile = Path.ChangeExtension(OutputPakFile, ".csv");


        List <string> ProjectPakFiles  = new List <string>();
        List <string> FeaturePackPaths = new List <string>();

        // loop through all the projects first and bail out if one of them doesn't exist.
        foreach (string FeaturePack in FeaturePacks)
        {
            if (!String.IsNullOrWhiteSpace(FeaturePack))
            {
                string FeaturePackPath = CommandUtils.CombinePaths(CommandUtils.RootDirectory.FullName, FeaturePack);
                if (!CommandUtils.FileExists(FeaturePackPath))
                {
                    throw new AutomationException("Could not find project: " + FeaturePack);
                }
                FeaturePackPaths.Add(FeaturePackPath);
            }
        }

        // loop through all the paths and generate ddc data for them
        foreach (string FeaturePackPath in FeaturePackPaths)
        {
            string            ProjectSpecificPlatforms = TargetPlatforms;
            FileReference     FileRef  = new FileReference(FeaturePackPath);
            string            GameName = FileRef.GetFileNameWithoutAnyExtensions();
            ProjectDescriptor Project  = ProjectDescriptor.FromFile(FileRef);

            if (Project.TargetPlatforms != null && Project.TargetPlatforms.Length > 0)
            {
                // Restrict target platforms used to those specified in project file
                List <string> FilteredPlatforms = new List <string>();

                // Always include the editor platform for cooking
                string EditorCookPlatform = Platform.GetPlatform(HostPlatform).GetEditorCookPlatform();
                if (TargetPlatforms.Contains(EditorCookPlatform))
                {
                    FilteredPlatforms.Add(EditorCookPlatform);
                }

                foreach (string TargetPlatform in Project.TargetPlatforms)
                {
                    if (TargetPlatforms.Contains(TargetPlatform))
                    {
                        FilteredPlatforms.Add(TargetPlatform);
                    }
                }
                if (FilteredPlatforms.Count == 0)
                {
                    LogInformation("Did not find any project specific platforms for FeaturePack {0} out of supplied TargetPlatforms {1}, skipping it!", GameName, ProjectSpecificPlatforms);
                    continue;
                }
                ProjectSpecificPlatforms = CommandUtils.CombineCommandletParams(FilteredPlatforms.Distinct().ToArray());
            }
            CommandUtils.LogInformation("Generating DDC data for {0} on {1}", GameName, ProjectSpecificPlatforms);
            CommandUtils.DDCCommandlet(FileRef, EditorExe, null, ProjectSpecificPlatforms, String.Format("-fill -DDC={0} -ProjectOnly", BackendName));

            string ProjectPakFile = CommandUtils.CombinePaths(Path.GetDirectoryName(OutputPakFile), String.Format("Compressed-{0}.ddp", GameName));
            CommandUtils.DeleteFile(ProjectPakFile);
            CommandUtils.RenameFile(OutputPakFile, ProjectPakFile);

            string ProjectCsvFile = Path.ChangeExtension(ProjectPakFile, ".csv");
            CommandUtils.DeleteFile(ProjectCsvFile);
            CommandUtils.RenameFile(OutputCsvFile, ProjectCsvFile);

            ProjectPakFiles.Add(Path.GetFileName(ProjectPakFile));
        }

        // Generate DDC for the editor, and merge all the other PAK files in
        CommandUtils.LogInformation("Generating DDC data for engine content on {0}", TargetPlatforms);
        CommandUtils.DDCCommandlet(null, EditorExe, null, TargetPlatforms, String.Format("-fill -DDC={0} -MergePaks={1}{2}", BackendName, CommandUtils.MakePathSafeToUseWithCommandLine(String.Join("+", ProjectPakFiles)), bSkipEngine? " -projectonly" : ""));

        string SavedPakFile = CommandUtils.CombinePaths(SavedDir, RelativePakPath);

        CommandUtils.CopyFile(OutputPakFile, SavedPakFile);
    }
예제 #26
0
    public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null)
    {
        int FilesAdded = 0;

        if (CommandUtils.DirectoryExists(InPath))
        {
            var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath);

            var Exclude = new HashSet <string>();
            if (ExcludeWildcard != null)
            {
                foreach (var Excl in ExcludeWildcard)
                {
                    var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath);
                    foreach (var File in Remove)
                    {
                        Exclude.Add(CommandUtils.CombinePaths(File));
                    }
                }
            }
            foreach (var AllFile in All)
            {
                var FileToCopy = CommandUtils.CombinePaths(AllFile);
                if (Exclude.Contains(FileToCopy))
                {
                    continue;
                }
                bool OtherPlatform = false;
                foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
                {
                    if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown && FileToCopy.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0)
                    {
                        OtherPlatform = true;
                        break;
                    }
                }
                if (OtherPlatform)
                {
                    continue;
                }

                string Dest;
                if (!FileToCopy.StartsWith(InPath))
                {
                    throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath);
                }
                Dest = FileToCopy.Substring(InPath.Length);

                if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                {
                    Dest = Dest.Substring(1);
                }

                ArchivedFiles.Add(FileToCopy, Dest);

                FilesAdded++;
            }
        }

        return(FilesAdded);
    }
예제 #27
0
    public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null)
    {
        int FilesAdded = 0;

        if (CommandUtils.DirectoryExists(InPath))
        {
            var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath);

            var Exclude = new HashSet <string>();
            if (ExcludeWildcard != null)
            {
                foreach (var Excl in ExcludeWildcard)
                {
                    var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath);
                    foreach (var File in Remove)
                    {
                        Exclude.Add(CommandUtils.CombinePaths(File));
                    }
                }
            }
            foreach (var AllFile in All)
            {
                var FileToCopy = CommandUtils.CombinePaths(AllFile);
                if (Exclude.Contains(FileToCopy))
                {
                    continue;
                }

                if (!bIsCombiningMultiplePlatforms)
                {
                    FileReference InputFile = new FileReference(FileToCopy);

                    bool OtherPlatform = false;
                    foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
                    {
                        if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown)
                        {
                            var Search = FileToCopy;
                            if (InputFile.IsUnderDirectory(LocalRoot))
                            {
                                Search = InputFile.MakeRelativeTo(LocalRoot);
                            }
                            else if (InputFile.IsUnderDirectory(ProjectRoot))
                            {
                                Search = InputFile.MakeRelativeTo(ProjectRoot);
                            }
                            if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0)
                            {
                                OtherPlatform = true;
                                break;
                            }
                        }
                    }
                    if (OtherPlatform)
                    {
                        continue;
                    }
                }

                string Dest;
                if (!FileToCopy.StartsWith(InPath))
                {
                    throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath);
                }

                // If the specified a new directory, first we deal with that, then apply the other things
                // this is used to collapse the sandbox, among other things
                if (NewPath != null)
                {
                    Dest = FileToCopy.Substring(InPath.Length);
                    if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                    {
                        Dest = Dest.Substring(1);
                    }
                    Dest = CommandUtils.CombinePaths(NewPath, Dest);
                }
                else
                {
                    Dest = FileToCopy.Substring(InPath.Length);
                }

                if (Dest.StartsWith("/") || Dest.StartsWith("\\"))
                {
                    Dest = Dest.Substring(1);
                }

                if (ArchivedFiles.ContainsKey(FileToCopy))
                {
                    if (ArchivedFiles[FileToCopy] != Dest)
                    {
                        throw new AutomationException("Can't archive {0}: it was already in the files to archive with a different destination '{1}'", FileToCopy, Dest);
                    }
                }
                else
                {
                    ArchivedFiles.Add(FileToCopy, Dest);
                }

                FilesAdded++;
            }
        }

        return(FilesAdded);
    }
예제 #28
0
    private static bool CopySharedCookedBuildForTargetInternal(string CookedBuildPath, string CookPlatform, string LocalPath, bool bOnlyCopyAssetRegistry)
    {
        // check to see if we have already synced this build ;)
        var    SyncedBuildFile = CommandUtils.CombinePaths(LocalPath, "SyncedBuild.txt");
        string BuildCL         = "Invalid";

        if (File.Exists(SyncedBuildFile))
        {
            BuildCL = File.ReadAllText(SyncedBuildFile);
        }

        CommandUtils.LogInformation("Attempting download of latest shared build from {0}", CookedBuildPath);

        string SavedBuildCL = string.Format("{0} {1}", CookedBuildPath, bOnlyCopyAssetRegistry ? "RegistryOnly" : "");

        if (BuildCL == SavedBuildCL)
        {
            CommandUtils.LogInformation("Already downloaded latest shared build at CL {0}", SavedBuildCL);
            return(false);
        }

        if (Directory.Exists(CookedBuildPath) == false)
        {
            CommandUtils.LogInformation("Unable to copy shared cooked build: Unable to find shared build at location {0} check SharedCookedBuildPath in Engine.ini SharedCookedBuildSettings is correct", CookedBuildPath);
            return(false);
        }

        // delete all the stuff
        CommandUtils.LogInformation("Deleting previous shared build because it was out of date");
        CommandUtils.DeleteDirectory(LocalPath);
        Directory.CreateDirectory(LocalPath);



        string CookedBuildMetadataDirectory = Path.Combine(CookedBuildPath, "Metadata");

        CookedBuildMetadataDirectory = Path.GetFullPath(CookedBuildMetadataDirectory);
        string LocalBuildMetadataDirectory = Path.Combine(LocalPath, "Metadata");

        LocalBuildMetadataDirectory = Path.GetFullPath(LocalBuildMetadataDirectory);
        if (Directory.Exists(CookedBuildMetadataDirectory))
        {
            foreach (string FileName in Directory.EnumerateFiles(CookedBuildMetadataDirectory, "*.*", SearchOption.AllDirectories))
            {
                string SourceFileName = Path.GetFullPath(FileName);
                string DestFileName   = SourceFileName.Replace(CookedBuildMetadataDirectory, LocalBuildMetadataDirectory);
                Directory.CreateDirectory(Path.GetDirectoryName(DestFileName));
                File.Copy(SourceFileName, DestFileName);
            }
        }

        if (CopySharedCookedBuildTask != null)
        {
            WaitForCopy();
        }

        if (bOnlyCopyAssetRegistry == false)
        {
            CopySharedCookedBuildTask = Task.Run(() =>
            {
                // find all the files in the staged directory
                string CookedBuildStagedDirectory = Path.GetFullPath(Path.Combine(CookedBuildPath, "Staged"));
                string LocalBuildStagedDirectory  = Path.GetFullPath(Path.Combine(LocalPath, "Staged"));
                if (Directory.Exists(CookedBuildStagedDirectory))
                {
                    foreach (string FileName in Directory.EnumerateFiles(CookedBuildStagedDirectory, "*.*", SearchOption.AllDirectories))
                    {
                        string SourceFileName = Path.GetFullPath(FileName);
                        string DestFileName   = SourceFileName.Replace(CookedBuildStagedDirectory, LocalBuildStagedDirectory);
                        Directory.CreateDirectory(Path.GetDirectoryName(DestFileName));
                        File.Copy(SourceFileName, DestFileName);
                    }
                }
                File.WriteAllText(SyncedBuildFile, SavedBuildCL);
            }
                                                 );
        }
        else
        {
            File.WriteAllText(SyncedBuildFile, SavedBuildCL);
        }


        return(true);
    }
예제 #29
0
 /// <summary>
 /// Returns the build root path (P:\Builds on build machines usually)
 /// </summary>
 /// <returns></returns>
 static public string GetBuildRootPath()
 {
     return(CommandUtils.P4Enabled && CommandUtils.AllowSubmit
         ? CommandUtils.RootSharedTempStorageDirectory()
         : CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "LocalBuilds"));
 }
 private string GetUtilitiesFilePath(string Filename)
 {
     return(CommandUtils.CombinePaths(BuildPatchToolStagingInfo.GetBuildRootPath(), "Utilities", Filename));
 }