Exemplo n.º 1
0
 /// <summary>
 /// Returns <see cref="GetCmdDependencies(PathTable)"/> formatted as a DScript array literal.
 /// </summary>
 public static string GetCmdDependenciesAsArrayLiteral(PathTable pathTable)
 {
     return("[ " + string.Join(", ", CmdHelper
                               .GetCmdDependencies(pathTable)
                               .Select(p => "f`" + p.ToString(pathTable) + "`")) + " ]");
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a process pip.
        /// </summary>
        protected Process CreateCmdProcess(
            IEnumerable <FileArtifact> dependencies,
            IEnumerable <FileArtifact> outputs,
            PipData?arguments         = null,
            IEnumerable <string> tags = null,
            PipProvenance provenance  = null,
            IEnumerable <DirectoryArtifact> directoryDependencies = null,
            IEnumerable <PipId> orderDependencies = null,
            IEnumerable <EnvironmentVariable> environmentVariables = null,
            FileArtifact?stdOut   = null,
            FileArtifact?stdError = null,
            bool withWarning      = false,
            string value          = null,
            IEnumerable <FileArtifact> untrackedFiles        = null,
            IEnumerable <DirectoryArtifact> directoryOutputs = null)
        {
            Contract.Requires(dependencies != null);
            Contract.Requires(outputs != null);

            FileArtifact executable = CmdExecutable;

            IEnumerable <AbsolutePath> untrackedDependencies = CmdHelper.GetCmdDependencies(Context.PathTable);

            if (untrackedFiles != null)
            {
                List <AbsolutePath> files = new List <AbsolutePath>(untrackedDependencies);
                foreach (FileArtifact oneFile in untrackedFiles)
                {
                    files.Add(oneFile.Path);
                }
                untrackedDependencies = files;
            }

            untrackedFiles = untrackedFiles ?? Enumerable.Empty <FileArtifact>();

            var process =
                new Process(
                    executable: executable,
                    workingDirectory: GetWorkingDirectory(),
                    arguments: arguments ?? CreateCmdArguments(Context.StringTable, dependencies.Concat(untrackedFiles), outputs, includeWarning: withWarning),
                    responseFile: FileArtifact.Invalid,
                    responseFileData: PipData.Invalid,
                    environmentVariables: environmentVariables != null
                        ? ReadOnlyArray <EnvironmentVariable> .From(environmentVariables)
                        : ReadOnlyArray <EnvironmentVariable> .Empty,
                    standardInput: FileArtifact.Invalid,
                    standardOutput: stdOut ?? FileArtifact.Invalid,
                    standardError: stdError ?? FileArtifact.Invalid,
                    standardDirectory: GetStandardDirectory(),
                    warningTimeout: null,
                    timeout: null,

                    // TODO:1759: Fix response file handling. Should be able to appear in the dependencies list, but should appear in the graph as a WriteFile pip.
                    dependencies: ReadOnlyArray <FileArtifact> .From((new[] { executable /*, responseFile*/ }).Concat(dependencies ?? CollectionUtilities.EmptyArray <FileArtifact>())),
                    outputs: ReadOnlyArray <FileArtifactWithAttributes> .From(outputs.Select(o => o.WithAttributes()).ToArray()),
                    directoryDependencies: ReadOnlyArray <DirectoryArtifact> .From(directoryDependencies ?? new DirectoryArtifact[0]),
                    directoryOutputs: ReadOnlyArray <DirectoryArtifact> .From(directoryOutputs ?? new DirectoryArtifact[0]),
                    orderDependencies: orderDependencies != null ? ReadOnlyArray <PipId> .From(orderDependencies) : ReadOnlyArray <PipId> .Empty,
                    untrackedPaths: ReadOnlyArray <AbsolutePath> .From(untrackedDependencies),
                    untrackedScopes: ReadOnlyArray <AbsolutePath> .From(CmdHelper.GetCmdDependencyScopes(Context.PathTable)),
                    tags: ConvertToStringIdArray(tags),
                    successExitCodes: ReadOnlyArray <int> .Empty,
                    semaphores: ReadOnlyArray <ProcessSemaphoreInfo> .Empty,
                    provenance: provenance,
                    toolDescription: StringId.Invalid,
                    additionalTempDirectories: ReadOnlyArray <AbsolutePath> .Empty,
                    warningRegex:
                    withWarning
                            ? new RegexDescriptor(StringId.Create(Context.StringTable, WarningRegexDescription), RegexOptions.IgnoreCase)
                            : default(RegexDescriptor));

            return(process);
        }