public override void ExecuteBuild()
    {
        var Build         = new UE4Build(this);
        var Agenda        = new UE4Build.BuildAgenda();
        var Platform      = UnrealBuildTool.UnrealTargetPlatform.Win64;
        var Configuration = UnrealBuildTool.UnrealTargetConfiguration.Development;
        var Targets       = new List <string>();

        foreach (var ObjParam in Params)
        {
            var Param = (string)ObjParam;
            if (!UnrealTargetPlatform.TryParse(Param, out Platform))
            {
                continue;
            }
            UnrealBuildTool.UnrealTargetConfiguration ParseConfiguration;
            if (Enum.TryParse <UnrealBuildTool.UnrealTargetConfiguration>(Param, true, out ParseConfiguration))
            {
                Configuration = ParseConfiguration;
                continue;
            }
            if (String.Compare("NoXGE", Param, true) != 0 && String.Compare("Clean", Param, true) != 0)
            {
                Targets.Add(Param);
            }
        }

        var Clean = ParseParam("Clean");

        Agenda.AddTargets(Targets.ToArray(), Platform, Configuration);

        LogInformation("UBT Buid");
        LogInformation("Targets={0}", String.Join(",", Targets));
        LogInformation("Platform={0}", Platform);
        LogInformation("Configuration={0}", Configuration);
        LogInformation("Clean={0}", Clean);

        Build.Build(Agenda, InUpdateVersionFiles: false);

        LogInformation("UBT Completed");
    }
    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 **********");
    }
Esempio n. 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();
    }
Esempio n. 4
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 **********");
    }
Esempio n. 5
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 **********");
    }
Esempio n. 6
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 **********");
    }