Пример #1
0
    private void ExportFileToDirectory(UploadedFile file, DirectoryInfo destination, IEnumerable <string> cultures)
    {
        foreach (var culture in cultures)
        {
            var cultureDirectory = new DirectoryInfo(Path.Combine(destination.FullName, culture));
            if (!cultureDirectory.Exists)
            {
                cultureDirectory.Create();
            }

            using (var memoryStream = new MemoryStream())
            {
                var exportFile = new FileInfo(Path.Combine(cultureDirectory.FullName, file.Filename));

                var exportTranslationState = file.ExportTranslation(culture, memoryStream).Result;
                if (exportTranslationState == UploadedFile.ExportTranslationState.Success)
                {
                    memoryStream.Position = 0;
                    using (Stream fileStream = File.OpenWrite(exportFile.FullName))
                    {
                        memoryStream.CopyTo(fileStream);
                        Console.WriteLine("[SUCCESS] Exporting: " + exportFile.FullName + " Locale: " + culture);
                    }
                    FileInfo exportFileCopy = new FileInfo(Path.Combine(exportFile.DirectoryName, Path.GetFileNameWithoutExtension(exportFile.Name) + "_FromOneSky" + exportFile.Extension));
                    // Add/check out backed up POs from OneSky.
                    if (P4Enabled)
                    {
                        UE4Build.AddBuildProductsToChangelist(OneSkyDownloadedPOChangeList, new List <string>()
                        {
                            exportFileCopy.FullName
                        });
                    }
                    File.Copy(exportFile.FullName, exportFileCopy.FullName, true);
                }
                else if (exportTranslationState == UploadedFile.ExportTranslationState.NoContent)
                {
                    Console.WriteLine("[WARNING] Exporting: " + exportFile.FullName + " Locale: " + culture + " has no translations!");
                }
                else
                {
                    Console.WriteLine("[FAILED] Exporting: " + exportFile.FullName + " Locale: " + culture);
                }
            }
        }
    }
    public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1, ProjectBuildTargets TargetMask = ProjectBuildTargets.All)
    {
        Params.ValidateAndLog();

        if (!Params.Build)
        {
            return;
        }

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

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

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

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

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

            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatformType in UniquePlatformTypes)
                {
                    string AdditionalArgs = GetBlueprintPluginPathArgument(Params, true, ClientPlatformType);
                    AdditionalArgs += " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"";
                    if (Params.IsCodeBasedProject == false)
                    {
                        AdditionalArgs += " -project=\"" + Path.GetFullPath(Params.RawProjectPath.FullName) + "\"";
                    }
                    CrashReportPlatforms.Add(ClientPlatformType);
                    Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: 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)
                {
                    string AdditionalArgs = GetBlueprintPluginPathArgument(Params, false, ServerPlatformType);
                    AdditionalArgs += " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"";
                    if (Params.IsCodeBasedProject == false)
                    {
                        AdditionalArgs += " -project=\"" + Path.GetFullPath(Params.RawProjectPath.FullName) + "\"";
                    }

                    CrashReportPlatforms.Add(ServerPlatformType);
                    Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatformType, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: 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 (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform))
                {
                    Agenda.AddTarget("CrashReportClient", CrashReportPlatform, UnrealTargetConfiguration.Shipping);
                }
            }
        }
        if (Params.HasProgramTargets && (TargetMask & ProjectBuildTargets.Programs) == ProjectBuildTargets.Programs)
        {
            List <UnrealTargetPlatform> UniquePlatformTypes = Params.ClientTargetPlatforms.ConvertAll(x => x.Type).Distinct().ToList();

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

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

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

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

        Log("********** BUILD COMMAND COMPLETED **********");
    }
