Beispiel #1
0
 /// <summary>
 /// Called after CopyUsingStagingManifest.  Does anything platform specific that requires a final list of staged files.
 /// e.g.  PlayGo emulation control file generation for PS4.
 /// </summary>
 /// <param name="Params"></param>
 /// <param name="SC"></param>
 public virtual void PostStagingFileCopy(ProjectParams Params, DeploymentContext SC)
 {
 }
    public override void ProcessArchivedProject(ProjectParams Params, DeploymentContext SC)
    {
        if (Params.CreateAppBundle)
        {
            string ExeName    = SC.StageExecutables[0];
            string BundlePath = CombinePaths(SC.ArchiveDirectory, SC.ShortProjectName + ".app");

            if (SC.bIsCombiningMultiplePlatforms)
            {
                // when combining multiple platforms, don't merge the content into the .app, use the one in the Binaries directory
                BundlePath = CombinePaths(SC.ArchiveDirectory, SC.ShortProjectName, "Binaries", "Mac", ExeName + ".app");
                if (!Directory.Exists(BundlePath))
                {
                    // if the .app wasn't there, just skip out (we don't require executables when combining)
                    return;
                }
            }

            string TargetPath = CombinePaths(BundlePath, "Contents", "UE4");
            if (!SC.bIsCombiningMultiplePlatforms)
            {
                if (Directory.Exists(BundlePath))
                {
                    Directory.Delete(BundlePath, true);
                }

                string SourceBundlePath = CombinePaths(SC.ArchiveDirectory, SC.ShortProjectName, "Binaries", "Mac", ExeName + ".app");
                if (!Directory.Exists(SourceBundlePath))
                {
                    SourceBundlePath = CombinePaths(SC.ArchiveDirectory, "Engine", "Binaries", "Mac", ExeName + ".app");
                    if (!Directory.Exists(SourceBundlePath))
                    {
                        SourceBundlePath = CombinePaths(SC.ArchiveDirectory, "Engine", "Binaries", "Mac", "UE4.app");
                    }
                }
                Directory.Move(SourceBundlePath, BundlePath);

                if (DirectoryExists(TargetPath))
                {
                    Directory.Delete(TargetPath, true);
                }

                // First, move all files and folders inside he app bundle
                string[] StagedFiles = Directory.GetFiles(SC.ArchiveDirectory, "*", SearchOption.TopDirectoryOnly);
                foreach (string FilePath in StagedFiles)
                {
                    string TargetFilePath = CombinePaths(TargetPath, Path.GetFileName(FilePath));
                    Directory.CreateDirectory(Path.GetDirectoryName(TargetFilePath));
                    File.Move(FilePath, TargetFilePath);
                }

                string[] StagedDirectories = Directory.GetDirectories(SC.ArchiveDirectory, "*", SearchOption.TopDirectoryOnly);
                foreach (string DirPath in StagedDirectories)
                {
                    string DirName = Path.GetFileName(DirPath);
                    if (!DirName.EndsWith(".app"))
                    {
                        string TargetDirPath = CombinePaths(TargetPath, DirName);
                        Directory.CreateDirectory(Path.GetDirectoryName(TargetDirPath));
                        Directory.Move(DirPath, TargetDirPath);
                    }
                }
            }

            // Update executable name, icon and entry in Info.plist
            string UE4GamePath = CombinePaths(BundlePath, "Contents", "MacOS", ExeName);
            if (ExeName != SC.ShortProjectName && File.Exists(UE4GamePath))
            {
                string GameExePath = CombinePaths(BundlePath, "Contents", "MacOS", SC.ShortProjectName);
                File.Delete(GameExePath);
                File.Move(UE4GamePath, GameExePath);

                string DefaultIconPath    = CombinePaths(BundlePath, "Contents", "Resources", "UE4Game.icns");
                string CustomIconSrcPath  = CombinePaths(BundlePath, "Contents", "Resources", "Application.icns");
                string CustomIconDestPath = CombinePaths(BundlePath, "Contents", "Resources", SC.ShortProjectName + ".icns");
                if (File.Exists(CustomIconSrcPath))
                {
                    File.Delete(DefaultIconPath);
                    if (File.Exists(CustomIconDestPath))
                    {
                        File.Delete(CustomIconDestPath);
                    }
                    File.Move(CustomIconSrcPath, CustomIconDestPath);
                }
                else if (File.Exists(DefaultIconPath))
                {
                    if (File.Exists(CustomIconDestPath))
                    {
                        File.Delete(CustomIconDestPath);
                    }
                    File.Move(DefaultIconPath, CustomIconDestPath);
                }

                string InfoPlistPath     = CombinePaths(BundlePath, "Contents", "Info.plist");
                string InfoPlistContents = File.ReadAllText(InfoPlistPath);
                InfoPlistContents = InfoPlistContents.Replace(ExeName, SC.ShortProjectName);
                InfoPlistContents = InfoPlistContents.Replace("<string>UE4Game</string>", "<string>" + SC.ShortProjectName + "</string>");
                File.Delete(InfoPlistPath);
                File.WriteAllText(InfoPlistPath, InfoPlistContents);
            }

            if (!SC.bIsCombiningMultiplePlatforms)
            {
                // creating these directories when the content isn't moved into the application causes it
                // to fail to load, and isn't needed
                Directory.CreateDirectory(CombinePaths(TargetPath, "Engine", "Binaries", "Mac"));
                Directory.CreateDirectory(CombinePaths(TargetPath, SC.ShortProjectName, "Binaries", "Mac"));
            }
        }
    }
 public override bool ShouldStageCommandLine(ProjectParams Params, DeploymentContext SC)
 {
     return(false);        // !String.IsNullOrEmpty(Params.StageCommandline) || !String.IsNullOrEmpty(Params.RunCommandline) || (!Params.IsCodeBasedProject && Params.NoBootstrapExe);
 }
Beispiel #4
0
 public override bool ShouldStageCommandLine(ProjectParams Params, DeploymentContext SC)
 {
     return(false);
 }
Beispiel #5
0
 public async Task <IActionResult> GetProjects([FromQuery] ProjectParams param)
 {
     return(HandlePagedResult(await Mediator.Send(new List.Query {
         Params = param
     })));
 }
