public BranchUProject()
 {
     GameName   = "UE4";
     Properties = ProjectUtils.GetProjectProperties(null);
     if (!Properties.Targets.ContainsKey(TargetType.Editor))
     {
         throw new AutomationException("Base UE4 project did not contain an editor target.");
     }
 }
예제 #2
0
            public BranchUProject(UnrealBuildTool.UProjectInfo InfoEntry)
            {
                GameName = InfoEntry.GameName;

                //not sure what the heck this path is relative to
                FilePath = InfoEntry.FilePath;

                if (!CommandUtils.FileExists_NoExceptions(FilePath.FullName))
                {
                    throw new AutomationException("Could not resolve relative path corrctly {0} -> {1} which doesn't exist.", InfoEntry.FilePath, FilePath);
                }

                Properties = ProjectUtils.GetProjectProperties(FilePath);
            }
            public BranchUProject(FileReference ProjectFile)
            {
                GameName = ProjectFile.GetFileNameWithoutExtension();

                //not sure what the heck this path is relative to
                FilePath = ProjectFile;

                if (!CommandUtils.FileExists_NoExceptions(FilePath.FullName))
                {
                    throw new AutomationException("Could not resolve relative path corrctly {0} -> {1} which doesn't exist.", ProjectFile, FilePath);
                }

                Properties = ProjectUtils.GetProjectProperties(FilePath);
            }
예제 #4
0
            public BranchUProject(UnrealBuildTool.UProjectInfo InfoEntry)
            {
                GameName = InfoEntry.GameName;

                //not sure what the heck this path is relative to
                FilePath = Path.GetFullPath(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Engine", "Binaries", InfoEntry.FilePath));

                if (!CommandUtils.FileExists_NoExceptions(FilePath))
                {
                    throw new AutomationException("Could not resolve relative path corrctly {0} -> {1} which doesn't exist.", InfoEntry.FilePath, FilePath);
                }

                Properties = ProjectUtils.GetProjectProperties(Path.GetFullPath(FilePath));
            }
예제 #5
0
        public override ExitCode Execute()
        {
            string EditorPath = HostPlatform.Current.GetUE4ExePath("UE4Editor");

            string EditorArgs = "";

            ProjectName = ParseParamValue("project", ProjectName);

            if (!String.IsNullOrEmpty(ProjectName))
            {
                FileReference ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName);

                if (ProjectFile == null)
                {
                    throw new AutomationException("Unable to find uproject file for {0}", ProjectName);
                }

                EditorArgs = ProjectFile.FullName;
            }

            Run(EditorPath, EditorArgs, null, ERunOptions.NoWaitForExit);

            return(ExitCode.Success);
        }