Пример #3
0
    public override void ExecuteBuild()
    {
        int WorkingCL = -1;

        if (P4Enabled && AllowSubmit)
        {
            string CmdLine = "";
            foreach (var Arg in Params)
            {
                CmdLine += Arg.ToString() + " ";
            }
            WorkingCL = P4.CreateChange(P4Env.Client, String.Format("MegaXGE build from changelist {0} - Params: {1}", P4Env.Changelist, CmdLine));
        }

        LogInformation("************************* MegaXGE");

        bool   Clean             = ParseParam("Clean");
        string CleanToolLocation = CombinePaths(CmdEnv.LocalRoot, "Engine", "Build", "Batchfiles", "Clean.bat");

        bool ShowProgress = ParseParam("Progress");

        var UE4Build = new UE4Build(this);

        var Agenda = new UE4Build.BuildAgenda();

        // we need to always build UHT when we use mega XGE
        var ProgramTargets = new string[]
        {
            "UnrealHeaderTool",
        };

        Agenda.AddTargets(ProgramTargets, UnrealTargetPlatform.Win64, UnrealTargetConfiguration.Development);
        if (Clean)
        {
            LogSetProgress(ShowProgress, "Cleaning previous builds...");
            foreach (var CurTarget in ProgramTargets)
            {
                string Args = String.Format("{0} {1} {2}", CurTarget, UnrealTargetPlatform.Win64.ToString(), UnrealTargetConfiguration.Development.ToString());
                RunAndLog(CmdEnv, CleanToolLocation, Args);
            }
        }

        LogInformation("*************************");
        for (int Arg = 1; Arg < 100; Arg++)
        {
            string Parm   = String.Format("Target{0}", Arg);
            string Target = ParseParamValue(Parm, "");
            if (String.IsNullOrEmpty(Target))
            {
                break;
            }

            FileReference ProjectFile = null;

            string ProjectFileParam = ParseParamValue(String.Format("Project{0}", Arg), null);
            if (ProjectFileParam != null)
            {
                ProjectFile = new FileReference(ProjectFileParam);
                if (!FileReference.Exists(ProjectFile))
                {
                    throw new AutomationException("Project file '{0}' could not be found");
                }
            }

            var Parts = Target.Split(' ');

            string JustTarget = Parts[0];
            if (String.IsNullOrEmpty(JustTarget))
            {
                throw new AutomationException("BUILD FAILED target option '{0}' not parsed.", Target);
            }
            var Targets = JustTarget.Split('|');
            if (Targets.Length < 1)
            {
                throw new AutomationException("BUILD FAILED target option '{0}' not parsed.", Target);
            }

            var Platforms      = new List <UnrealTargetPlatform>();
            var Configurations = new List <UnrealTargetConfiguration>();

            for (int Part = 1; Part < Parts.Length; Part++)
            {
                if (!String.IsNullOrEmpty(Parts[Part]))
                {
                    var SubParts = Parts[Part].Split('|');

                    foreach (var SubPart in SubParts)
                    {
                        UnrealTargetPlatform Platform;
                        if (UnrealTargetPlatform.TryParse(SubPart, out Platform))
                        {
                            Platforms.Add(Platform);
                        }
                        else
                        {
                            switch (SubPart.ToUpperInvariant())
                            {
                            case "DEBUG":
                                Configurations.Add(UnrealTargetConfiguration.Debug);
                                break;

                            case "DEBUGGAME":
                                Configurations.Add(UnrealTargetConfiguration.DebugGame);
                                break;

                            case "DEVELOPMENT":
                                Configurations.Add(UnrealTargetConfiguration.Development);
                                break;

                            case "SHIPPING":
                                Configurations.Add(UnrealTargetConfiguration.Shipping);
                                break;

                            case "TEST":
                                Configurations.Add(UnrealTargetConfiguration.Test);
                                break;

                            default:
                                throw new AutomationException("BUILD FAILED target option {0} not recognized.", SubPart);
                            }
                        }
                    }
                }
            }
            if (Platforms.Count < 1)
            {
                Platforms.Add(UnrealTargetPlatform.Win64);
            }
            if (Configurations.Count < 1)
            {
                Configurations.Add(UnrealTargetConfiguration.Development);
            }
            foreach (var Platform in Platforms)
            {
                foreach (var CurTarget in Targets)
                {
                    foreach (var Configuration in Configurations)
                    {
                        Agenda.AddTargets(new string[] { CurTarget }, Platform, Configuration, ProjectFile);
                        LogInformation("Target {0} {1} {2}", CurTarget, Platform.ToString(), Configuration.ToString());
                        if (Clean)
                        {
                            string Args = String.Format("{0} {1} {2}", CurTarget, Platform.ToString(), Configuration.ToString());
                            RunAndLog(CmdEnv, CleanToolLocation, Args);
                        }
                    }
                }
            }
        }
        LogInformation("*************************");

        UE4Build.Build(Agenda, InUpdateVersionFiles: IsBuildMachine, InUseParallelExecutor: ParseParam("useparallelexecutor"), InShowProgress: ShowProgress);

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

        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);

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

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

            int SubmittedCL;
            P4.Submit(WorkingCL, out SubmittedCL, true, true);
        }

        PrintRunTime();
    }
