Ejemplo n.º 1
0
        /// <summary>
        /// Parse the command line and create a list of commands to execute.
        /// </summary>
        /// <param name="Arguments">Command line</param>
        /// <param name="OutCommandsToExecute">List containing the names of commands to execute</param>
        /// <param name="OutAdditionalScriptsFolders">Optional list of additional paths to look for scripts in</param>
        private static void ParseCommandLine(string[] Arguments, List <CommandInfo> OutCommandsToExecute, out string OutScriptsForProjectFileName, List <string> OutAdditionalScriptsFolders)
        {
            // Initialize global command line parameters
            GlobalCommandLine.Init();

            ParseProfile(ref Arguments);

            Log.TraceInformation("Parsing command line: {0}", CommandUtils.FormatCommandLine(Arguments));

            OutScriptsForProjectFileName = null;

            CommandInfo CurrentCommand = null;

            for (int Index = 0; Index < Arguments.Length; ++Index)
            {
                // Guard against empty arguments passed as "" on the command line
                string Param = Arguments[Index];
                if (Param.Length > 0)
                {
                    if (Param.StartsWith("-") || Param.Contains("="))
                    {
                        ParseParam(Arguments[Index], CurrentCommand, ref OutScriptsForProjectFileName, OutAdditionalScriptsFolders);
                    }
                    else
                    {
                        CurrentCommand             = new CommandInfo();
                        CurrentCommand.CommandName = Arguments[Index];
                        OutCommandsToExecute.Add(CurrentCommand);
                    }
                }
            }

            // Validate
            var Result = OutCommandsToExecute.Count > 0 || GlobalCommandLine.Help || GlobalCommandLine.CompileOnly || GlobalCommandLine.List;

            if (OutCommandsToExecute.Count > 0)
            {
                Log.TraceVerbose("Found {0} scripts to execute:", OutCommandsToExecute.Count);
                foreach (var Command in OutCommandsToExecute)
                {
                    Log.TraceVerbose("  " + Command.ToString());
                }
            }
            else if (!Result)
            {
                throw new AutomationException("Failed to find scripts to execute in the command line params.");
            }
            if (GlobalCommandLine.NoP4 && GlobalCommandLine.P4)
            {
                throw new AutomationException("{0} and {1} can't be set simultaneously.", GlobalCommandLine.NoP4.Name, GlobalCommandLine.P4.Name);
            }
            if (GlobalCommandLine.NoSubmit && GlobalCommandLine.Submit)
            {
                throw new AutomationException("{0} and {1} can't be set simultaneously.", GlobalCommandLine.NoSubmit.Name, GlobalCommandLine.Submit.Name);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parse the command line and create a list of commands to execute.
        /// </summary>
        /// <param name="CommandLine">Command line</param>
        /// <param name="OutCommandsToExecute">List containing the names of commands to execute</param>
        /// <param name="OutAdditionalScriptsFolders">Optional list of additional paths to look for scripts in</param>
        private static void ParseCommandLine(string[] CommandLine, List <CommandInfo> OutCommandsToExecute, List <string> OutAdditionalScriptsFolders)
        {
            // Initialize global command line parameters
            GlobalCommandLine.Init();

            Log.TraceInformation("Parsing command line: {0}", String.Join(" ", CommandLine));

            CommandInfo CurrentCommand = null;

            for (int Index = 0; Index < CommandLine.Length; ++Index)
            {
                var Param = CommandLine[Index];
                if (Param.StartsWith("-") || Param.Contains("="))
                {
                    ParseParam(CommandLine[Index], CurrentCommand, OutAdditionalScriptsFolders);
                }
                else
                {
                    CurrentCommand             = new CommandInfo();
                    CurrentCommand.CommandName = CommandLine[Index];
                    OutCommandsToExecute.Add(CurrentCommand);
                }
            }

            // Validate
            var Result = OutCommandsToExecute.Count > 0 || GlobalCommandLine.Help || GlobalCommandLine.CompileOnly || GlobalCommandLine.List;

            if (OutCommandsToExecute.Count > 0)
            {
                Log.TraceVerbose("Found {0} scripts to execute:", OutCommandsToExecute.Count);
                foreach (var Command in OutCommandsToExecute)
                {
                    Log.TraceVerbose("  " + Command.ToString());
                }
            }
            else if (!Result)
            {
                throw new AutomationException("Failed to find scripts to execute in the command line params.");
            }
            if (GlobalCommandLine.NoP4 && GlobalCommandLine.P4)
            {
                throw new AutomationException("{0} and {1} can't be set simultaneously.", GlobalCommandLine.NoP4.Name, GlobalCommandLine.P4.Name);
            }
            if (GlobalCommandLine.NoSubmit && GlobalCommandLine.Submit)
            {
                throw new AutomationException("{0} and {1} can't be set simultaneously.", GlobalCommandLine.NoSubmit.Name, GlobalCommandLine.Submit.Name);
            }

            if (GlobalCommandLine.Rocket)
            {
                UnrealBuildTool.UnrealBuildTool.bRunningRocket = true;
            }
        }