Beispiel #6
0
    public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1, ProjectBuildTargets TargetMask = ProjectBuildTargets.All)
    {
        Params.ValidateAndLog();

        if (!Params.Build)
        {
            return;
        }

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

        var UE4Build             = new UE4Build(Command);
        var Agenda               = new UE4Build.BuildAgenda();
        var CrashReportPlatforms = new HashSet <UnrealTargetPlatform>();

        // Setup editor targets
        if (Params.HasEditorTargets && (!Params.SkipBuildEditor) && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Editor) == ProjectBuildTargets.Editor)
        {
            // @todo Mac: proper platform detection
            UnrealTargetPlatform            EditorPlatform      = HostPlatform.Current.HostEditorPlatform;
            const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development;

            CrashReportPlatforms.Add(EditorPlatform);
            Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath);
            if (Params.EditorTargets.Contains("UnrealHeaderTool") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealHeaderTool" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.EditorTargets.Contains("ShaderCompileWorker") == false)
            {
                Agenda.AddTargets(new string[] { "ShaderCompileWorker" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.Pak && Params.EditorTargets.Contains("UnrealPak") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealPak" }, EditorPlatform, EditorConfiguration);
            }
            if (Params.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration);
            }
        }

        // Additional compile arguments
        string AdditionalArgs = "";

        if (Params.MapFile)
        {
            AdditionalArgs += " -mapfile";
        }

        if (Params.Deploy || Params.Package)
        {
            AdditionalArgs += " -skipdeploy";             // skip deploy step in UBT if we going to do it later anyway
        }

        // Config overrides (-ini)
        foreach (string ConfigOverrideParam in Params.ConfigOverrideParams)
        {
            AdditionalArgs += " -";
            AdditionalArgs += ConfigOverrideParam;
        }

        // Setup cooked targets
        if (Params.HasClientCookedTargets && (!Params.SkipBuildClient) && (TargetMask & ProjectBuildTargets.ClientCooked) == ProjectBuildTargets.ClientCooked)
        {
            List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList();

            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatformType in UniquePlatformTypes)
                {
                    CrashReportPlatforms.Add(ClientPlatformType);
                    Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"" + AdditionalArgs);
                }
            }
        }
        if (Params.HasServerCookedTargets && (TargetMask & ProjectBuildTargets.ServerCooked) == ProjectBuildTargets.ServerCooked)
        {
            List <UnrealTargetPlatform> UniquePlatformTypes = Params.ServerTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList();

            foreach (var BuildConfig in Params.ServerConfigsToBuild)
            {
                foreach (var ServerPlatformType in UniquePlatformTypes)
                {
                    CrashReportPlatforms.Add(ServerPlatformType);
                    Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"" + AdditionalArgs);
                }
            }
        }
        if (!Params.NoBootstrapExe && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Bootstrap) == ProjectBuildTargets.Bootstrap)
        {
            UnrealBuildTool.UnrealTargetPlatform[] BootstrapPackagedGamePlatforms = { UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetPlatform.Win64 };
            foreach (UnrealBuildTool.UnrealTargetPlatform BootstrapPackagedGamePlatformType in BootstrapPackagedGamePlatforms)
            {
                if (Params.ClientTargetPlatforms.Contains(new TargetPlatformDescriptor(BootstrapPackagedGamePlatformType)))
                {
                    Agenda.AddTarget("BootstrapPackagedGame", BootstrapPackagedGamePlatformType, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
                }
            }
        }
        if (Params.CrashReporter && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.CrashReporter) == ProjectBuildTargets.CrashReporter)
        {
            foreach (var CrashReportPlatform in CrashReportPlatforms)
            {
                if (PlatformSupportsCrashReporter(CrashReportPlatform))
                {
                    Agenda.AddTarget("CrashReportClient", CrashReportPlatform, UnrealTargetConfiguration.Shipping, InAddArgs: " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"");
                }
            }
        }
        if (Params.HasProgramTargets && (TargetMask & ProjectBuildTargets.Programs) == ProjectBuildTargets.Programs)
        {
            List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList();

            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatformType in UniquePlatformTypes)
                {
                    Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath);
                }
            }
        }
        UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0);

        if (WorkingCL > 0)         // only move UAT files if we intend to check in some build products
        {
            UE4Build.AddUATFilesToBuildProducts();
        }
        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);

        if (WorkingCL > 0)
        {
            // Sign everything we built
            CodeSign.SignMultipleIfEXEOrDLL(Command, UE4Build.BuildProductFiles);

            // Open files for add or edit
            UE4Build.AddBuildProductsToChangelist(WorkingCL, UE4Build.BuildProductFiles);
        }

        Log("********** BUILD COMMAND COMPLETED **********");
    }
Beispiel #7
0
 public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
 {
     // package up the program
     PrintRunTime();
 }
Beispiel #8
0
 public virtual void PreBuildAgenda(UE4Build Build, UE4Build.BuildAgenda Agenda, ProjectParams Params)
 {
 }
Beispiel #9
0
 /// <summary>
 /// Determines whether we should stage a UE4CommandLine.txt for this platform
 /// </summary>
 public virtual bool ShouldStageCommandLine(ProjectParams Params, DeploymentContext SC)
 {
     return(true);
 }
Beispiel #10
0
 /// <summary>
 /// Returns platform specific command line options for UnrealPak
 /// </summary>
 public virtual string GetPlatformPakCommandLine(ProjectParams Params, DeploymentContext SC)
 {
     return("");
 }
Beispiel #11
0
 /// <summary>
 /// Returns true if the platform wants patches to generate a small .pak file containing the difference
 /// of current data against a shipped pak file.
 /// </summary>
 /// <returns></returns>
 public virtual bool GetPlatformPatchesWithDiffPak(ProjectParams Params, DeploymentContext SC)
 {
     return(true);
 }
Beispiel #12
0
 public virtual PakType RequiresPak(ProjectParams Params)
 {
     return(PakType.DontCare);
 }
Beispiel #13
0
 /// <summary>
 /// Gets extra launch commandline arguments for this platform.
 /// </summary>
 /// <param name="Params"> ProjectParams </param>
 /// <returns>Launch platform string.</returns>
 public virtual string GetLaunchExtraCommandLine(ProjectParams Params)
 {
     return("");
 }