Пример #4
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 && !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);
            }
        }

        string ScriptPluginArgs = "";

        // if we're utilizing an auto-generated code plugin/module (a product of
        // the cook process), make sure to compile it along with the targets here
        if (Params.RunAssetNativization)
        {
            // Add every plugin:
            foreach (var CodePlugin in  Params.BlueprintPluginPaths)
            {
                ScriptPluginArgs = "-PLUGIN \"" + CodePlugin + "\"";
            }
        }

        // Setup cooked targets
        if (Params.HasClientCookedTargets && (TargetMask & ProjectBuildTargets.ClientCooked) == ProjectBuildTargets.ClientCooked)
        {
            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                {
                    CrashReportPlatforms.Add(ClientPlatform);
                    Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: ScriptPluginArgs + " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"");
                }
            }
        }
        if (Params.HasServerCookedTargets && (TargetMask & ProjectBuildTargets.ServerCooked) == ProjectBuildTargets.ServerCooked)
        {
            foreach (var BuildConfig in Params.ServerConfigsToBuild)
            {
                foreach (var ServerPlatform in Params.ServerTargetPlatforms)
                {
                    CrashReportPlatforms.Add(ServerPlatform);
                    Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: ScriptPluginArgs + " -remoteini=\"" + Params.RawProjectPath.Directory.FullName + "\"");
                }
            }
        }
        if (!Params.NoBootstrapExe && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.Bootstrap) == ProjectBuildTargets.Bootstrap)
        {
            UnrealBuildTool.UnrealTargetPlatform[] BootstrapPackagedGamePlatforms = { UnrealBuildTool.UnrealTargetPlatform.Win32, UnrealBuildTool.UnrealTargetPlatform.Win64 };
            foreach (UnrealBuildTool.UnrealTargetPlatform BootstrapPackagedGamePlatform in BootstrapPackagedGamePlatforms)
            {
                if (Params.ClientTargetPlatforms.Contains(BootstrapPackagedGamePlatform))
                {
                    Agenda.AddTarget("BootstrapPackagedGame", BootstrapPackagedGamePlatform, UnrealBuildTool.UnrealTargetConfiguration.Shipping);
                }
            }
        }
        if (Params.CrashReporter && !Automation.IsEngineInstalled() && (TargetMask & ProjectBuildTargets.CrashReporter) == ProjectBuildTargets.CrashReporter)
        {
            foreach (var CrashReportPlatform in CrashReportPlatforms)
            {
                if (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform))
                {
                    Agenda.AddTarget("CrashReportClient", CrashReportPlatform, UnrealTargetConfiguration.Shipping);
                }
            }
        }
        if (Params.HasProgramTargets && (TargetMask & ProjectBuildTargets.Programs) == ProjectBuildTargets.Programs)
        {
            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                {
                    Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath);
                }
            }
        }
        UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0);

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

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

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

        Log("********** BUILD COMMAND COMPLETED **********");
    }