예제 #6
0
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="CommandLine">Command line</param>
        public static void Process(string[] CommandLine)
        {
            // Initial check for local or build machine runs BEFORE we parse the command line (We need this value set
            // in case something throws the exception while parsing the command line)
            IsBuildMachine = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("uebp_LOCAL_ROOT"));

            // Scan the command line for commands to execute.
            var CommandsToExecute        = new List <CommandInfo>();
            var AdditionalScriptsFolders = new List <string>();

            ParseCommandLine(CommandLine, CommandsToExecute, AdditionalScriptsFolders);

            // Check for build machine override (force local)
            IsBuildMachine = GlobalCommandLine.ForceLocal ? false : IsBuildMachine;
            Log.TraceInformation("IsBuildMachine={0}", IsBuildMachine);
            Environment.SetEnvironmentVariable("IsBuildMachine", IsBuildMachine ? "1" : "0");

            // should we kill processes on exit
            ShouldKillProcesses = !GlobalCommandLine.NoKill;
            Log.TraceInformation("ShouldKillProcesses={0}", ShouldKillProcesses);

            if (CommandsToExecute.Count == 0 && GlobalCommandLine.Help)
            {
                DisplayHelp();
                return;
            }

            // Disable AutoSDKs if specified on the command line
            if (GlobalCommandLine.NoAutoSDK)
            {
                UEBuildPlatform.bAllowAutoSDKSwitching = false;
            }

            // Setup environment
            Log.TraceInformation("Setting up command environment.");
            CommandUtils.InitCommandEnvironment();

            // Change CWD to UE4 root.
            Environment.CurrentDirectory = CommandUtils.CmdEnv.LocalRoot;

            // Fill in the project info
            UnrealBuildTool.UProjectInfo.FillProjectInfo();

            // Clean rules folders up
            ProjectUtils.CleanupFolders();

            // Compile scripts.
            Log.TraceInformation("Compiling scripts.");
            ScriptCompiler Compiler = new ScriptCompiler();

            Compiler.FindAndCompileAllScripts(AdditionalScriptsFolders: AdditionalScriptsFolders);

            if (GlobalCommandLine.CompileOnly)
            {
                Log.TraceInformation("Compilation successful, exiting (CompileOnly)");
                return;
            }

            if (GlobalCommandLine.List)
            {
                ListAvailableCommands(Compiler.Commands);
                return;
            }

            if (GlobalCommandLine.Help)
            {
                DisplayHelp(CommandsToExecute, Compiler.Commands);
                return;
            }

            // Enable or disable P4 support
            CommandUtils.InitP4Support(CommandsToExecute, Compiler.Commands);
            if (CommandUtils.P4Enabled)
            {
                Log.TraceInformation("Setting up Perforce environment.");
                CommandUtils.InitP4Environment();
                CommandUtils.InitDefaultP4Connection();
            }

            // Find and execute commands.
            Execute(CommandsToExecute, Compiler.Commands);

            return;
        }
예제 #7
0
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="Arguments">Command line</param>
        public static ExitCode Process(string[] Arguments, StartupTraceListener StartupListener)
        {
            // Initial check for local or build machine runs BEFORE we parse the command line (We need this value set
            // in case something throws the exception while parsing the command line)
            IsBuildMachine = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("uebp_LOCAL_ROOT")) || Arguments.Any(x => x.Equals("-BuildMachine", StringComparison.InvariantCultureIgnoreCase));

            // Scan the command line for commands to execute.
            var    CommandsToExecute = new List <CommandInfo>();
            string OutScriptsForProjectFileName;
            var    AdditionalScriptsFolders = new List <string>();

            ParseCommandLine(Arguments, CommandsToExecute, out OutScriptsForProjectFileName, AdditionalScriptsFolders);

            // Get the path to the telemetry file, if present
            string TelemetryFile = CommandUtils.ParseParamValue(Arguments, "-Telemetry");

            Log.TraceVerbose("IsBuildMachine={0}", IsBuildMachine);
            Environment.SetEnvironmentVariable("IsBuildMachine", IsBuildMachine ? "1" : "0");

            // should we kill processes on exit
            ShouldKillProcesses = !GlobalCommandLine.NoKill;
            Log.TraceVerbose("ShouldKillProcesses={0}", ShouldKillProcesses);

            if (CommandsToExecute.Count == 0 && GlobalCommandLine.Help)
            {
                DisplayHelp();
                return(ExitCode.Success);
            }

            // Disable AutoSDKs if specified on the command line
            if (GlobalCommandLine.NoAutoSDK)
            {
                PlatformExports.PreventAutoSDKSwitching();
            }

            // Setup environment
            Log.TraceLog("Setting up command environment.");
            CommandUtils.InitCommandEnvironment();

            // Create the log file, and flush the startup listener to it
            TraceListener LogTraceListener = LogUtils.AddLogFileListener(CommandUtils.CmdEnv.LogFolder, CommandUtils.CmdEnv.FinalLogFolder);

            StartupListener.CopyTo(LogTraceListener);
            Trace.Listeners.Remove(StartupListener);

            // Initialize UBT
            if (!UnrealBuildTool.PlatformExports.Initialize())
            {
                Log.TraceInformation("Failed to initialize UBT");
                return(ExitCode.Error_Unknown);
            }

            // Clean rules folders up
            ProjectUtils.CleanupFolders();

            // Compile scripts.
            Compiler = new ScriptCompiler();
            using (TelemetryStopwatch ScriptCompileStopwatch = new TelemetryStopwatch("ScriptCompile"))
            {
                Compiler.FindAndCompileAllScripts(OutScriptsForProjectFileName, AdditionalScriptsFolders);
            }

            if (GlobalCommandLine.CompileOnly)
            {
                Log.TraceInformation("Compilation successful, exiting (CompileOnly)");
                return(ExitCode.Success);
            }

            if (GlobalCommandLine.List)
            {
                ListAvailableCommands(Compiler.Commands);
                return(ExitCode.Success);
            }

            if (GlobalCommandLine.Help)
            {
                DisplayHelp(CommandsToExecute, Compiler.Commands);
                return(ExitCode.Success);
            }

            // Enable or disable P4 support
            CommandUtils.InitP4Support(CommandsToExecute, Compiler.Commands);
            if (CommandUtils.P4Enabled)
            {
                Log.TraceLog("Setting up Perforce environment.");
                CommandUtils.InitP4Environment();
                CommandUtils.InitDefaultP4Connection();
            }

            // Find and execute commands.
            ExitCode Result = Execute(CommandsToExecute, Compiler.Commands);

            if (TelemetryFile != null)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(TelemetryFile));
                CommandUtils.Telemetry.Write(TelemetryFile);
            }
            return(Result);
        }