Beispiel #14
0
 /// <summary>
 /// Get the files to deploy, specific to this platform, typically binaries
 /// </summary>
 /// <param name="SC">Deployment Context</param>
 public virtual void GetFilesToArchive(ProjectParams Params, DeploymentContext SC)
 {
     SC.ArchiveFiles(SC.StageDirectory.FullName);
 }
        public override void ExecuteBuild()
        {
            var Params = new ProjectParams
                         (
                Command: this,
                // Shared
                RawProjectPath: ProjectPath
                         );

            LogInformation("********** CRYPTOKEYS COMMAND STARTED **********");

            string UE4EditorExe = HostPlatform.Current.GetUE4ExePath(Params.UE4Exe);

            if (!FileExists(UE4EditorExe))
            {
                throw new AutomationException("Missing " + UE4EditorExe + " executable. Needs to be built first.");
            }

            bool bCycleAllKeys       = ParseParam("updateallkeys");
            bool bCycleEncryptionKey = bCycleAllKeys || ParseParam("updateencryptionkey");
            bool bCycleSigningKey    = bCycleAllKeys || ParseParam("updatesigningkey");

            if (!bCycleAllKeys && !bCycleEncryptionKey && !bCycleSigningKey)
            {
                throw new Exception("A target for key cycling must be specified when using the cryptokeys automation script\n\t-updateallkeys: Update all keys\n\t-updateencryptionkey: Update encryption key\n\t-updatesigningkey: Update signing key");
            }

            FileReference OutputFile         = FileReference.Combine(ProjectPath.Directory, "Config", "DefaultCrypto.ini");
            FileReference NoRedistOutputFile = FileReference.Combine(ProjectPath.Directory, "Config", "NoRedist", "DefaultCrypto.ini");
            FileReference DestinationFile    = OutputFile;

            // If the project has a DefaultCrypto.ini in a NoRedist folder, we want to copy the newly generated file into that location
            if (FileReference.Exists(NoRedistOutputFile))
            {
                DestinationFile = NoRedistOutputFile;
            }

            string ChangeDescription = "Automated update of ";

            if (bCycleEncryptionKey)
            {
                ChangeDescription += "encryption";
            }

            if (bCycleSigningKey)
            {
                if (bCycleEncryptionKey)
                {
                    ChangeDescription += " and ";
                }
                ChangeDescription += "signing";
            }

            ChangeDescription += " key";

            if (bCycleEncryptionKey && bCycleSigningKey)
            {
                ChangeDescription += "s";
            }

            ChangeDescription += " for project " + Params.ShortProjectName;

            P4Connection SubmitP4 = null;
            int          NewCL    = 0;

            if (CommandUtils.P4Enabled)
            {
                SubmitP4 = CommandUtils.P4;

                NewCL = SubmitP4.CreateChange(Description: ChangeDescription);
                SubmitP4.Revert(String.Format("-k \"{0}\"", DestinationFile.FullName));
                SubmitP4.Sync(String.Format("-k \"{0}\"", DestinationFile.FullName), AllowSpew: false);
                SubmitP4.Add(NewCL, String.Format("\"{0}\"", DestinationFile.FullName));
                SubmitP4.Edit(NewCL, String.Format("\"{0}\"", DestinationFile.FullName));
            }
            else
            {
                LogInformation(ChangeDescription);
                FileReference.MakeWriteable(OutputFile);
            }

            string CommandletParams = "";

            if (bCycleAllKeys)
            {
                CommandletParams = "-updateallkeys";
            }
            else if (bCycleEncryptionKey)
            {
                CommandletParams = "-updateencryptionkey";
            }
            else if (bCycleSigningKey)
            {
                CommandletParams = "-updatesigningkey";
            }

            RunCommandlet(ProjectPath, UE4EditorExe, "CryptoKeys", CommandletParams);

            if (DestinationFile != OutputFile)
            {
                File.Delete(DestinationFile.FullName);
                FileReference.Move(OutputFile, DestinationFile);
            }

            if (SubmitP4 != null)
            {
                int ActualCL;
                SubmitP4.Submit(NewCL, out ActualCL);
            }
        }
Beispiel #16
0
 public virtual bool RetrieveDeployedManifests(ProjectParams Params, DeploymentContext SC, string DeviceName, out List <string> UFSManifests, out List <string> NonUFSManifests)
 {
     UFSManifests    = null;
     NonUFSManifests = null;
     return(false);
 }
Beispiel #17
0
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        // Stage all the build products
        foreach (StageTarget Target in SC.StageTargets)
        {
            SC.StageBuildProductsFromReceipt(Target.Receipt, Target.RequireFilesExist, Params.bTreatNonShippingBinariesAsDebugFiles);
        }

        if (SC.bStageCrashReporter)
        {
            StagedDirectoryReference CrashReportClientPath = StagedDirectoryReference.Combine("Engine/Binaries", SC.PlatformDir, "CrashReportClient.app");
            StageAppBundle(SC, DirectoryReference.Combine(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "CrashReportClient.app"), CrashReportClientPath);
        }

        // Find the app bundle path
        List <FileReference> Exes = GetExecutableNames(SC);

        foreach (var Exe in Exes)
        {
            StagedDirectoryReference AppBundlePath = null;
            if (Exe.IsUnderDirectory(DirectoryReference.Combine(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir)))
            {
                AppBundlePath = StagedDirectoryReference.Combine(SC.ShortProjectName, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe.FullName) + ".app");
            }
            else if (Exe.IsUnderDirectory(DirectoryReference.Combine(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir)))
            {
                AppBundlePath = StagedDirectoryReference.Combine("Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe.FullName) + ".app");
            }

            // Copy the custom icon and Steam dylib, if needed
            if (AppBundlePath != null)
            {
                FileReference AppIconsFile = FileReference.Combine(SC.ProjectRoot, "Build", "Mac", "Application.icns");
                if (FileReference.Exists(AppIconsFile))
                {
                    SC.StageFile(StagedFileType.NonUFS, AppIconsFile, StagedFileReference.Combine(AppBundlePath, "Contents", "Resources", "Application.icns"));
                }
            }
        }

        // Copy the splash screen, Mac specific
        FileReference SplashImage = FileReference.Combine(SC.ProjectRoot, "Content", "Splash", "Splash.bmp");

        if (FileReference.Exists(SplashImage))
        {
            SC.StageFile(StagedFileType.NonUFS, SplashImage);
        }

        // 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
                    List <StagedFileReference> StagedFiles = SC.FilesToStage.NonUFSFiles.Where(x => x.Value == Executable.Path).Select(x => x.Key).ToList();
                    if (StagedFiles.Count > 0 && Executable.Path.FullName.Replace("\\", "/").Contains("/" + TargetPlatformType.ToString() + "/"))
                    {
                        string BootstrapArguments = "";
                        if (!ShouldStageCommandLine(Params, SC))
                        {
                            if (!SC.IsCodeBasedProject)
                            {
                                BootstrapArguments = String.Format("../../../{0}/{0}.uproject", SC.ShortProjectName);
                            }
                            else
                            {
                                BootstrapArguments = SC.ShortProjectName;
                            }
                        }

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

                        string AppPath = Executable.Path.FullName.Substring(0, Executable.Path.FullName.LastIndexOf(".app/") + 4);
                        foreach (var DestPath in StagedFiles)
                        {
                            string AppRelativePath = DestPath.Name.Substring(0, DestPath.Name.LastIndexOf(".app/") + 4);
                            StageBootstrapExecutable(SC, BootstrapExeName, AppPath, AppRelativePath, BootstrapArguments);
                        }
                    }
                }
            }
        }

        // Copy the ShaderCache files, if they exist
        FileReference DrawCacheFile = FileReference.Combine(SC.ProjectRoot, "Content", "DrawCache.ushadercache");

        if (FileReference.Exists(DrawCacheFile))
        {
            SC.StageFile(StagedFileType.UFS, DrawCacheFile);
        }

        FileReference ByteCodeCacheFile = FileReference.Combine(SC.ProjectRoot, "Content", "ByteCodeCache.ushadercode");

        if (FileReference.Exists(ByteCodeCacheFile))
        {
            SC.StageFile(StagedFileType.UFS, ByteCodeCacheFile);
        }
    }