Пример #5
0
    public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1)
    {
        Params.ValidateAndLog();

        if (!Params.Build)
        {
            return;
        }

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

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

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

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

        // Setup cooked targets
        if (Params.HasClientCookedTargets)
        {
            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                {
                    CrashReportPlatforms.Add(ClientPlatform);
                    Agenda.AddTargets(Params.ClientCookedTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Path.GetDirectoryName(Params.RawProjectPath) + "\"");
                }
            }
        }
        if (Params.HasServerCookedTargets)
        {
            foreach (var BuildConfig in Params.ServerConfigsToBuild)
            {
                foreach (var ServerPlatform in Params.ServerTargetPlatforms)
                {
                    CrashReportPlatforms.Add(ServerPlatform);
                    Agenda.AddTargets(Params.ServerCookedTargets.ToArray(), ServerPlatform, BuildConfig, Params.CodeBasedUprojectPath, InAddArgs: " -remoteini=\"" + Path.GetDirectoryName(Params.RawProjectPath) + "\"");
                }
            }
        }
        if (Params.CrashReporter && !Params.Rocket)
        {
            var CrashReportClientTarget = new[] { "CrashReportClient" };
            foreach (var CrashReportPlatform in CrashReportPlatforms)
            {
                if (UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(CrashReportPlatform))
                {
                    Agenda.AddTargets(CrashReportClientTarget, CrashReportPlatform, UnrealTargetConfiguration.Development);
                }
            }
        }
        if (Params.HasProgramTargets && !Params.Rocket)
        {
            foreach (var BuildConfig in Params.ClientConfigsToBuild)
            {
                foreach (var ClientPlatform in Params.ClientTargetPlatforms)
                {
                    Agenda.AddTargets(Params.ProgramTargets.ToArray(), ClientPlatform, BuildConfig, Params.CodeBasedUprojectPath);
                }
            }
        }
        UE4Build.Build(Agenda, InDeleteBuildProducts: Params.Clean, InUpdateVersionFiles: WorkingCL > 0);

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

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

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

        Log("********** BUILD COMMAND COMPLETED **********");
    }