예제 #8
0
        public override ExitCode Execute()
        {
            string[] Arguments = this.Params;

            ProjectName    = ParseParamValue("project", ProjectName);
            Targets        = ParseParamValue("target", Targets);
            Platforms      = ParseParamValue("platform", Platforms);
            Configurations = ParseParamValue("configuration", Configurations);
            Clean          = ParseParam("clean") || Clean;

            if (string.IsNullOrEmpty(Targets))
            {
                throw new AutomationException("No target specified with -target. Use -help to see all options");
            }

            bool NoTools = ParseParam("notools");

            IEnumerable <string> TargetList = Targets.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
            IEnumerable <UnrealTargetConfiguration> ConfigurationList = null;
            IEnumerable <UnrealTargetPlatform>      PlatformList      = null;

            try
            {
                ConfigurationList = Configurations.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries)
                                    .Select(C => (UnrealTargetConfiguration)Enum.Parse(typeof(UnrealTargetConfiguration), C, true)).ToArray();
            }
            catch (Exception Ex)
            {
                LogError("Failed to parse configuration string. {0}", Ex.Message);
                return(ExitCode.Error_Arguments);
            }

            try
            {
                PlatformList = Platforms.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries)
                               .Select(C =>
                {
                    UnrealTargetPlatform Platform;
                    if (!UnrealTargetPlatform.TryParse(C, out Platform))
                    {
                        throw new AutomationException("No such platform {0}", C);
                    }
                    return(Platform);
                }).ToArray();
            }
            catch (Exception Ex)
            {
                LogError("Failed to parse configuration string. {0}", Ex.Message);
                return(ExitCode.Error_Arguments);
            }

            FileReference ProjectFile = null;

            if (!string.IsNullOrEmpty(ProjectName))
            {
                ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName);

                if (ProjectFile == null)
                {
                    throw new AutomationException("Unable to find uproject file for {0}", ProjectName);
                }

                string SourceDirectoryName = Path.Combine(ProjectFile.Directory.FullName, "Source");

                if (Directory.Exists(SourceDirectoryName))
                {
                    IEnumerable <string> TargetScripts = Directory.EnumerateFiles(SourceDirectoryName, "*.Target.cs");

                    foreach (string TargetName in TargetList)
                    {
                        string TargetScript = TargetScripts.Where(S => S.IndexOf(TargetName, StringComparison.OrdinalIgnoreCase) >= 0).FirstOrDefault();

                        if (TargetScript == null && (
                                TargetName.Equals("Client", StringComparison.OrdinalIgnoreCase) ||
                                TargetName.Equals("Game", StringComparison.OrdinalIgnoreCase)
                                )
                            )
                        {
                            // if there's no ProjectGame.Target.cs or ProjectClient.Target.cs then
                            // fallback to Project.Target.cs
                            TargetScript = TargetScripts.Where(S => S.IndexOf(ProjectName + ".", StringComparison.OrdinalIgnoreCase) >= 0).FirstOrDefault();
                        }

                        if (TargetScript == null)
                        {
                            throw new AutomationException("No Target.cs file for target {0} in project {1}", TargetName, ProjectName);
                        }

                        string FullName = Path.GetFileName(TargetScript);
                        TargetNames[TargetName] = Regex.Replace(FullName, ".Target.cs", "", RegexOptions.IgnoreCase);
                    }
                }
            }
            else
            {
                Log.TraceWarning("No project specified, will build vanilla UE4 binaries");
            }

            // Handle content-only projects or when no project was specified
            if (TargetNames.Keys.Count == 0)
            {
                foreach (string TargetName in TargetList)
                {
                    TargetNames[TargetName] = string.Format("UE4{0}", TargetName);
                }
            }

            UE4Build Build = new UE4Build(this);

            UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();

            string EditorTarget = TargetList.Where(T => T.EndsWith("Editor", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            IEnumerable <string> OtherTargets = TargetList.Where(T => T != EditorTarget);

            UnrealTargetPlatform CurrentPlatform = HostPlatform.Current.HostEditorPlatform;

            if (!NoTools)
            {
                Agenda.AddTarget("UnrealHeaderTool", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile);
            }

            if (string.IsNullOrEmpty(EditorTarget) == false)
            {
                string TargetName = TargetNames[EditorTarget];

                Agenda.AddTarget(TargetName, CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile);

                if (!NoTools)
                {
                    Agenda.AddTarget("UnrealPak", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile);
                    Agenda.AddTarget("ShaderCompileWorker", CurrentPlatform, UnrealTargetConfiguration.Development);
                    Agenda.AddTarget("UnrealLightmass", CurrentPlatform, UnrealTargetConfiguration.Development);
                    Agenda.AddTarget("CrashReportClient", CurrentPlatform, UnrealTargetConfiguration.Shipping);
                    Agenda.AddTarget("CrashReportClientEditor", CurrentPlatform, UnrealTargetConfiguration.Shipping);
                }
            }

            foreach (string Target in OtherTargets)
            {
                string TargetName = TargetNames[Target];

                bool IsServer = Target.EndsWith("Server", StringComparison.OrdinalIgnoreCase);

                IEnumerable <UnrealTargetPlatform> PlatformsToBuild = IsServer ? new UnrealTargetPlatform[] { CurrentPlatform } : PlatformList;

                foreach (UnrealTargetPlatform Platform in PlatformsToBuild)
                {
                    foreach (UnrealTargetConfiguration Config in ConfigurationList)
                    {
                        Agenda.AddTarget(TargetName, Platform, Config);
                    }
                }
            }

            // Set clean and log
            foreach (var Target in Agenda.Targets)
            {
                if (Clean)
                {
                    Target.Clean = Clean;
                }

                Log.TraceInformation("Will {0}build {1}", Clean ? "clean and " : "", Target);
            }

            Build.Build(Agenda, InUpdateVersionFiles: false);

            return(ExitCode.Success);
        }
예제 #9
0
        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="Arguments">Command line</param>
        public static ExitCode Process(string[] Arguments)
        {
            // Initial check for local or build machine runs BEFORE we parse the command line (We need this value set
            // in case something throws the exception while parsing the command line)
            IsBuildMachine = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("uebp_LOCAL_ROOT"));

            // Scan the command line for commands to execute.
            var    CommandsToExecute = new List <CommandInfo>();
            string OutScriptsForProjectFileName;
            var    AdditionalScriptsFolders = new List <string>();

            ParseCommandLine(Arguments, CommandsToExecute, out OutScriptsForProjectFileName, AdditionalScriptsFolders);

            // Get the path to the telemetry file, if present
            string TelemetryFile = CommandUtils.ParseParamValue(Arguments, "-Telemetry");

            // Check for build machine override (force local)
            IsBuildMachine = GlobalCommandLine.ForceLocal ? false : IsBuildMachine;
            Log.TraceVerbose("IsBuildMachine={0}", IsBuildMachine);
            Environment.SetEnvironmentVariable("IsBuildMachine", IsBuildMachine ? "1" : "0");

            // should we kill processes on exit
            ShouldKillProcesses = !GlobalCommandLine.NoKill;
            Log.TraceVerbose("ShouldKillProcesses={0}", ShouldKillProcesses);

            if (CommandsToExecute.Count == 0 && GlobalCommandLine.Help)
            {
                DisplayHelp();
                return(ExitCode.Success);
            }

            // Disable AutoSDKs if specified on the command line
            if (GlobalCommandLine.NoAutoSDK)
            {
                UEBuildPlatformSDK.bAllowAutoSDKSwitching = false;
            }

            // Setup environment
            Log.TraceInformation("Setting up command environment.");
            CommandUtils.InitCommandEnvironment();

            // Change CWD to UE4 root.
            Environment.CurrentDirectory = CommandUtils.CmdEnv.LocalRoot;

            // Fill in the project info
            UnrealBuildTool.UProjectInfo.FillProjectInfo();

            // Clean rules folders up
            ProjectUtils.CleanupFolders();

            // Compile scripts.
            ScriptCompiler Compiler = new ScriptCompiler();

            using (TelemetryStopwatch ScriptCompileStopwatch = new TelemetryStopwatch("ScriptCompile"))
            {
                Compiler.FindAndCompileAllScripts(OutScriptsForProjectFileName, AdditionalScriptsFolders);
            }

            if (GlobalCommandLine.CompileOnly)
            {
                Log.TraceInformation("Compilation successful, exiting (CompileOnly)");
                return(ExitCode.Success);
            }

            if (GlobalCommandLine.List)
            {
                ListAvailableCommands(Compiler.Commands);
                return(ExitCode.Success);
            }

            if (GlobalCommandLine.Help)
            {
                DisplayHelp(CommandsToExecute, Compiler.Commands);
                return(ExitCode.Success);
            }

            // Enable or disable P4 support
            CommandUtils.InitP4Support(CommandsToExecute, Compiler.Commands);
            if (CommandUtils.P4Enabled)
            {
                Log.TraceInformation("Setting up Perforce environment.");
                CommandUtils.InitP4Environment();
                CommandUtils.InitDefaultP4Connection();
            }

            // Find and execute commands.
            ExitCode Result = Execute(CommandsToExecute, Compiler.Commands);

            if (TelemetryFile != null)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(TelemetryFile));
                CommandUtils.Telemetry.Write(TelemetryFile);
            }
            return(Result);
        }