Beispiel #18
0
 public virtual bool SignExecutables(DeploymentContext SC, ProjectParams Params)
 {
     return(true);
 }
Beispiel #19
0
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        if (SC.bStageCrashReporter)
        {
            string ReceiptFileName = TargetReceipt.GetDefaultPath(CommandUtils.EngineDirectory.FullName, "CrashReportClient", SC.StageTargetPlatform.PlatformType, UnrealTargetConfiguration.Shipping, null);
            if (File.Exists(ReceiptFileName))
            {
                TargetReceipt Receipt = TargetReceipt.Read(ReceiptFileName);
                Receipt.ExpandPathVariables(CommandUtils.EngineDirectory, (Params.RawProjectPath == null) ? CommandUtils.EngineDirectory : Params.RawProjectPath.Directory);
                SC.StageBuildProductsFromReceipt(Receipt, true, false);
            }
        }

        // Stage all the build products
        Console.WriteLine("Staging all {0} build products", SC.StageTargets.Count);
        int BuildProductIdx = 0;

        foreach (StageTarget Target in SC.StageTargets)
        {
            Console.WriteLine(" Product {0}: {1}", BuildProductIdx, Target.Receipt.TargetName);
            SC.StageBuildProductsFromReceipt(Target.Receipt, Target.RequireFilesExist, Params.bTreatNonShippingBinariesAsDebugFiles);
            ++BuildProductIdx;
        }

        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 (Executable.Path.Replace("\\", "/").Contains("/" + TargetPlatformType.ToString() + "/"))
                    {
                        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 = Target.Receipt.TargetName;
                        }
                        else
                        {
                            BootstrapExeName = SC.ShortProjectName;
                        }

                        foreach (string StagePath in SC.NonUFSStagingFiles[FullExecutablePath])
                        {
                            StageBootstrapExecutable(SC, BootstrapExeName + ".sh", FullExecutablePath, StagePath, BootstrapArguments);
                        }
                    }
                }
            }
        }
    }