Пример #6
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
                                });
                            }
                        }
                    }
                }
            }
        }
        private void ExportOneSkyFileToDirectory(UploadedFile OneSkyFile, DirectoryInfo DestinationDirectory, string DestinationFilename, IEnumerable <string> Cultures, bool bUseCultureDirectory, int OneSkyDownloadedPOChangeList)
        {
            foreach (var Culture in Cultures)
            {
                var CultureDirectory = (bUseCultureDirectory) ? new DirectoryInfo(Path.Combine(DestinationDirectory.FullName, Culture)) : DestinationDirectory;
                if (!CultureDirectory.Exists)
                {
                    CultureDirectory.Create();
                }

                using (var MemoryStream = new MemoryStream())
                {
                    var ExportTranslationState = OneSkyFile.ExportTranslation(Culture, MemoryStream).Result;
                    if (ExportTranslationState == UploadedFile.ExportTranslationState.Success)
                    {
                        var ExportFile = new FileInfo(Path.Combine(CultureDirectory.FullName, DestinationFilename));

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

                            MemoryStream.Position = 0;
                            using (Stream FileStream = ExportFile.OpenWrite())
                            {
                                MemoryStream.CopyTo(FileStream);
                                Console.WriteLine("[SUCCESS] Exporting: '{0}' as '{1}' ({2})", OneSkyFile.Filename, ExportFile.FullName, Culture);
                            }

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

                        // Also update the back-up copy so we can diff against what we got from OneSky, and what the gather commandlet produced
                        {
                            var ExportFileCopy = new FileInfo(Path.Combine(ExportFile.DirectoryName, String.Format("{0}_FromOneSky{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(OneSkyDownloadedPOChangeList, new List <string>()
                                {
                                    ExportFileCopy.FullName
                                });
                            }
                        }
                    }
                    else if (ExportTranslationState == UploadedFile.ExportTranslationState.NoContent)
                    {
                        Console.WriteLine("[WARNING] Exporting: '{0}' ({1}) has no translations!", OneSkyFile.Filename, Culture);
                    }
                    else
                    {
                        Console.WriteLine("[FAILED] Exporting: '{0}' ({1})", OneSkyFile.Filename, Culture);
                    }
                }
            }
        }
Пример #8
0
    public override void Package(ProjectParams Params, DeploymentContext SC, int WorkingCL)
    {
        Log("Package {0}", Params.RawProjectPath);

        // ensure the ue4game binary exists, if applicable
        string FullExePath = CombinePaths(Path.GetDirectoryName(Params.ProjectGameExeFilename), SC.StageExecutables[0] + (UnrealBuildTool.BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac ? ".stub" : ""));

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

        //@TODO: We should be able to use this code on both platforms, when the following issues are sorted:
        //   - Raw executable is unsigned & unstripped (need to investigate adding stripping to IPP)
        //   - IPP needs to be able to codesign a raw directory
        //   - IPP needs to be able to take a .app directory instead of a Payload directory when doing RepackageFromStage (which would probably be renamed)
        //   - Some discrepancy in the loading screen pngs that are getting packaged, which needs to be investigated
        //   - Code here probably needs to be updated to write 0 byte files as 1 byte (difference with IPP, was required at one point when using Ionic.Zip to prevent issues on device, maybe not needed anymore?)
        if (UnrealBuildTool.BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac)
        {
            // copy in all of the artwork and plist
            var DeployHandler = UEBuildDeploy.GetBuildDeploy(UnrealTargetPlatform.IOS);

            DeployHandler.PrepForUATPackageOrDeploy(Params.ShortProjectName,
                                                    Path.GetDirectoryName(Params.RawProjectPath),
                                                    CombinePaths(Path.GetDirectoryName(Params.ProjectGameExeFilename), SC.StageExecutables[0]),
                                                    CombinePaths(SC.LocalRoot, "Engine"),
                                                    Params.Distribution,
                                                    "",
                                                    false);

            // figure out where to pop in the staged files
            string AppDirectory = string.Format("{0}/Payload/{1}.app",
                                                Path.GetDirectoryName(Params.ProjectGameExeFilename),
                                                Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename));

            // delete the old cookeddata
            InternalUtils.SafeDeleteDirectory(AppDirectory + "/cookeddata", true);
            InternalUtils.SafeDeleteFile(AppDirectory + "/ue4commandline.txt", true);

            if (!Params.IterativeDeploy)
            {
                // copy the Staged files to the AppDirectory
                string[] StagedFiles = Directory.GetFiles(SC.StageDirectory, "*", SearchOption.AllDirectories);
                foreach (string Filename in StagedFiles)
                {
                    string DestFilename = Filename.Replace(SC.StageDirectory, AppDirectory);
                    Directory.CreateDirectory(Path.GetDirectoryName(DestFilename));
                    InternalUtils.SafeCopyFile(Filename, DestFilename, true);
                }
            }
            else
            {
                // copy just the root stage directory files
                string[] StagedFiles = Directory.GetFiles(SC.StageDirectory, "*", SearchOption.TopDirectoryOnly);
                foreach (string Filename in StagedFiles)
                {
                    string DestFilename = Filename.Replace(SC.StageDirectory, AppDirectory);
                    Directory.CreateDirectory(Path.GetDirectoryName(DestFilename));
                    InternalUtils.SafeCopyFile(Filename, DestFilename, true);
                }
            }
        }

        if (SC.StageTargetConfigurations.Count != 1)
        {
            throw new AutomationException("iOS is currently only able to package one target configuration at a time, but StageTargetConfigurations contained {0} configurations", SC.StageTargetConfigurations.Count);
        }
        bCreatedIPA = false;
        bool bNeedsIPA = false;

        if (Params.IterativeDeploy)
        {
            String NonUFSManifestPath = SC.GetNonUFSDeploymentDeltaPath();
            // check to determine if we need to update the IPA
            if (File.Exists(NonUFSManifestPath))
            {
                string   NonUFSFiles = File.ReadAllText(NonUFSManifestPath);
                string[] Lines       = NonUFSFiles.Split('\n');
                bNeedsIPA = Lines.Length > 0 && !string.IsNullOrWhiteSpace(Lines[0]);
            }
        }

        if (UnrealBuildTool.BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
        {
            var TargetConfiguration = SC.StageTargetConfigurations[0];
            var ProjectIPA          = MakeIPAFileName(TargetConfiguration, Params);
            var ProjectStub         = Path.GetFullPath(Params.ProjectGameExeFilename);

            // package a .ipa from the now staged directory
            var IPPExe = CombinePaths(CmdEnv.LocalRoot, "Engine/Binaries/DotNET/IOS/IPhonePackager.exe");

            Log("ProjectName={0}", Params.ShortProjectName);
            Log("ProjectStub={0}", ProjectStub);
            Log("ProjectIPA={0}", ProjectIPA);
            Log("IPPExe={0}", IPPExe);

            bool cookonthefly = Params.CookOnTheFly || Params.SkipCookOnTheFly;

            // if we are incremental check to see if we need to even update the IPA
            if (!Params.IterativeDeploy || !File.Exists(ProjectIPA) || bNeedsIPA)
            {
                // delete the .ipa to make sure it was made
                DeleteFile(ProjectIPA);

                bCreatedIPA = true;

                if (RemoteToolChain.bUseRPCUtil)
                {
                    string IPPArguments = "RepackageFromStage \"" + (Params.IsCodeBasedProject ? Params.RawProjectPath : "Engine") + "\"";
                    IPPArguments += " -config " + TargetConfiguration.ToString();

                    if (TargetConfiguration == UnrealTargetConfiguration.Shipping)
                    {
                        IPPArguments += " -compress=best";
                    }

                    // Determine if we should sign
                    bool bNeedToSign = GetCodeSignDesirability(Params);

                    if (!String.IsNullOrEmpty(Params.BundleName))
                    {
                        // Have to sign when a bundle name is specified
                        bNeedToSign   = true;
                        IPPArguments += " -bundlename " + Params.BundleName;
                    }

                    if (bNeedToSign)
                    {
                        IPPArguments += " -sign";
                        if (Params.Distribution)
                        {
                            IPPArguments += " -distribution";
                        }
                    }

                    IPPArguments += (cookonthefly ? " -cookonthefly" : "");
                    IPPArguments += " -stagedir \"" + CombinePaths(Params.BaseStageDirectory, "IOS") + "\"";
                    IPPArguments += " -project \"" + Params.RawProjectPath + "\"";
                    if (Params.IterativeDeploy)
                    {
                        IPPArguments += " -iterate";
                    }

                    RunAndLog(CmdEnv, IPPExe, IPPArguments);
                }
                else
                {
                    List <string> IPPArguments = new List <string>();
                    IPPArguments.Add("RepackageFromStage");
                    IPPArguments.Add(Params.IsCodeBasedProject ? Params.RawProjectPath : "Engine");
                    IPPArguments.Add("-config");
                    IPPArguments.Add(TargetConfiguration.ToString());

                    if (TargetConfiguration == UnrealTargetConfiguration.Shipping)
                    {
                        IPPArguments.Add("-compress=best");
                    }

                    // Determine if we should sign
                    bool bNeedToSign = GetCodeSignDesirability(Params);

                    if (!String.IsNullOrEmpty(Params.BundleName))
                    {
                        // Have to sign when a bundle name is specified
                        bNeedToSign = true;
                        IPPArguments.Add("-bundlename");
                        IPPArguments.Add(Params.BundleName);
                    }

                    if (bNeedToSign)
                    {
                        IPPArguments.Add("-sign");
                    }

                    if (cookonthefly)
                    {
                        IPPArguments.Add(" -cookonthefly");
                    }
                    IPPArguments.Add(" -stagedir");
                    IPPArguments.Add(CombinePaths(Params.BaseStageDirectory, "IOS"));
                    IPPArguments.Add(" -project");
                    IPPArguments.Add(Params.RawProjectPath);
                    if (Params.IterativeDeploy)
                    {
                        IPPArguments.Add(" -iterate");
                    }

                    if (RunIPP(IPPArguments.ToArray()) != 0)
                    {
                        throw new AutomationException("IPP Failed");
                    }
                }
            }

            // verify the .ipa exists
            if (!FileExists(ProjectIPA))
            {
                throw new AutomationException(ErrorCodes.Error_FailedToCreateIPA, "PACKAGE FAILED - {0} was not created", ProjectIPA);
            }

            if (WorkingCL > 0)
            {
                // Open files for add or edit
                var ExtraFilesToCheckin = new List <string>
                {
                    ProjectIPA
                };

                // check in the .ipa along with everything else
                UE4Build.AddBuildProductsToChangelist(WorkingCL, ExtraFilesToCheckin);
            }

            //@TODO: This automatically deploys after packaging, useful for testing on PC when iterating on IPP
            //Deploy(Params, SC);
        }
        else
        {
            // create the ipa
            string IPAName = CombinePaths(Path.GetDirectoryName(Params.RawProjectPath), "Binaries", "IOS", (Params.Distribution ? "Distro_" : "") + Params.ShortProjectName + (SC.StageTargetConfigurations[0] != UnrealTargetConfiguration.Development ? ("-IOS-" + SC.StageTargetConfigurations[0].ToString()) : "") + ".ipa");

            if (!Params.IterativeDeploy || !File.Exists(IPAName) || bNeedsIPA)
            {
                bCreatedIPA = true;

                // code sign the app
                CodeSign(Path.GetDirectoryName(Params.ProjectGameExeFilename), Params.IsCodeBasedProject ? Params.ShortProjectName : Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename), Params.RawProjectPath, SC.StageTargetConfigurations[0], SC.LocalRoot, Params.ShortProjectName, Path.GetDirectoryName(Params.RawProjectPath), SC.IsCodeBasedProject, Params.Distribution);

                // now generate the ipa
                PackageIPA(Path.GetDirectoryName(Params.ProjectGameExeFilename), Params.IsCodeBasedProject ? Params.ShortProjectName : Path.GetFileNameWithoutExtension(Params.ProjectGameExeFilename), Params.ShortProjectName, Path.GetDirectoryName(Params.RawProjectPath), SC.StageTargetConfigurations[0], Params.Distribution);
            }
        }

        PrintRunTime();
    }
