Exemple #1
0
        /// <nodoc />
        public static DirectoryArtifact GetOpaqueDirectory(this ProcessOutputs processOutputs, AbsolutePath path)
        {
            if (!processOutputs.TryGetOutputDirectory(path, out var result))
            {
                throw new InvalidOperationException();
            }

            return(result.Root);
        }
Exemple #2
0
        /// <nodoc />
        public static FileArtifact GetOutputFile(this ProcessOutputs processOutputs, AbsolutePath path)
        {
            if (!processOutputs.TryGetOutputFile(FileArtifact.CreateSourceFile(path), out var file))
            {
                throw new InvalidOperationException();
            }

            return(file);
        }
 public ProcessWithOutputs(Process process, ProcessOutputs processOutputs)
 {
     Process        = process;
     ProcessOutputs = processOutputs;
 }
Exemple #4
0
        /// <summary>
        /// Wraps up all generated state, bundles it in the Process pip and the ProcessOutputs object to be
        /// handed down to those who need to get the files out and then releases all the temporary structures
        /// back to their respective pools.
        /// </summary>
        public bool TryFinish(PipConstructionHelper pipConstructionHelper, out Process process, out ProcessOutputs processOutputs)
        {
            // Provenance and default directory
            var      provenance       = pipConstructionHelper.CreatePipProvenance(Usage);
            PathAtom folderName       = Executable.Path.GetName(m_pathTable).Concat(m_pathTable.StringTable, PathAtom.Create(m_pathTable.StringTable, ".std"));
            var      defaultDirectory = pipConstructionHelper.GetUniqueObjectDirectory(folderName);

            // arguments
            var arguments = FinishArgumentsAndOverflowArgumentsToResponseFile(defaultDirectory);

            // Handle temp files
            if (m_enableAutomaticTempDirectory && !TempDirectory.IsValid)
            {
                SetTempDirectory(pipConstructionHelper.GetUniqueTempDirectory());
            }

            // Handle output files
            var outputFileMap = new Dictionary <AbsolutePath, FileArtifactWithAttributes>();

            foreach (var file in m_outputFiles.Instance)
            {
                outputFileMap.Add(file.Path, file);
            }
            var outputFiles = ReadOnlyArray <FileArtifactWithAttributes> .From(m_outputFiles.Instance);

            // Handle temp directories
            foreach (var additionalTempDirectory in AdditionalTempDirectories)
            {
                if (additionalTempDirectory.IsValid)
                {
                    AddUntrackedDirectoryScope(DirectoryArtifact.CreateWithZeroPartialSealId(additionalTempDirectory));
                }
            }

            processOutputs = new ProcessOutputs(outputFileMap);

            process = new Process(
                executable: Executable,
                workingDirectory: WorkingDirectory.IsValid ? WorkingDirectory : defaultDirectory,
                arguments: arguments,
                responseFile: ResponseFile,
                responseFileData: ResponseFileData,

                environmentVariables: FinishEnvironmentVariables(),
                standardInput: StandardInput,
                standardOutput: m_standardOutputFile,
                standardError: m_standardErrorFile,
                standardDirectory: (m_standardOutputFile.IsValid && m_standardErrorFile.IsValid) ? AbsolutePath.Invalid : defaultDirectory,

                dependencies: ReadOnlyArray <FileArtifact> .From(m_inputFiles.Instance),
                directoryDependencies: ReadOnlyArray <DirectoryArtifact> .From(m_inputDirectories.Instance),
                orderDependencies: ReadOnlyArray <PipId> .Empty, // There is no code setting this yet.

                outputs: outputFiles,
                directoryOutputs: ReadOnlyArray <DirectoryArtifact> .Empty,

                tempDirectory: TempDirectory,
                additionalTempDirectories: AdditionalTempDirectories,
                untrackedPaths: ReadOnlyArray <AbsolutePath> .From(m_untrackedFilesAndDirectories.Instance),
                untrackedScopes: ReadOnlyArray <AbsolutePath> .From(m_untrackedDirectoryScopes.Instance.Select(dir => dir.Path)),

                tags: Tags,
                provenance: provenance,
                toolDescription: ToolDescription,

                successExitCodes: SuccessExitCodes,
                retryExitCodes: RetryExitCodes,
                semaphores: m_semaphores != null ? ReadOnlyArray <ProcessSemaphoreInfo> .From(m_semaphores.Values) : ReadOnlyArray <ProcessSemaphoreInfo> .Empty,
                warningTimeout: WarningTimeout,
                timeout: Timeout,
                warningRegex: WarningRegex ?? RegexDescriptor.CreateDefaultForWarnings(m_pathTable.StringTable),
                errorRegex: ErrorRegex ?? RegexDescriptor.CreateDefaultForErrors(m_pathTable.StringTable),

                uniqueOutputDirectory: defaultDirectory,
                options: Options,
                unsafeOptions: UnsafeOptions,
                allowedSurvivingChildProcessNames: AllowedSurvivingChildProcessNames,
                nestedProcessTerminationTimeout: NestedProcessTerminationTimeout
                );

            return(true);
        }