Exemplo n.º 1
0
        public string GenerateCommandLine(CommandLineFormat format = 0, EscapeFormat escapeFormat = 0)
        {
            string str  = this.GenerateCommandLineCommands(format, escapeFormat);
            string str2 = this.GenerateResponseFileCommands(format, escapeFormat);

            return(string.IsNullOrEmpty(str) ? str2 : (str + " " + str2));
        }
Exemplo n.º 2
0
        protected virtual string GenerateResponseFileCommandsExceptSwitches(
            string[] switchesToRemove,
            CommandLineFormat format  = CommandLineFormat.ForBuildLog,
            EscapeFormat escapeFormat = EscapeFormat.Default)
        {
            this.AddDefaultsToActiveSwitchList();
            this.AddFallbacksToActiveSwitchList();
            this.PostProcessSwitchList();

            CommandLineBuilder commandLineBuilder = new CommandLineBuilder(true);

            bool hasBuiltAdditionalArgs = false;

            foreach (string switchOrder in this.SwitchOrderList)
            {
                if (this.IsPropertySet(switchOrder))
                {
                    ToolSwitch activeToolSwitch = this.activeToolSwitches[switchOrder];
                    if (this.VerifyDependenciesArePresent(activeToolSwitch) && this.VerifyRequiredArgumentsArePresent(activeToolSwitch, false))
                    {
                        bool notRemove = true;

                        if (switchesToRemove != null)
                        {
                            foreach (string strRemove in switchesToRemove)
                            {
                                if (switchOrder.Equals(strRemove, StringComparison.OrdinalIgnoreCase))
                                {
                                    notRemove = false;
                                    break;
                                }
                            }
                        }

                        if (notRemove)
                        {
                            this.GenerateCommandsAccordingToType(commandLineBuilder, activeToolSwitch, false, format, escapeFormat);
                        }
                    }
                }
                else if (string.Equals(switchOrder, "additionaloptions", StringComparison.OrdinalIgnoreCase))
                {
                    this.BuildAdditionalArgs(commandLineBuilder);
                    hasBuiltAdditionalArgs = true;
                }
                else if (string.Equals(switchOrder, "AlwaysAppend", StringComparison.OrdinalIgnoreCase))
                {
                    commandLineBuilder.AppendSwitch(this.AlwaysAppend);
                }
            }

            if (!hasBuiltAdditionalArgs)
            {
                this.BuildAdditionalArgs(commandLineBuilder);
            }

            return(commandLineBuilder.ToString());
        }
Exemplo n.º 3
0
 /// <inheritdoc/>
 protected override string GenerateCommandLineCommands(CommandLineFormat format, EscapeFormat escapeFormat)
 {
     // Use the response file command line generation for the normal command line.
     return(base.GenerateResponseFileCommands(format, escapeFormat));
 }
Exemplo n.º 4
0
 /// <inheritdoc/>
 protected override string GenerateResponseFileCommands(CommandLineFormat format, EscapeFormat escapeFormat)
 {
     // DO NOT USE RESPONSE FILE GENERATION.
     // return base.GenerateResponseFileCommands(format, escapeFormat);
     return(string.Empty);
 }
Exemplo n.º 5
0
 protected virtual string GenerateResponseFileCommands(CommandLineFormat format, EscapeFormat escapeFormat) => this.GenerateResponseFileCommandsExceptSwitches(null, format, escapeFormat);