Beispiel #20
0
    public static void Cook(ProjectParams Params)
    {
        if ((!Params.Cook && !(Params.CookOnTheFly && !Params.SkipServer)) || Params.SkipCook)
        {
            return;
        }
        Params.ValidateAndLog();

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

        string UE4EditorExe = HostPlatform.Current.GetUE4ExePath(Params.UE4Exe);

        if (!FileExists(UE4EditorExe))
        {
            throw new AutomationException("Missing " + UE4EditorExe + " executable. Needs to be built first.");
        }

        if (Params.CookOnTheFly && !Params.SkipServer)
        {
            if (Params.HasDLCName)
            {
                throw new AutomationException("Cook on the fly doesn't support cooking dlc");
            }
            if (Params.ClientTargetPlatforms.Count > 0)
            {
                var LogFolderOutsideOfSandbox = GetLogFolderOutsideOfSandbox();
                if (!GlobalCommandLine.Installed)
                {
                    // In the installed runs, this is the same folder as CmdEnv.LogFolder so delete only in not-installed
                    DeleteDirectory(LogFolderOutsideOfSandbox);
                    CreateDirectory(LogFolderOutsideOfSandbox);
                }

                String COTFCommandLine = Params.RunCommandline;
                if (Params.IterativeCooking)
                {
                    COTFCommandLine += " -iterate -iteratehash";
                }
                if (Params.UseDebugParamForEditorExe)
                {
                    COTFCommandLine += " -debug";
                }

                var      ServerLogFile      = CombinePaths(LogFolderOutsideOfSandbox, "Server.log");
                Platform ClientPlatformInst = Params.ClientTargetPlatformInstances[0];
                string   TargetCook         = ClientPlatformInst.GetCookPlatform(false, false);       // cook on he fly doesn't support server cook platform...
                ServerProcess = RunCookOnTheFlyServer(Params.RawProjectPath, Params.NoClient ? "" : ServerLogFile, TargetCook, COTFCommandLine);

                if (ServerProcess != null)
                {
                    Log("Waiting a few seconds for the server to start...");
                    Thread.Sleep(5000);
                }
            }
            else
            {
                throw new AutomationException("Failed to run, client target platform not specified");
            }
        }
        else
        {
            string NativizedPluginPath = "";

            var PlatformsToCook = new HashSet <string>();
            if (!Params.NoClient)
            {
                foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                {
                    // Use the data platform, sometimes we will copy another platform's data
                    var    DataPlatformDesc = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
                    string PlatformToCook   = Platform.Platforms[DataPlatformDesc].GetCookPlatform(false, Params.Client);
                    PlatformsToCook.Add(PlatformToCook);
                    NativizedPluginPath = AddBlueprintPluginPathArgument(Params, true, DataPlatformDesc.Type, PlatformToCook);
                }
            }
            if (Params.DedicatedServer)
            {
                foreach (var ServerPlatform in Params.ServerTargetPlatforms)
                {
                    // Use the data platform, sometimes we will copy another platform's data
                    var    DataPlatformDesc = Params.GetCookedDataPlatformForServerTarget(ServerPlatform);
                    string PlatformToCook   = Platform.Platforms[DataPlatformDesc].GetCookPlatform(true, false);
                    PlatformsToCook.Add(PlatformToCook);
                    NativizedPluginPath = AddBlueprintPluginPathArgument(Params, false, DataPlatformDesc.Type, PlatformToCook);
                }
            }

            if (Params.Clean.HasValue && Params.Clean.Value && !Params.IterativeCooking)
            {
                Log("Cleaning cooked data.");
                CleanupCookedData(PlatformsToCook.ToList(), Params);
            }

            // cook the set of maps, or the run map, or nothing
            string[] Maps = null;
            if (Params.HasMapsToCook)
            {
                Maps = Params.MapsToCook.ToArray();
                foreach (var M in Maps)
                {
                    Log("HasMapsToCook " + M.ToString());
                }
                foreach (var M in Params.MapsToCook)
                {
                    Log("Params.HasMapsToCook " + M.ToString());
                }
            }

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

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

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

            try
            {
                var CommandletParams = IsBuildMachine ? "-buildmachine -fileopenlog" : "-fileopenlog";
                if (Params.UnversionedCookedContent)
                {
                    CommandletParams += " -unversioned";
                }
                if (Params.FastCook)
                {
                    CommandletParams += " -FastCook";
                }
                if (Params.UseDebugParamForEditorExe)
                {
                    CommandletParams += " -debug";
                }
                if (Params.Manifests)
                {
                    CommandletParams += " -manifests";
                }
                if (Params.IterativeCooking)
                {
                    CommandletParams += " -iterate -iterateshash";
                }
                if (Params.IterateSharedCookedBuild)
                {
                    CopySharedCookedBuild(Params);
                    CommandletParams += " -iteratesharedcookedbuild";
                }

                if (Params.CookMapsOnly)
                {
                    CommandletParams += " -mapsonly";
                }
                if (Params.CookAll)
                {
                    CommandletParams += " -cookall";
                }
                if (Params.HasCreateReleaseVersion)
                {
                    CommandletParams += " -createreleaseversion=" + Params.CreateReleaseVersion;
                }
                if (Params.SkipCookingEditorContent)
                {
                    CommandletParams += " -skipeditorcontent";
                }
                if (Params.NumCookersToSpawn != 0)
                {
                    CommandletParams += " -numcookerstospawn=" + Params.NumCookersToSpawn;
                }
                if (Params.CookPartialGC)
                {
                    CommandletParams += " -partialgc";
                }
                if (Params.HasMapIniSectionsToCook)
                {
                    string MapIniSections = CombineCommandletParams(Params.MapIniSectionsToCook.ToArray());

                    CommandletParams += " -MapIniSection=" + MapIniSections;
                }
                if (Params.HasDLCName)
                {
                    CommandletParams += " -dlcname=" + Params.DLCName;
                    if (!Params.DLCIncludeEngineContent)
                    {
                        CommandletParams += " -errorOnEngineContentUse";
                    }
                }
                if (!String.IsNullOrEmpty(Params.CookOutputDir))
                {
                    CommandletParams += " -outputdir=" + CommandUtils.MakePathSafeToUseWithCommandLine(Params.CookOutputDir);
                }
                // don't include the based on release version unless we are cooking dlc or creating a new release version
                // in this case the based on release version is used in packaging
                if (Params.HasBasedOnReleaseVersion && (Params.HasDLCName || Params.HasCreateReleaseVersion))
                {
                    CommandletParams += " -basedonreleaseversion=" + Params.BasedOnReleaseVersion;
                }
                // if we are not going to pak but we specified compressed then compress in the cooker ;)
                // otherwise compress the pak files
                if (!Params.Pak && !Params.SkipPak && Params.Compressed)
                {
                    CommandletParams += " -compressed";
                }
                // we provide the option for users to run a conversion on certain (script) assets, translating them
                // into native source code... the cooker needs to
                if (Params.RunAssetNativization)
                {
                    CommandletParams += " -NativizeAssets";
                    if (NativizedPluginPath.Length > 0)
                    {
                        CommandletParams += "=\"" + NativizedPluginPath + "\"";
                    }
                }
                if (Params.HasAdditionalCookerOptions)
                {
                    string FormatedAdditionalCookerParams = Params.AdditionalCookerOptions.TrimStart(new char[] { '\"', ' ' }).TrimEnd(new char[] { '\"', ' ' });
                    CommandletParams += " ";
                    CommandletParams += FormatedAdditionalCookerParams;
                }

                if (!Params.NoClient)
                {
                    var MapsList = Maps == null ? new List <string>() :  Maps.ToList();
                    foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                    {
                        var DataPlatformDesc = Params.GetCookedDataPlatformForClientTarget(ClientPlatform);
                        CommandletParams += (Platform.Platforms[DataPlatformDesc].GetCookExtraCommandLine(Params));
                        MapsList.AddRange((Platform.Platforms[ClientPlatform].GetCookExtraMaps()));
                    }
                    Maps = MapsList.ToArray();
                }

                CookCommandlet(Params.RawProjectPath, Params.UE4Exe, Maps, Dirs, InternationalizationPreset, CulturesToCook, CombineCommandletParams(PlatformsToCook.ToArray()), CommandletParams);
            }
            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 **********");
    }
Beispiel #21
0
 public override IProcessResult RunClient(ERunOptions ClientRunFlags, string ClientApp, string ClientCmdLine, ProjectParams Params)
 {
     if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Linux)
     {
         IProcessResult Result = null;
         foreach (string DeviceAddress in Params.DeviceNames)
         {
             // Use the helper script (should already be +x - see Deploy)
             string RemoteBasePath     = "./" + Params.ShortProjectName;
             string RemotePathToBinary = RemoteBasePath + "/" + LaunchOnHelperShellScriptName;
             // non-null input is essential, since RedirectStandardInput=true is needed for PLINK, see http://stackoverflow.com/questions/1910592/process-waitforexit-on-console-vs-windows-forms
             Result = Run(PlinkPath, String.Format("-batch -ssh -t -l {0} -pw {1} {2}  {3} {4}", Params.DeviceUsername, Params.DevicePassword, Params.DeviceNames[0], RemotePathToBinary, ClientCmdLine), "");
         }
         return(Result);
     }
     else
     {
         return(base.RunClient(ClientRunFlags, ClientApp, ClientCmdLine, Params));
     }
 }
