Esempio 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));
        }
Esempio n. 2
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));
        }
Esempio n. 3
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());
        }
Esempio n. 4
0
        protected internal string GenerateCommandLine(CommandLineFormat format = 0)
        {
            string cmdLineCommands = GenerateCommandLineCommands(format);
            string rspFileCommands = GenerateResponseFileCommands(format);

            if (!string.IsNullOrEmpty(cmdLineCommands))
            {
                return(cmdLineCommands + " " + rspFileCommands);
            }
            return(rspFileCommands);
        }
        protected string GenerateCommandLineExcept(
            OptSpecifier[] excludeOpts, CommandLineFormat format = 0)
        {
            string cmdLineCommands = GenerateCommandLineCommands(format);
            string rspFileCommands = GenerateResponseFileCommandsExceptSwitches(excludeOpts, format);

            if (!string.IsNullOrEmpty(cmdLineCommands))
            {
                return(cmdLineCommands + " " + rspFileCommands);
            }
            return(rspFileCommands);
        }
        protected override string GenerateCommandLineExceptSources(CommandLineFormat format)
        {
            OptSpecifier[] excludeOpts;
            if (SourcesOption != null)
            {
                excludeOpts = new[] { SourcesOption.Value }
            }
            ;
            else
            {
                excludeOpts = new OptSpecifier[0];
            }

            return(GenerateCommandLineExcept(excludeOpts, format));
        }
        protected virtual string GenerateResponseFileCommandsExceptSwitches(
            OptSpecifier[] switchesToRemove, CommandLineFormat format = 0)
        {
            PostProcessOptions();

            var builder = new CommandLineBuilder(true);

            foreach (OptSpecifier opt in OptionOrder)
            {
                if (!IsOptionSet(opt))
                {
                    continue;
                }

                if (switchesToRemove == null || !switchesToRemove.Any(o => opt.Id == o.Id))
                {
                    GenerateCommandsAccordingToType(builder, activeArgs[opt.Id]);
                }
            }

            BuildAdditionalArgs(builder);
            return(builder.ToString());
        }
Esempio n. 8
0
 protected virtual string GenerateCommandLineCommandsExceptSwitches(string[] switchesToRemove, CommandLineFormat format = 0, EscapeFormat escapeFormat = 0) =>
 string.Empty;
Esempio n. 9
0
 protected virtual string GenerateCommandLineCommands(CommandLineFormat format, EscapeFormat escapeFormat) =>
 this.GenerateCommandLineCommandsExceptSwitches(new string[0], format, escapeFormat);
Esempio n. 10
0
 private static void EmitTaskItemArraySwitch(CommandLineBuilder builder, ToolSwitch toolSwitch, CommandLineFormat format = 0)
 {
     if (string.IsNullOrEmpty(toolSwitch.Separator))
     {
         foreach (ITaskItem item in toolSwitch.TaskItemArray)
         {
             builder.AppendSwitchIfNotNull(toolSwitch.SwitchValue, Environment.ExpandEnvironmentVariables(item.ItemSpec));
         }
     }
     else
     {
         ITaskItem[] parameters = new ITaskItem[toolSwitch.TaskItemArray.Length];
         for (int i = 0; i < toolSwitch.TaskItemArray.Length; i++)
         {
             parameters[i] = new TaskItem(Environment.ExpandEnvironmentVariables(toolSwitch.TaskItemArray[i].ItemSpec));
             if (format == CommandLineFormat.ForTracking)
             {
                 parameters[i].ItemSpec = parameters[i].ItemSpec.ToUpperInvariant();
             }
         }
         builder.AppendSwitchIfNotNull(toolSwitch.SwitchValue, parameters, toolSwitch.Separator);
     }
 }
Esempio n. 11
0
 /// <inheritdoc/>
 protected override string GenerateResponseFileCommands(CommandLineFormat format, EscapeFormat escapeFormat)
 {
     // DO NOT USE RESPONSE FILE GENERATION.
     // return base.GenerateResponseFileCommands(format, escapeFormat);
     return(string.Empty);
 }
Esempio n. 12
0
 protected virtual string GenerateResponseFileCommands(CommandLineFormat format, EscapeFormat escapeFormat) => this.GenerateResponseFileCommandsExceptSwitches(null, format, escapeFormat);
 protected override string GenerateResponseFileCommands(CommandLineFormat format, EscapeFormat escapeFormat)
 {
     return(GenerateResponseFileCommands());
 }
Esempio n. 14
0
 protected abstract string GenerateCommandLineExceptSources(CommandLineFormat format);
Esempio n. 15
0
 protected abstract string GenerateResponseFileCommands(CommandLineFormat format);
Esempio n. 16
0
 protected virtual string GenerateCommandLineCommands(CommandLineFormat format)
 {
     return(string.Empty);
 }
Esempio n. 17
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");
            }
        }
Esempio n. 18
0
 private static void EmitDirectorySwitch(CommandLineBuilder builder, ToolSwitch toolSwitch, CommandLineFormat format = 0)
 {
     if (!string.IsNullOrEmpty(toolSwitch.SwitchValue))
     {
         if (format == CommandLineFormat.ForBuildLog)
         {
             builder.AppendSwitch(toolSwitch.SwitchValue + toolSwitch.Separator);
         }
         else
         {
             builder.AppendSwitch(toolSwitch.SwitchValue.ToUpperInvariant() + toolSwitch.Separator);
         }
     }
 }
Esempio n. 19
0
 private static void EmitFileSwitch(CommandLineBuilder builder, ToolSwitch toolSwitch, CommandLineFormat format = 0)
 {
     if (!string.IsNullOrEmpty(toolSwitch.Value))
     {
         string parameter = Environment.ExpandEnvironmentVariables(toolSwitch.Value).Trim();
         if (format == CommandLineFormat.ForTracking)
         {
             parameter = parameter.ToUpperInvariant();
         }
         if (!parameter.StartsWith("\"", StringComparison.Ordinal))
         {
             parameter = "\"" + parameter;
             parameter = (!parameter.EndsWith(@"\", StringComparison.Ordinal) || parameter.EndsWith(@"\\", StringComparison.Ordinal)) ? (parameter + "\"") : (parameter + "\\\"");
         }
         builder.AppendSwitchUnquotedIfNotNull(toolSwitch.SwitchValue + toolSwitch.Separator, parameter);
     }
 }
Esempio n. 20
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);
         }
     }
 }
Esempio n. 21
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));
 }
 protected override string GenerateResponseFileCommands(CommandLineFormat format)
 {
     return(GenerateResponseFileCommandsExceptSwitches(new OptSpecifier[0], format));
 }