AppendTextUnquoted() public method

Appends a string. No quotes are added. This method does not append a space to the command line before executing.
In the future, this function may fixup 'textToAppend' to handle literal embedded quotes.
public AppendTextUnquoted ( string textToAppend ) : void
textToAppend string The string to append
return void
Exemplo n.º 1
0
 protected override String GenerateCommandLineCommands()
 {
     CommandLineBuilder builder = new CommandLineBuilder();
     if (Tie)
     {
         builder.AppendSwitch("--tie ");
     }
     builder.AppendTextUnquoted(String.Format(" {0}", base.GenerateCommandLineCommands()));
     return builder.ToString();
 }
Exemplo n.º 2
0
        protected override String GenerateCommandLineCommands()
        {
            UsageError = false;
            CommandLineBuilder builder = new CommandLineBuilder(false);
            if(Depend)
            {
                builder.AppendSwitch("--depend-xml");
                builder.AppendSwitch("--depend-file");
                builder.AppendFileNameIfNotNull(Path.Combine(OutputDir, DependFile));
            }

            if(!String.IsNullOrEmpty(OutputDir))
            {
                builder.AppendSwitch("--output-dir");
                builder.AppendFileNameIfNotNull(OutputDir);
            }

            if(AllowIcePrefix)
            {
                builder.AppendSwitch("--ice");
            }

            if(Underscore)
            {
                builder.AppendSwitch("--underscore");
            }

            if(Stream)
            {
                builder.AppendSwitch("--stream");
            }

            if(Checksum)
            {
                builder.AppendSwitch("--checksum");
            }

            if (IncludeDirectories != null)
            {
                foreach (String path in IncludeDirectories)
                {
                    builder.AppendSwitchIfNotNull("-I", path);
                }
            }

            if(!String.IsNullOrEmpty(AdditionalOptions))
            {
                builder.AppendTextUnquoted(" ");
                builder.AppendTextUnquoted(AdditionalOptions);
            }

            builder.AppendFileNamesIfNotNull(Sources, " ");

            return builder.ToString();
        }
Exemplo n.º 3
0
        protected override String GenerateCommandLineCommands()
        {
            CommandLineBuilder builder = new CommandLineBuilder(false);

            if (!String.IsNullOrEmpty(DLLExport))
            {
                builder.AppendSwitch("--dll-export");
                builder.AppendFileNameIfNotNull(DLLExport);
            }

            if (!HeaderExt.Equals("h"))
            {
                builder.AppendSwitch("--header-ext");
                builder.AppendFileNameIfNotNull(HeaderExt);
            }

            if (!SourceExt.Equals("cpp"))
            {
                builder.AppendSwitch("--source-ext");
                builder.AppendFileNameIfNotNull(SourceExt);
            }

            if (!String.IsNullOrEmpty(BaseDirectoryForGeneratedInclude))
            {
                builder.AppendSwitch("--include-dir");
                builder.AppendFileNameIfNotNull(BaseDirectoryForGeneratedInclude);
            }
            builder.AppendTextUnquoted(" ");
            builder.AppendTextUnquoted(base.GenerateCommandLineCommands());

            return builder.ToString();
        }