Beispiel #22
0
    static void CopySharedCookedBuildForTarget(ProjectParams Params, TargetPlatformDescriptor TargetPlatform, string CookPlatform)
    {
        string ProjectPath = Params.RawProjectPath.FullName;
        var    LocalPath   = CombinePaths(GetDirectoryName(ProjectPath), "Saved", "SharedIterativeBuild", CookPlatform);

        // get network location
        ConfigHierarchy Hierarchy = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(Params.RawProjectPath), TargetPlatform.Type);
        string          CookedBuildPath;

        if (Hierarchy.GetString("SharedCookedBuildSettings", "SharedCookedBuildPath", out CookedBuildPath) == false)
        {
            Log("Unable to copy shared cooked build: SharedCookedBuildPath not set in Engine.ini SharedCookedBuildSettings");
            return;
        }

        string BuildRoot = P4Enabled ? P4Env.BuildRootP4.Replace("/", "+") : "";
        int    RecentCL  = P4Enabled ? P4Env.Changelist : 0;

        BuildVersion Version;

        if (BuildVersion.TryRead(out Version))
        {
            RecentCL  = Version.Changelist;
            BuildRoot = Version.BranchName;
        }

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

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

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

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


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

        if (Directory.Exists(CookedBuildPath) == false)
        {
            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;
        }

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

        if (BuildCL == RecentCL.ToString())
        {
            Log("Already downloaded latest shared build at CL {0}", RecentCL);
            return;
        }
        // delete all the stuff
        Log("Deleting previous shared build because it was out of date");
        CommandUtils.DeleteDirectory(LocalPath);
        Directory.CreateDirectory(LocalPath);


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


        string CookedBuildCookedDirectory = Path.Combine(CookedBuildPath, "Cooked");

        CookedBuildCookedDirectory = Path.GetFullPath(CookedBuildCookedDirectory);
        string LocalBuildCookedDirectory = Path.Combine(LocalPath, "Cooked");

        LocalBuildCookedDirectory = Path.GetFullPath(LocalBuildCookedDirectory);
        if (Directory.Exists(CookedBuildCookedDirectory))
        {
            foreach (string FileName in Directory.EnumerateFiles(CookedBuildCookedDirectory, "*.*", SearchOption.AllDirectories))
            {
                string SourceFileName = Path.GetFullPath(FileName);
                string DestFileName   = SourceFileName.Replace(CookedBuildCookedDirectory, LocalBuildCookedDirectory);
                Directory.CreateDirectory(Path.GetDirectoryName(DestFileName));
                File.Copy(SourceFileName, DestFileName);
            }
        }
        File.WriteAllText(SyncedBuildFile, RecentCL.ToString());
        return;
    }
Beispiel #23
0
        private void RunRebuildHLODCommandlet(ProjectParams Params)
        {
            Log("Running Step:- RebuildHLOD::RunRebuildHLODCommandlet");

            // Find the commandlet binary
            string UE4EditorExe = HostPlatform.Current.GetUE4ExePath(Params.UE4Exe);

            if (!FileExists(UE4EditorExe))
            {
                LogError("Missing " + UE4EditorExe + " executable. Needs to be built first.");
                throw new AutomationException("Missing " + UE4EditorExe + " executable. Needs to be built first.");
            }

            // Now let's rebuild HLODs for the project
            try
            {
                var CommandletParams = IsBuildMachine ? "-unattended -buildmachine -fileopenlog" : "-fileopenlog";
                CommandletParams += " -AutoCheckOutPackages";

                string BuildOptions = ParseParamValue("BuildOptions", "");
                if (BuildOptions.Length > 0)
                {
                    CommandletParams += String.Format(" -BuildOptions={0}", BuildOptions);
                }

                if (P4Enabled)
                {
                    CommandletParams += String.Format(" -SCCProvider={0} -P4Port={1} -P4User={2} -P4Client={3} -P4Changelist={4} -P4Passwd={5}", "Perforce", P4Env.ServerAndPort, P4Env.User, P4Env.Client, WorkingCL.ToString(), P4.GetAuthenticationToken());
                }
                RebuildHLODCommandlet(Params.RawProjectPath, Params.UE4Exe, Params.MapsToRebuildHLODMaps.ToArray(), CommandletParams);
            }
            catch (Exception Ex)
            {
                string FinalLogLines    = "No log file found";
                CommandletException AEx = Ex as CommandletException;
                if (AEx != null)
                {
                    string LogFile = AEx.LogFileName;
                    UnrealBuildTool.Log.TraceWarning("Attempting to load file {0}", LogFile);
                    if (LogFile != "")
                    {
                        UnrealBuildTool.Log.TraceWarning("Attempting to read file {0}", LogFile);
                        try
                        {
                            string[] AllLogFile = ReadAllLines(LogFile);

                            FinalLogLines = "Important log entries\n";
                            foreach (string LogLine in AllLogFile)
                            {
                                if (LogLine.Contains("[REPORT]") || LogLine.Contains("Error:"))
                                {
                                    FinalLogLines += LogLine + "\n";
                                }
                            }
                        }
                        catch (Exception)
                        {
                            // we don't care about this because if this is hit then there is no log file the exception probably has more info
                            LogError("Could not find log file " + LogFile);
                        }
                    }
                }

                // Something went wrong with the commandlet. Abandon this run, don't check in any updated files, etc.
                LogError("Rebuild HLODs has failed. because " + Ex.ToString());
                throw new AutomationException(ExitCode.Error_Unknown, Ex, "RebuildHLOD failed. {0}", FinalLogLines);
            }
        }
