Esempio n. 1
0
        public ProcessBuilder WithArguments(PipData arguments)
        {
            Contract.Assert(m_argumentsFactory == null, "Only WithArguments or WithArgumentsFactory method could be called, but not both.");

            m_arguments = arguments;
            return(this);
        }
Esempio n. 2
0
 /// <summary>
 /// Clone and override select properties.
 /// </summary>
 public IpcPip Override(
     IpcClientInfo ipcInfo   = null,
     PipData?messageBody     = null,
     FileArtifact?outputFile = null,
     ReadOnlyArray <PipId>?servicePipDependencies            = null,
     ReadOnlyArray <FileArtifact>?fileDependencies           = null,
     ReadOnlyArray <DirectoryArtifact>?directoryDependencies = null,
     ReadOnlyArray <FileOrDirectoryArtifact>?lazilyMaterializedDependencies = null,
     ReadOnlyArray <StringId>?tags = null,
     bool?isServiceFinalization    = null,
     bool?mustRunOnMaster          = null,
     PipProvenance provenance      = null)
 {
     return(new IpcPip(
                ipcInfo ?? IpcInfo,
                messageBody ?? MessageBody,
                outputFile ?? OutputFile,
                servicePipDependencies ?? ServicePipDependencies,
                fileDependencies ?? FileDependencies,
                directoryDependencies ?? DirectoryDependencies,
                lazilyMaterializedDependencies ?? LazilyMaterializedDependencies,
                tags ?? Tags,
                isServiceFinalization ?? IsServiceFinalization,
                mustRunOnMaster ?? MustRunOnMaster,
                provenance ?? Provenance));
 }
Esempio n. 3
0
 /// <summary>
 /// Clone and override select properties.
 /// </summary>
 public Process Override(
     FileArtifact?executable       = null,
     AbsolutePath?workingDirectory = null,
     PipData?arguments             = null,
     FileArtifact?responseFile     = null,
     PipData?responseFileData      = null,
     ReadOnlyArray <EnvironmentVariable>?environmentVariables = null,
     StandardInput?standardInput    = null,
     FileArtifact?standardOutput    = null,
     FileArtifact?standardError     = null,
     AbsolutePath?standardDirectory = null,
     TimeSpan?warningTimeout        = null,
     TimeSpan?timeout = null,
     ReadOnlyArray <FileArtifact>?dependencies = null,
     ReadOnlyArray <FileArtifactWithAttributes>?fileOutputs  = null,
     ReadOnlyArray <DirectoryArtifact>?directoryDependencies = null,
     ReadOnlyArray <DirectoryArtifact>?directoryOutputs      = null,
     ReadOnlyArray <PipId>?orderDependencies      = null,
     ReadOnlyArray <AbsolutePath>?untrackedPaths  = null,
     ReadOnlyArray <AbsolutePath>?untrackedScopes = null,
     ReadOnlyArray <StringId>?tags                   = null,
     ReadOnlyArray <int>?successExitCodes            = null,
     ReadOnlyArray <ProcessSemaphoreInfo>?semaphores = null,
     PipProvenance provenance = null,
     StringId?toolDescription = null,
     ReadOnlyArray <AbsolutePath>?additionalTempDirectories = null,
     RegexDescriptor?warningRegex         = null,
     RegexDescriptor?errorRegex           = null,
     AbsolutePath?uniqueOutputDirectory   = null,
     AbsolutePath?redirectedDirectoryRoot = null,
     AbsolutePath?tempDirectory           = null,
     Options?options                    = null,
     bool?testRetries                   = null,
     ServiceInfo serviceInfo            = null,
     ReadOnlyArray <int>?retryExitCodes = null,
     ReadOnlyArray <PathAtom>?allowedSurvivingChildProcessNames = null,
     TimeSpan?nestedProcessTerminationTimeout = null,
     AbsentPathProbeInUndeclaredOpaquesMode absentPathProbeMode = AbsentPathProbeInUndeclaredOpaquesMode.Unsafe,
     DoubleWritePolicy doubleWritePolicy             = DoubleWritePolicy.DoubleWritesAreErrors,
     ContainerIsolationLevel containerIsolationLevel = ContainerIsolationLevel.None)
 {
     return(new Process(
                executable ?? Executable,
                workingDirectory ?? WorkingDirectory,
                arguments ?? Arguments,
                responseFile ?? ResponseFile,
                responseFileData ?? ResponseFileData,
                environmentVariables ?? EnvironmentVariables,
                standardInput ?? StandardInput,
                standardOutput ?? StandardOutput,
                standardError ?? StandardError,
                standardDirectory ?? StandardDirectory,
                warningTimeout ?? WarningTimeout,
                timeout ?? Timeout,
                dependencies ?? Dependencies,
                fileOutputs ?? FileOutputs,
                directoryDependencies ?? DirectoryDependencies,
                directoryOutputs ?? DirectoryOutputs,
                orderDependencies ?? OrderDependencies,
                untrackedPaths ?? UntrackedPaths,
                untrackedScopes ?? UntrackedScopes,
                tags ?? Tags,
                successExitCodes ?? SuccessExitCodes,
                semaphores ?? Semaphores,
                provenance ?? Provenance,
                toolDescription ?? ToolDescription,
                additionalTempDirectories ?? AdditionalTempDirectories,
                warningRegex ?? WarningRegex,
                errorRegex ?? ErrorRegex,
                uniqueOutputDirectory ?? UniqueOutputDirectory,
                redirectedDirectoryRoot ?? UniqueRedirectedDirectoryRoot,
                tempDirectory ?? TempDirectory,
                options ?? ProcessOptions,
                testRetries ?? TestRetries,
                serviceInfo ?? ServiceInfo,
                retryExitCodes ?? RetryExitCodes,
                allowedSurvivingChildProcessNames,
                nestedProcessTerminationTimeout,
                absentPathProbeMode,
                doubleWritePolicy,
                containerIsolationLevel));
 }
Esempio n. 4
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);
        }