Exemplo n.º 4
0
        // helper for string-based properties
        private void AppendStringValue(CommandLineBuilder builder, BaseProperty property, string subtype, string value)
        {
            value = value.Trim();

            // could cache this SubType test off in property wrapper or somewhere if performance were an issue
            string switchName = m_parsedBuildRule.SwitchPrefix + property.Switch;
            switchName += property.Separator;
            if (subtype == "file" || subtype == "folder")
            {
                // for switches that contains files or folders we need quoting
                builder.AppendSwitchIfNotNull(switchName, value);
            }
            else if (!string.IsNullOrEmpty(property.Switch))
            {
                builder.AppendSwitchUnquotedIfNotNull(switchName, value);
            }
            else if (!string.IsNullOrEmpty(value))
            {
                // for non-switches such as AdditionalOptions we just append the value
                builder.AppendTextUnquoted(" " + value);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns a string value containing the command line arguments to pass directly to the executable file.
        /// </summary>
        /// <returns>
        /// A string value containing the command line arguments to pass directly to the executable file.
        /// </returns>
        protected override string GenerateCommandLineCommands()
        {
            var builder = new CommandLineBuilder();

              var c = Environment.OSVersion.Platform == PlatformID.Unix
            ? "-"
            : "--";

              if (EnableShadowCopy) builder.AppendSwitch(c + "shadowcopy");
              if (_testInNewThread.HasValue && !_testInNewThread.Value) builder.AppendSwitch(c + "nothread");
              if (Force32Bit) builder.AppendSwitch(c + "x86");
              if (NoHeader) builder.AppendSwitch(c + "noheader");
              if (NoColor) builder.AppendSwitch(c + "nocolor");
              if (Verbose) builder.AppendSwitch(c + "verbose");
              if (ReportProgressToTeamCity) builder.AppendSwitch(c + "teamcity");
              builder.AppendFileNamesIfNotNull(Assemblies, " ");
              builder.AppendSwitchIfNotNull(c + "config=", ProjectConfiguration);
              builder.AppendSwitchIfNotNull(c + "err=", ErrorOutputFile);
              builder.AppendSwitchIfNotNull(c + "out=", TextOutputFile);
              builder.AppendSwitchIfNotNull(c + "framework=", Framework);
              builder.AppendSwitchIfNotNull(c + "process=", Process);
              builder.AppendSwitchIfNotNull(c + "domain=", Domain);
              builder.AppendSwitchIfNotNull(c + "apartment=", Apartment);
              builder.AppendSwitchIfNotNull(c + "where=", Where);
              builder.AppendSwitchIfNotNull(c + "timeout=", TestTimeout);
              builder.AppendSwitchIfNotNull(c + "workers=", Workers);
              builder.AppendSwitchIfNotNull(c + "result=", OutputXmlFile);
              builder.AppendSwitchIfNotNull(c + "work=", WorkingDirectory);
              builder.AppendSwitchIfNotNull(c + "labels=", ShowLabels);
              builder.AppendSwitchIfNotNull(c + "trace=", InternalTrace);
              if(!string.IsNullOrWhiteSpace(AdditionalArguments)) builder.AppendTextUnquoted(" " + AdditionalArguments);

              return builder.ToString();
        }
Exemplo n.º 6
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    private void AppendStringListValue (CommandLineBuilder builder, BaseProperty property, string subtype, string [] value, string delimiter)
    {
      string switchName = m_parsedBuildRule.SwitchPrefix + property.Switch;

      switchName += property.Separator;

      if (subtype == "file" || subtype == "folder")
      {
        builder.AppendSwitchUnquotedIfNotNull (switchName, value, delimiter);
      }
      else if (!string.IsNullOrEmpty (property.Switch))
      {
        builder.AppendSwitchUnquotedIfNotNull (switchName, value, delimiter);
      }
      else if (value.Length > 0)
      {
        foreach (string entry in value)
        {
          builder.AppendTextUnquoted (entry + delimiter);
        }
      }
    }
Exemplo n.º 7
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    private void AppendStringValue (CommandLineBuilder builder, BaseProperty property, string subtype, string value)
    {
      string switchName = property.SwitchPrefix;

      if (string.IsNullOrEmpty (property.SwitchPrefix))
      {
        switchName = m_parsedBuildRule.SwitchPrefix;
      }

      switchName += property.Switch + property.Separator;

      if (subtype == "file" || subtype == "folder")
      {
        if (!string.IsNullOrWhiteSpace (switchName))
        {
          builder.AppendSwitchIfNotNull (switchName, value);
        }
        else
        {
          builder.AppendTextUnquoted (" " + PathUtils.QuoteIfNeeded (value));
        }
      }
      else if (!string.IsNullOrEmpty (property.Switch))
      {
        builder.AppendSwitchUnquotedIfNotNull (switchName, value);
      }
      else if (!string.IsNullOrEmpty (value))
      {
        builder.AppendTextUnquoted (" " + value);
      }
    }
Exemplo n.º 8
0
        /// <summary>
        /// Generates the command-line using the template specified.
        /// </summary>
        private void GenerateTemplatedCommandLine(CommandLineBuilder builder)
        {
            // Match all instances of [asdf], where "asdf" can be any combination of any 
            // characters *except* a [ or an ]. i.e., if "[ [ sdf ]" is passed, then we will 
            // match "[ sdf ]"
            string matchString = @"\[[^\[\]]+\]";
            Regex regex = new Regex(matchString, RegexOptions.ECMAScript);
            MatchCollection matches = regex.Matches(CommandLineTemplate);

            int indexOfEndOfLastSubstitution = 0;
            foreach (Match match in matches)
            {
                if (match.Length == 0)
                {
                    continue;
                }

                // Because we match non-greedily, in the case where we have input such as "[[[[[foo]", the match will
                // be "[foo]".  However, if there are multiple '[' in a row, we need to do some escaping logic, so we 
                // want to know what the first *consecutive* square bracket was.  
                int indexOfFirstBracketInMatch = match.Index;

                // Indexing using "indexOfFirstBracketInMatch - 1" is safe here because it will always be 
                // greater than indexOfEndOfLastSubstitution, which will always be 0 or greater. 
                while (indexOfFirstBracketInMatch > indexOfEndOfLastSubstitution && CommandLineTemplate[indexOfFirstBracketInMatch - 1].Equals('['))
                {
                    indexOfFirstBracketInMatch--;
                }

                // Append everything we know we want to add -- everything between where the last substitution ended and 
                // this match (including previous '[' that were not initially technically part of the match) begins. 
                if (indexOfFirstBracketInMatch != indexOfEndOfLastSubstitution)
                {
                    builder.AppendTextUnquoted(CommandLineTemplate.Substring(indexOfEndOfLastSubstitution, indexOfFirstBracketInMatch - indexOfEndOfLastSubstitution));
                }

                // Now replace every "[[" with a literal '['.  We can do this by simply counting the number of '[' between 
                // the first one and the start of the match, since by definition everything in between is an '['.  
                // + 1 because match.Index is also a bracket. 
                int openBracketsInARow = match.Index - indexOfFirstBracketInMatch + 1;

                if (openBracketsInARow % 2 == 0)
                {
                    // even number -- they all go away and the rest of the match is appended literally. 
                    for (int i = 0; i < openBracketsInARow / 2; i++)
                    {
                        builder.AppendTextUnquoted("[");
                    }

                    builder.AppendTextUnquoted(match.Value.Substring(1, match.Value.Length - 1));
                }
                else
                {
                    // odd number -- all but one get merged two at a time, and the rest of the match is substituted. 
                    for (int i = 0; i < (openBracketsInARow - 1) / 2; i++)
                    {
                        builder.AppendTextUnquoted("[");
                    }

                    // Determine which property the user has specified in the template.
                    string propertyName = match.Value.Substring(1, match.Value.Length - 2);
                    if (String.Equals(propertyName, "AllOptions", StringComparison.OrdinalIgnoreCase))
                    {
                        // When [AllOptions] is specified, we append all switch-type options.
                        CommandLineBuilder tempBuilder = new CommandLineBuilder(true);
                        GenerateStandardCommandLine(tempBuilder, true);
                        builder.AppendTextUnquoted(tempBuilder.ToString());
                    }
                    else if (String.Equals(propertyName, "AdditionalOptions", StringComparison.OrdinalIgnoreCase))
                    {
                        BuildAdditionalArgs(builder);
                    }
                    else if (IsPropertySet(propertyName))
                    {
                        CommandLineToolSwitch property = _activeCommandLineToolSwitches[propertyName];

                        // verify the dependencies
                        if (VerifyDependenciesArePresent(property) && VerifyRequiredArgumentsArePresent(property, false))
                        {
                            CommandLineBuilder tempBuilder = new CommandLineBuilder(true);
                            GenerateCommandsAccordingToType(tempBuilder, property, false);
                            builder.AppendTextUnquoted(tempBuilder.ToString());
                        }
                    }
                    else if (!PropertyExists(propertyName))
                    {
                        // If the thing enclosed in square brackets is not in fact a property, we 
                        // don't want to replace it. 
                        builder.AppendTextUnquoted('[' + propertyName + ']');
                    }
                }

                indexOfEndOfLastSubstitution = match.Index + match.Length;
            }

            builder.AppendTextUnquoted(CommandLineTemplate.Substring(indexOfEndOfLastSubstitution, CommandLineTemplate.Length - indexOfEndOfLastSubstitution));
        }