Beispiel #24
0
    private static void DiffCookedContent(ProjectParams Params)
    {
        List <TargetPlatformDescriptor> PlatformsToCook = Params.ClientTargetPlatforms;
        string ProjectPath = Params.RawProjectPath.FullName;

        var CookedSandboxesPath = CombinePaths(GetDirectoryName(ProjectPath), "Saved", "Cooked");

        for (int CookPlatformIndex = 0; CookPlatformIndex < PlatformsToCook.Count; ++CookPlatformIndex)
        {
            // temporary directory to save the pak file to (pak file is usually not local and on network drive)
            var TemporaryPakPath = CombinePaths(GetDirectoryName(ProjectPath), "Saved", "Temp", "LocalPKG");
            // extracted files from pak file
            var TemporaryFilesPath = CombinePaths(GetDirectoryName(ProjectPath), "Saved", "Temp", "LocalFiles");



            try
            {
                Directory.Delete(TemporaryPakPath, true);
            }
            catch (Exception Ex)
            {
                if (!(Ex is System.IO.DirectoryNotFoundException))
                {
                    Log("Failed deleting temporary directories " + TemporaryPakPath + " continuing. " + Ex.GetType().ToString());
                }
            }
            try
            {
                Directory.Delete(TemporaryFilesPath, true);
            }
            catch (Exception Ex)
            {
                if (!(Ex is System.IO.DirectoryNotFoundException))
                {
                    Log("Failed deleting temporary directories " + TemporaryFilesPath + " continuing. " + Ex.GetType().ToString());
                }
            }

            try
            {
                Directory.CreateDirectory(TemporaryPakPath);
                Directory.CreateDirectory(TemporaryFilesPath);

                Platform CurrentPlatform = Platform.Platforms[PlatformsToCook[CookPlatformIndex]];

                string SourceCookedContentPath = Params.DiffCookedContentPath;

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

                string CookPlatformString = CurrentPlatform.GetCookPlatform(false, Params.Client);

                if (Path.HasExtension(SourceCookedContentPath) && (!SourceCookedContentPath.EndsWith(".pak")))
                {
                    // must be a per platform pkg file try this
                    CurrentPlatform.ExtractPackage(Params, Params.DiffCookedContentPath, TemporaryPakPath);

                    // find the pak file
                    PakFiles.AddRange(Directory.EnumerateFiles(TemporaryPakPath, Params.ShortProjectName + "*.pak", SearchOption.AllDirectories));
                    PakFiles.AddRange(Directory.EnumerateFiles(TemporaryPakPath, "pakchunk*.pak", SearchOption.AllDirectories));
                }
                else if (!Path.HasExtension(SourceCookedContentPath))
                {
                    // try find the pak or pkg file
                    string SourceCookedContentPlatformPath = CombinePaths(SourceCookedContentPath, CookPlatformString);

                    foreach (var PakName in Directory.EnumerateFiles(SourceCookedContentPlatformPath, Params.ShortProjectName + "*.pak", SearchOption.AllDirectories))
                    {
                        string TemporaryPakFilename = CombinePaths(TemporaryPakPath, Path.GetFileName(PakName));
                        File.Copy(PakName, TemporaryPakFilename);
                        PakFiles.Add(TemporaryPakFilename);
                    }

                    foreach (var PakName in Directory.EnumerateFiles(SourceCookedContentPlatformPath, "pakchunk*.pak", SearchOption.AllDirectories))
                    {
                        string TemporaryPakFilename = CombinePaths(TemporaryPakPath, Path.GetFileName(PakName));
                        File.Copy(PakName, TemporaryPakFilename);
                        PakFiles.Add(TemporaryPakFilename);
                    }

                    if (PakFiles.Count <= 0)
                    {
                        Log("No Pak files found in " + SourceCookedContentPlatformPath + " :(");
                    }
                }
                else if (SourceCookedContentPath.EndsWith(".pak"))
                {
                    string TemporaryPakFilename = CombinePaths(TemporaryPakPath, Path.GetFileName(SourceCookedContentPath));
                    File.Copy(SourceCookedContentPath, TemporaryPakFilename);
                    PakFiles.Add(TemporaryPakFilename);
                }


                string FullCookPath = CombinePaths(CookedSandboxesPath, CookPlatformString);

                var UnrealPakExe = CombinePaths(CmdEnv.LocalRoot, "Engine/Binaries/Win64/UnrealPak.exe");


                foreach (var Name in PakFiles)
                {
                    Log("Extracting pak " + Name + " for comparision to location " + TemporaryFilesPath);

                    string UnrealPakParams = Name + " -Extract " + " " + TemporaryFilesPath;
                    try
                    {
                        RunAndLog(CmdEnv, UnrealPakExe, UnrealPakParams, Options: ERunOptions.Default | ERunOptions.UTF8Output | ERunOptions.LoggingOfRunDuration);
                    }
                    catch (Exception Ex)
                    {
                        Log("Pak failed to extract because of " + Ex.GetType().ToString());
                    }
                }

                const string RootFailedContentDirectory = "\\\\epicgames.net\\root\\Developers\\Daniel.Lamb";

                string FailedContentDirectory = CombinePaths(RootFailedContentDirectory, CommandUtils.P4Env.BuildRootP4 + CommandUtils.P4Env.ChangelistString, Params.ShortProjectName, CookPlatformString);

                Directory.CreateDirectory(FailedContentDirectory);

                // diff the content
                List <FileInfo> FileReport = new List <FileInfo>();

                List <string> AllFiles = Directory.EnumerateFiles(FullCookPath, "*.uasset", System.IO.SearchOption.AllDirectories).ToList();
                AllFiles.AddRange(Directory.EnumerateFiles(FullCookPath, "*.umap", System.IO.SearchOption.AllDirectories).ToList());
                foreach (string SourceFilename in AllFiles)
                {
                    // Filename.StartsWith( CookedSandboxesPath );
                    string RelativeFilename = SourceFilename.Remove(0, FullCookPath.Length);

                    string DestFilename = TemporaryFilesPath + RelativeFilename;

                    Log("Comparing file " + RelativeFilename);

                    byte[] SourceFile = null;
                    try
                    {
                        SourceFile = File.ReadAllBytes(SourceFilename);
                    }
                    catch (Exception)
                    {
                        Log("Diff cooked content failed to load file " + SourceFilename);
                    }

                    byte[] DestFile = null;
                    try
                    {
                        DestFile = File.ReadAllBytes(DestFilename);
                    }
                    catch (Exception)
                    {
                        Log("Diff cooked content failed to load file " + DestFilename);
                    }

                    if (SourceFile == null || DestFile == null)
                    {
                        Log("Diff cooked content failed on file " + SourceFilename + " when comparing against " + DestFilename + " " + (SourceFile == null?SourceFilename:DestFilename) + " file is missing");
                    }
                    else if (SourceFile.LongLength == DestFile.LongLength)
                    {
                        /*long FirstByteFailed = -1;
                         * long BytesFailed = 0;*/

                        FileInfo DiffFileInfo = new FileInfo(SourceFilename);
                        DiffFileInfo.File1Size = DiffFileInfo.File2Size = SourceFile.LongLength;

                        bool bFailedDiff = false;
                        for (long Index = 0; Index < SourceFile.LongLength; ++Index)
                        {
                            if (SourceFile[Index] != DestFile[Index])
                            {
                                if (DiffFileInfo.FirstByteFailed == -1)
                                {
                                    DiffFileInfo.FirstByteFailed = Index;
                                }
                                DiffFileInfo.BytesMismatch += 1;

                                if (bFailedDiff == false)
                                {
                                    bFailedDiff = true;

                                    Log("Diff cooked content failed on file " + SourceFilename + " when comparing against " + DestFilename + " at offset " + Index.ToString());
                                    string SavedSourceFilename = CombinePaths(FailedContentDirectory, Path.GetFileName(SourceFilename) + "Source");
                                    string SavedDestFilename   = CombinePaths(FailedContentDirectory, Path.GetFileName(DestFilename) + "Dest");

                                    Log("Creating directory " + Path.GetDirectoryName(SavedSourceFilename));

                                    try
                                    {
                                        Directory.CreateDirectory(Path.GetDirectoryName(SavedSourceFilename));
                                    }
                                    catch (Exception E)
                                    {
                                        Log("Failed to create directory " + Path.GetDirectoryName(SavedSourceFilename) + " Exception " + E.ToString());
                                    }
                                    Log("Creating directory " + Path.GetDirectoryName(SavedDestFilename));
                                    try
                                    {
                                        Directory.CreateDirectory(Path.GetDirectoryName(SavedDestFilename));
                                    }
                                    catch (Exception E)
                                    {
                                        Log("Failed to create directory " + Path.GetDirectoryName(SavedDestFilename) + " Exception " + E.ToString());
                                    }
                                    File.Copy(SourceFilename, SavedSourceFilename, true);
                                    File.Copy(DestFilename, SavedDestFilename, true);
                                    Log("Content temporarily saved to " + SavedSourceFilename + " and " + SavedDestFilename + " at offset " + Index.ToString());
                                }
                                // break;
                            }
                        }
                        if (!bFailedDiff)
                        {
                            Log("Content matches for " + SourceFilename + " and " + DestFilename);
                        }
                        else
                        {
                            FileReport.Add(DiffFileInfo);
                        }
                    }
                    else
                    {
                        Log("Diff cooked content failed on file " + SourceFilename + " when comparing against " + DestFilename + " files are different sizes " + SourceFile.LongLength.ToString() + " " + DestFile.LongLength.ToString());

                        FileInfo DiffFileInfo = new FileInfo(SourceFilename);

                        DiffFileInfo.File1Size = SourceFile.LongLength;
                        DiffFileInfo.File2Size = DestFile.LongLength;

                        FileReport.Add(DiffFileInfo);
                    }
                }

                Log("Mismatching files:");
                foreach (var Report in FileReport)
                {
                    if (Report.FirstByteFailed == -1)
                    {
                        Log("File " + Report.Filename + " size mismatch: " + Report.File1Size + " VS " + Report.File2Size);
                    }
                    else
                    {
                        Log("File " + Report.Filename + " bytes mismatch: " + Report.BytesMismatch + " first byte failed at: " + Report.FirstByteFailed + " file size: " + Report.File1Size);
                    }
                }
            }
            catch (Exception Ex)
            {
                Log("Exception " + Ex.ToString());
                continue;
            }
        }
    }
 public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
 {
     // package up the program, potentially with an installer for Mac
     PrintRunTime();
 }
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        // Engine non-ufs (binaries)

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

        // 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 (!ShouldStageCommandLine(Params, SC))
                        {
                            if (!SC.IsCodeBasedProject)
                            {
                                BootstrapArguments = String.Format("..\\..\\..\\{0}\\{0}.uproject", SC.ShortProjectName);
                            }
                            else
                            {
                                BootstrapArguments = 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 IProcessResult RunClient(ERunOptions ClientRunFlags, string ClientApp, string ClientCmdLine, ProjectParams Params)
    {
        if (!File.Exists(ClientApp))
        {
            if (Directory.Exists(ClientApp + ".app"))
            {
                ClientApp += ".app/Contents/MacOS/" + Path.GetFileName(ClientApp);
            }
            else
            {
                Int32  BaseDirLen  = Params.BaseStageDirectory.Length;
                string StageSubDir = ClientApp.Substring(BaseDirLen, ClientApp.IndexOf("/", BaseDirLen + 1) - BaseDirLen);
                ClientApp = CombinePaths(Params.BaseStageDirectory, StageSubDir, Params.ShortProjectName + ".app/Contents/MacOS/" + Params.ShortProjectName);
            }
        }

        PushDir(Path.GetDirectoryName(ClientApp));
        // Always start client process and don't wait for exit.
        IProcessResult ClientProcess = Run(ClientApp, ClientCmdLine, null, ClientRunFlags | ERunOptions.NoWaitForExit);

        PopDir();

        return(ClientProcess);
    }
 public override void ExtractPackage(ProjectParams Params, string SourcePath, string DestinationPath)
 {
 }
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        // Stage all the build products
        foreach (StageTarget Target in SC.StageTargets)
        {
            SC.StageBuildProductsFromReceipt(Target.Receipt, Target.RequireFilesExist, Params.bTreatNonShippingBinariesAsDebugFiles);
        }

        if (SC.bStageCrashReporter)
        {
            string CrashReportClientPath = CombinePaths("Engine/Binaries", SC.PlatformDir, "CrashReportClient.app");
            StageAppBundle(SC, StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "CrashReportClient.app"), CrashReportClientPath);
        }

        // Find the app bundle path
        List <string> Exes = GetExecutableNames(SC);

        foreach (var Exe in Exes)
        {
            string AppBundlePath = "";
            if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir)))
            {
                AppBundlePath = CombinePaths(SC.ShortProjectName, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app");
            }
            else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir)))
            {
                AppBundlePath = CombinePaths("Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app");
            }

            // Copy the custom icon and Steam dylib, if needed
            if (!string.IsNullOrEmpty(AppBundlePath))
            {
                SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Build/Mac"), "Application.icns", false, null, CombinePaths(AppBundlePath, "Contents/Resources"), true);
            }
        }

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

        // 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
                    if (SC.NonUFSStagingFiles.ContainsKey(Executable.Path) && Executable.Path.Replace("\\", "/").Contains("/" + TargetPlatformType.ToString() + "/"))
                    {
                        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) + ".app";
                        }
                        else if (Params.IsCodeBasedProject)
                        {
                            BootstrapExeName = Target.Receipt.TargetName + ".app";
                        }
                        else
                        {
                            BootstrapExeName = SC.ShortProjectName + ".app";
                        }

                        string AppPath = Executable.Path.Substring(0, Executable.Path.LastIndexOf(".app/") + 4);
                        object Dest    = SC.NonUFSStagingFiles[Executable.Path];
                        foreach (var DestPath in SC.NonUFSStagingFiles[Executable.Path])
                        {
                            string AppRelativePath = DestPath.Substring(0, DestPath.LastIndexOf(".app/") + 4);
                            StageBootstrapExecutable(SC, BootstrapExeName, AppPath, AppRelativePath, BootstrapArguments);
                        }
                    }
                }
            }
        }

        // Copy the ShaderCache files, if they exist
        SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Content"), "DrawCache.ushadercache", false, null, null, true);
        SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Content"), "ByteCodeCache.ushadercode", false, null, null, true);
    }
Beispiel #30
0
 /// <summary>
 /// Get the files to deploy, specific to this platform, typically binaries
 /// </summary>
 /// <param name="SC">Deployment Context</param>
 public virtual void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
 {
     throw new AutomationException("{0} does not yet implement GetFilesToDeployOrStage.", PlatformType);
 }