예제 #10
0
        public override ExitCode Execute()
        {
            string[] Arguments = this.Params;

            ProjectName    = ParseParamValue("project", ProjectName);
            Targets        = ParseParamValue("target", Targets);
            Platforms      = ParseParamValue("platform", Platforms);
            Configurations = ParseParamValue("configuration", Configurations);
            Clean          = ParseParam("clean") || Clean;
            NoTools        = ParseParam("NoTools") || NoTools;
            UBTArgs        = ParseParamValue("ubtargs", UBTArgs);
            Preview        = ParseParam("preview") || Preview;

            if (string.IsNullOrEmpty(Targets))
            {
                throw new AutomationException("No target specified with -target. Use -help to see all options");
            }

            IEnumerable <string> TargetList = Targets.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
            IEnumerable <UnrealTargetConfiguration> ConfigurationList = null;
            IEnumerable <UnrealTargetPlatform>      PlatformList      = null;

            try
            {
                ConfigurationList = Configurations.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries)
                                    .Select(C => (UnrealTargetConfiguration)Enum.Parse(typeof(UnrealTargetConfiguration), C, true)).ToArray();
            }
            catch (Exception Ex)
            {
                LogError("Failed to parse configuration string. {0}", Ex.Message);
                return(ExitCode.Error_Arguments);
            }

            try
            {
                PlatformList = Platforms.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries)
                               .Select(C =>
                {
                    UnrealTargetPlatform Platform;
                    if (!UnrealTargetPlatform.TryParse(C, out Platform))
                    {
                        throw new AutomationException("No such platform {0}", C);
                    }
                    return(Platform);
                }).ToArray();
            }
            catch (Exception Ex)
            {
                LogError("Failed to parse configuration string. {0}", Ex.Message);
                return(ExitCode.Error_Arguments);
            }

            FileReference ProjectFile = null;

            if (!string.IsNullOrEmpty(ProjectName))
            {
                // find the project
                ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName);

                if (ProjectFile == null)
                {
                    throw new AutomationException("Unable to find uproject file for {0}", ProjectName);
                }
            }

            IEnumerable <string> BuildTargets = TargetList.Select(T => ProjectTargetFromTarget(T, ProjectFile)).ToArray();

            bool ContainsEditor = BuildTargets.Where(T => T.EndsWith("Editor", StringComparison.OrdinalIgnoreCase)).Any();
            bool SingleBuild    = BuildTargets.Count() == 1 && PlatformList.Count() == 1 && ConfigurationList.Count() == 1;

            if (!SingleBuild || (ContainsEditor && !NoTools))
            {
                UE4Build Build = new UE4Build(this);
                Build.AlwaysBuildUHT = true;

                UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda();

                string EditorTarget = BuildTargets.Where(T => T.EndsWith("Editor", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                IEnumerable <string> OtherTargets = BuildTargets.Where(T => T != EditorTarget);

                UnrealTargetPlatform CurrentPlatform = HostPlatform.Current.HostEditorPlatform;

                if (string.IsNullOrEmpty(EditorTarget) == false)
                {
                    Agenda.AddTarget(EditorTarget, CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs);

                    if (!NoTools)
                    {
                        Agenda.AddTarget("UnrealPak", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs);
                        Agenda.AddTarget("ShaderCompileWorker", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs);
                        Agenda.AddTarget("UnrealLightmass", CurrentPlatform, UnrealTargetConfiguration.Development, ProjectFile, UBTArgs);
                        Agenda.AddTarget("CrashReportClient", CurrentPlatform, UnrealTargetConfiguration.Shipping, ProjectFile, UBTArgs);
                        Agenda.AddTarget("CrashReportClientEditor", CurrentPlatform, UnrealTargetConfiguration.Shipping, ProjectFile, UBTArgs);
                    }
                }

                foreach (string Target in OtherTargets)
                {
                    bool IsServer = Target.EndsWith("Server", StringComparison.OrdinalIgnoreCase);

                    IEnumerable <UnrealTargetPlatform> PlatformsToBuild = IsServer ? new UnrealTargetPlatform[] { CurrentPlatform } : PlatformList;

                    foreach (UnrealTargetPlatform Platform in PlatformsToBuild)
                    {
                        foreach (UnrealTargetConfiguration Config in ConfigurationList)
                        {
                            Agenda.AddTarget(Target, Platform, Config, ProjectFile, UBTArgs);
                        }
                    }
                }

                foreach (var Target in Agenda.Targets)
                {
                    Log.TraceInformation("Will {0}build {1}", Clean ? "clean and " : "", Target);
                    if (Clean)
                    {
                        Target.Clean = Clean;
                    }
                }

                if (!Preview)
                {
                    Build.Build(Agenda, InUpdateVersionFiles: false);
                }
            }
            else
            {
                // Get the path to UBT
                FileReference InstalledUBT = FileReference.Combine(CommandUtils.EngineDirectory, "Binaries", "DotNET", "UnrealBuildTool.exe");

                UnrealTargetPlatform      PlatformToBuild = PlatformList.First();
                UnrealTargetConfiguration ConfigToBuild   = ConfigurationList.First();
                string TargetToBuild = BuildTargets.First();

                if (!Preview)
                {
                    // Compile the editor
                    string CommandLine = CommandUtils.UBTCommandline(ProjectFile, TargetToBuild, PlatformToBuild, ConfigToBuild, UBTArgs);

                    if (Clean)
                    {
                        CommandUtils.RunUBT(CommandUtils.CmdEnv, InstalledUBT.FullName, CommandLine + " -clean");
                    }
                    CommandUtils.RunUBT(CommandUtils.CmdEnv, InstalledUBT.FullName, CommandLine);
                }
                else
                {
                    Log.TraceInformation("Will {0}build {1} {2} {3}", Clean ? "clean and " : "", TargetToBuild, PlatformToBuild, ConfigToBuild);
                }
            }

            return(ExitCode.Success);
        }
예제 #11
0
        public string ProjectTargetFromTarget(string InTargetName, FileReference InProjectFile)
        {
            ProjectProperties Properties = InProjectFile != null?ProjectUtils.GetProjectProperties(InProjectFile) : null;

            string ProjectTarget = null;

            if (Properties != null && Properties.bIsCodeBasedProject)
            {
                var AvailableTargets = Properties.Targets.Select(T => T.Rules.Type.ToString());

                // go through the list of targets such as Editor, Client, Server etc and replace them with their real target names
                List <string> ActualTargets = new List <string>();

                // If they asked for ShooterClient etc and that's there, just return that.
                if (Properties.Targets.Any(T => T.TargetName.Equals(InTargetName, StringComparison.OrdinalIgnoreCase)))
                {
                    ProjectTarget = InTargetName;
                }
                else
                {
                    // find targets that match (and there may be multiple...)
                    IEnumerable <string> MatchingTargetTypes = Properties.Targets.Where(T => T.Rules.Type.ToString().Equals(InTargetName, StringComparison.OrdinalIgnoreCase)).Select(T => T.TargetName);

                    if (MatchingTargetTypes.Any())
                    {
                        if (MatchingTargetTypes.Count() == 1)
                        {
                            ProjectTarget = MatchingTargetTypes.First();
                        }
                        else
                        {
                            // if multiple targets, pick the one with our name (FN specific!)
                            ProjectTarget = MatchingTargetTypes.Where(T => string.CompareOrdinal(T, 0, ProjectName, 0, 1) == 0).FirstOrDefault();
                        }
                    }
                }
            }
            else
            {
                // default UE4 targets
                IEnumerable <string> UE4Targets = new[] { "Editor", "Game", "Client", "Server" };

                string ShortTargetName = InTargetName;
                if (ShortTargetName.StartsWith("UE4", StringComparison.OrdinalIgnoreCase))
                {
                    ShortTargetName = ShortTargetName.Substring(3);
                }

                string UE4Target = UE4Targets.Where(S => S.Equals(ShortTargetName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                // If they asked for editor, client etc then give them the UE version
                if (!string.IsNullOrEmpty(UE4Target))
                {
                    ProjectTarget = "UE4" + UE4Target;
                }
                else
                {
                    // or just build what they want and let later code figure out if that's valid. E.g. "UnrealPak"
                    ProjectTarget = InTargetName;
                }
            }

            if (string.IsNullOrEmpty(ProjectTarget))
            {
                throw new AutomationException("{0} is not a valid target in {1}", InTargetName, InProjectFile);
            }

            return(ProjectTarget);
        }