Beispiel #1
0
        private bool TryExecuteArgumentsToPipBuilder(
            ProjectWithPredictions project,
            QualifierId qualifierId,
            out string failureDetail,
            out Process scheduledProcess)
        {
            // We create a pip construction helper for each project
            var pipConstructionHelper = GetPipConstructionHelperForProject(project, qualifierId);

            using (var processBuilder = ProcessBuilder.Create(PathTable, m_context.GetPipDataBuilder()))
            {
                // Configure the process to add an assortment of settings: arguments, response file, etc.
                if (!TryConfigureProcessBuilder(processBuilder, pipConstructionHelper, project, qualifierId, out AbsolutePath outputResultCacheFile, out failureDetail))
                {
                    scheduledProcess = null;
                    return(false);
                }

                // Process all predicted outputs and inputs, including the predicted project dependencies
                ProcessOutputs(project, processBuilder);
                ProcessInputs(project, processBuilder);

                // Try to schedule the process pip
                if (!pipConstructionHelper.TryAddProcess(processBuilder, out ProcessOutputs outputs, out scheduledProcess))
                {
                    failureDetail = "Failed to schedule the pip";
                    return(false);
                }

                // Add the computed outputs for this project, so dependencies can consume it
                var outputDirectories = outputs.GetOutputDirectories();

                // A valid output cache path indicates that the project is building in isolation
                MSBuildProjectOutputs projectOutputs;
                if (outputResultCacheFile == AbsolutePath.Invalid)
                {
                    projectOutputs = MSBuildProjectOutputs.CreateLegacy(outputDirectories);
                }
                else
                {
                    var success = outputs.TryGetOutputFile(outputResultCacheFile, out FileArtifact cacheFileArtifact);
                    if (!success)
                    {
                        Contract.Assert(false, I($"The output cache file {outputResultCacheFile.ToString(PathTable)} should be part of the project {project.FullPath.ToString(PathTable)} outputs."));
                    }

                    projectOutputs = MSBuildProjectOutputs.CreateIsolated(outputDirectories, cacheFileArtifact);
                }

                m_processOutputsPerProject[project] = projectOutputs;

                failureDetail = string.Empty;
                return(true);
            }
        }
Beispiel #2
0
        private bool TryExecuteArgumentsToPipBuilder(
            ProjectWithPredictions project,
            QualifierId qualifierId,
            out string failureDetail,
            out Process scheduledProcess)
        {
            // We create a pip construction helper for each project
            var pipConstructionHelper = GetPipConstructionHelperForProject(project, qualifierId);

            using (var processBuilder = ProcessBuilder.Create(PathTable, m_context.GetPipDataBuilder()))
            {
                // Configure the process to add an assortment of settings: arguments, response file, etc.
                if (!TryConfigureProcessBuilder(processBuilder, pipConstructionHelper, project, qualifierId, out AbsolutePath outputResultCacheFile, out failureDetail))
                {
                    scheduledProcess = null;
                    return(false);
                }

                // Process all predicted outputs and inputs, including the predicted project dependencies
                ProcessOutputs(project, processBuilder);
                ProcessInputs(project, processBuilder);

                // Try to schedule the process pip
                if (!pipConstructionHelper.TryAddProcess(processBuilder, out ProcessOutputs outputs, out scheduledProcess))
                {
                    failureDetail = "Failed to schedule the pip";
                    return(false);
                }

                // Add the computed outputs for this project, so dependencies can consume it
                var outputDirectories = outputs.GetOutputDirectories();

                // A valid output cache path indicates that the project is building in isolation
                MSBuildProjectOutputs projectOutputs;
                if (outputResultCacheFile == AbsolutePath.Invalid)
                {
                    projectOutputs = MSBuildProjectOutputs.CreateLegacy(outputDirectories);
                }
                else
                {
                    var success = outputs.TryGetOutputFile(outputResultCacheFile, out FileArtifact cacheFileArtifact);
                    if (!success)
                    {
                        Contract.Assert(false, I($"The output cache file {outputResultCacheFile.ToString(PathTable)} should be part of the project {project.FullPath.ToString(PathTable)} outputs."));
                    }

                    projectOutputs = MSBuildProjectOutputs.CreateIsolated(outputDirectories, cacheFileArtifact);
                }

                // If the project is not implementing the target protocol, emit corresponding warn/verbose
                if (!project.ImplementsTargetProtocol)
                {
                    if (project.ProjectReferences.Count != 0)
                    {
                        // Let's warn about this. Targets of the referenced projects may not be accurate
                        Tracing.Logger.Log.ProjectIsNotSpecifyingTheProjectReferenceProtocol(
                            m_context.LoggingContext,
                            Location.FromFile(project.FullPath.ToString(PathTable)),
                            project.FullPath.GetName(m_context.PathTable).ToString(m_context.StringTable));
                    }
                    else
                    {
                        // Just a verbose message in this case
                        Tracing.Logger.Log.LeafProjectIsNotSpecifyingTheProjectReferenceProtocol(
                            m_context.LoggingContext,
                            Location.FromFile(project.FullPath.ToString(PathTable)),
                            project.FullPath.GetName(m_context.PathTable).ToString(m_context.StringTable));
                    }
                }

                // Warn if default targets were appended to the targets to execute
                if (project.PredictedTargetsToExecute.IsDefaultTargetsAppended)
                {
                    Tracing.Logger.Log.ProjectPredictedTargetsAlsoContainDefaultTargets(
                        m_context.LoggingContext,
                        Location.FromFile(project.FullPath.ToString(PathTable)),
                        project.FullPath.GetName(m_context.PathTable).ToString(m_context.StringTable),
                        $"[{string.Join(";", project.PredictedTargetsToExecute.AppendedDefaultTargets)}]");
                }

                m_processOutputsPerProject[project] = projectOutputs;

                failureDetail = string.Empty;
                return(true);
            }
        }