Пример #9
0
    public static void Build(BuildCommand Command, ProjectParams Params, int WorkingCL = -1, ProjectBuildTargets TargetMask = ProjectBuildTargets.All)
    {
        Params.ValidateAndLog();

        if (!Params.Build)
        {
            return;
        }
        if (CommandUtils.IsEngineInstalled() && !Params.IsCodeBasedProject)
        {
            return;
        }

        LogInformation("********** 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) && (TargetMask & ProjectBuildTargets.Editor) == ProjectBuildTargets.Editor)
        {
            // @todo Mac: proper platform detection
            UnrealTargetPlatform            EditorPlatform      = HostPlatform.Current.HostEditorPlatform;
            const UnrealTargetConfiguration EditorConfiguration = UnrealTargetConfiguration.Development;

            Agenda.AddTargets(Params.EditorTargets.ToArray(), EditorPlatform, EditorConfiguration, Params.CodeBasedUprojectPath);

            if (!CommandUtils.IsEngineInstalled())
            {
                CrashReportPlatforms.Add(EditorPlatform);
                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.FileServer && Params.EditorTargets.Contains("UnrealFileServer") == false)
                {
                    Agenda.AddTargets(new string[] { "UnrealFileServer" }, EditorPlatform, EditorConfiguration);
                }
            }
        }

        // allow all involved platforms to hook into the agenda
        HashSet <UnrealTargetPlatform> UniquePlatforms = new HashSet <UnrealTargetPlatform>();

        UniquePlatforms.UnionWith(Params.ClientTargetPlatforms.Select(x => x.Type));
        UniquePlatforms.UnionWith(Params.ServerTargetPlatforms.Select(x => x.Type));
        foreach (UnrealTargetPlatform TargetPlatform in UniquePlatforms)
        {
            Platform.GetPlatform(TargetPlatform).PreBuildAgenda(UE4Build, Agenda);
        }

        // Build any tools we need to stage
        if ((TargetMask & ProjectBuildTargets.UnrealPak) == ProjectBuildTargets.UnrealPak && !CommandUtils.IsEngineInstalled())
        {
            if (Params.EditorTargets.Contains("UnrealPak") == false)
            {
                Agenda.AddTargets(new string[] { "UnrealPak" }, HostPlatform.Current.HostEditorPlatform, UnrealTargetConfiguration.Development, Params.CodeBasedUprojectPath);
            }
        }

        // Additional compile arguments
        string AdditionalArgs = "";

        if (string.IsNullOrEmpty(Params.UbtArgs) == false)
        {
            string Arg = Params.UbtArgs;
            Arg             = Arg.TrimStart(new char[] { '\"' });
            Arg             = Arg.TrimEnd(new char[] { '\"' });
            AdditionalArgs += " " + Arg;
        }

        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
        }

        if (Params.Distribution)
        {
            AdditionalArgs += " -distribution";
        }

        // 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 && !CommandUtils.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 && !CommandUtils.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);
        }

        LogInformation("********** BUILD COMMAND COMPLETED **********");
    }