Exemplo n.º 6
0
        protected virtual void GenerateCommandsAccordingToType(CommandLineBuilder builder, ToolSwitch toolSwitch, bool recursive, CommandLineFormat format = 0, EscapeFormat escapeFormat = 0)
        {
            if ((toolSwitch.Parents.Count <= 0) || recursive)
            {
                switch (toolSwitch.Type)
                {
                case ToolSwitchType.Boolean:
                    this.EmitBooleanSwitch(builder, toolSwitch);
                    return;

                case ToolSwitchType.Integer:
                    this.EmitIntegerSwitch(builder, toolSwitch);
                    return;

                case ToolSwitchType.String:
                    this.EmitStringSwitch(builder, toolSwitch);
                    return;

                case ToolSwitchType.StringArray:
                    EmitStringArraySwitch(builder, toolSwitch, CommandLineFormat.ForBuildLog, EscapeFormat.Default);
                    return;

                case ToolSwitchType.File:
                    EmitFileSwitch(builder, toolSwitch, format);
                    return;

                case ToolSwitchType.Directory:
                    EmitDirectorySwitch(builder, toolSwitch, format);
                    return;

                case ToolSwitchType.ITaskItem:
                    EmitTaskItemSwitch(builder, toolSwitch);
                    return;

                case ToolSwitchType.ITaskItemArray:
                    EmitTaskItemArraySwitch(builder, toolSwitch, format);
                    return;

                case ToolSwitchType.AlwaysAppend:
                    EmitAlwaysAppendSwitch(builder, toolSwitch);
                    return;

                case ToolSwitchType.StringPathArray:
                    EmitStringArraySwitch(builder, toolSwitch, format, escapeFormat);
                    return;
                }
                ErrorUtilities.VerifyThrow(false, "InternalError");
            }
        }
Exemplo n.º 7
0
        public string GenerateCommandLineExceptSwitches(string[] switchesToRemove, CommandLineFormat format = 0, EscapeFormat escapeFormat = 0)
        {
            string str  = this.GenerateCommandLineCommandsExceptSwitches(switchesToRemove, format, escapeFormat);
            string str2 = this.GenerateResponseFileCommandsExceptSwitches(switchesToRemove, format, escapeFormat);

            return(string.IsNullOrEmpty(str) ? str2 : (str + " " + str2));
        }
Exemplo n.º 8
0
 protected virtual string GenerateCommandLineCommandsExceptSwitches(string[] switchesToRemove, CommandLineFormat format = 0, EscapeFormat escapeFormat = 0) =>
 string.Empty;
Exemplo n.º 9
0
 protected virtual string GenerateCommandLineCommands(CommandLineFormat format, EscapeFormat escapeFormat) =>
 this.GenerateCommandLineCommandsExceptSwitches(new string[0], format, escapeFormat);
Exemplo n.º 10
0
 private static void EmitStringArraySwitch(CommandLineBuilder builder, ToolSwitch toolSwitch, CommandLineFormat format = 0, EscapeFormat escapeFormat = 0)
 {
     string[] parameters = new string[toolSwitch.StringList.Length];
     char[]   anyOf      = new char[] { ' ', '|', '<', '>', ',', ';', '-', '\r', '\n', '\t', '\f' };
     for (int i = 0; i < toolSwitch.StringList.Length; i++)
     {
         string str = (!toolSwitch.StringList[i].StartsWith("\"", StringComparison.Ordinal) || !toolSwitch.StringList[i].EndsWith("\"", StringComparison.Ordinal)) ? Environment.ExpandEnvironmentVariables(toolSwitch.StringList[i]) : Environment.ExpandEnvironmentVariables(toolSwitch.StringList[i].Substring(1, toolSwitch.StringList[i].Length - 2));
         if (!string.IsNullOrEmpty(str))
         {
             if (format == CommandLineFormat.ForTracking)
             {
                 str = str.ToUpperInvariant();
             }
             if (escapeFormat.HasFlag(EscapeFormat.EscapeTrailingSlash) && ((str.IndexOfAny(anyOf) == -1) && (str.EndsWith(@"\", StringComparison.Ordinal) && !str.EndsWith(@"\\", StringComparison.Ordinal))))
             {
                 str = str + @"\";
             }
             parameters[i] = str;
         }
     }
     if (!string.IsNullOrEmpty(toolSwitch.Separator))
     {
         builder.AppendSwitchIfNotNull(toolSwitch.SwitchValue, parameters, toolSwitch.Separator);
     }
     else
     {
         foreach (string str2 in parameters)
         {
             builder.AppendSwitchIfNotNull(toolSwitch.SwitchValue, str2);
         }
     }
 }
Exemplo n.º 11
0
 protected override string GenerateResponseFileCommands(CommandLineFormat format, EscapeFormat escapeFormat)
 {
     return(GenerateResponseFileCommands());
 }