Пример #10
0
    public override void ExecuteBuild()
    {
        // get the project
        var UProjectFileName = ParseParamValue("Project");

        if (UProjectFileName == null)
        {
            throw new AutomationException("Project was not specified via the -project argument.");
        }

        // Get the list of targets
        var TargetList = ParseParamList("Target");

        if (TargetList == null)
        {
            throw new AutomationException("Target was not specified via the -target argument.");
        }

        // get the list of platforms
        var PlatformList = ParseParamList("TargetPlatforms", "Win64");
        List <UnrealTargetPlatform> TargetPlatforms = new List <UnrealTargetPlatform>();

        foreach (string Platform in PlatformList)
        {
            TargetPlatforms.Add((UnrealTargetPlatform)Enum.Parse(typeof(UnrealTargetPlatform), Platform, true));
        }

        // get the list configurations
        var ConfigList = ParseParamList("Config", "Development");
        List <UnrealTargetConfiguration> ConfigsToBuild = new List <UnrealTargetConfiguration>();

        foreach (string Config in ConfigList)
        {
            ConfigsToBuild.Add((UnrealTargetConfiguration)Enum.Parse(typeof(UnrealTargetConfiguration), Config, true));
        }

        // parse any extra parameters
        bool bClean    = ParseParam("Clean");
        int  WorkingCL = ParseParamInt("P4Change");

        FileReference UProjectFileReference = new FileReference(UProjectFileName);

        // add the targets to the agenda
        // verify the targets and add them to the agenda
        var Properties = ProjectUtils.GetProjectProperties(UProjectFileReference);

        UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();
        foreach (string Target in TargetList)
        {
            SingleTargetProperties TargetData;
            if (!Properties.Targets.TryGetValue((TargetRules.TargetType)Enum.Parse(typeof(TargetRules.TargetType), Target), out TargetData))
            {
                throw new AutomationException("Project does not support specified target: {0}", Target);
            }

            foreach (UnrealTargetPlatform TargetPlatform in TargetPlatforms)
            {
                if (TargetData.Rules.SupportsPlatform(TargetPlatform))
                {
                    List <UnrealTargetConfiguration> SupportedConfigurations = new List <UnrealTargetConfiguration>();
                    TargetData.Rules.GetSupportedConfigurations(ref SupportedConfigurations, true);

                    foreach (UnrealTargetConfiguration TargetConfig in ConfigsToBuild)
                    {
                        if (SupportedConfigurations.Contains(TargetConfig))
                        {
                            Agenda.AddTarget(TargetData.TargetName, TargetPlatform, TargetConfig, UProjectFileReference);
                        }
                        else
                        {
                            Log("{0} doesn't support the {1} configuration. It will not be built.", TargetData.TargetName, TargetConfig);
                        }
                    }
                }
                else
                {
                    Log("{0} doesn't support the {1} platform. It will not be built.", TargetData.TargetName, TargetPlatform);
                }
            }
        }


        // build it
        UE4Build Build = new UE4Build(this);

        Build.Build(Agenda, InDeleteBuildProducts: bClean, InUpdateVersionFiles: WorkingCL > 0);

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

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

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