private async Task <Possible <Unit> > GenerateBuildDirectoryAsync() { Contract.Assert(m_buildDirectory.IsValid); AbsolutePath outputDirectory = m_host.GetFolderForFrontEnd(Name); AbsolutePath argumentsFile = outputDirectory.Combine(m_context.PathTable, Guid.NewGuid().ToString()); if (!TryRetrieveCMakeSearchLocations(out IEnumerable <AbsolutePath> searchLocations)) { return(new CMakeGenerationError(m_resolverSettings.ModuleName, m_buildDirectory.ToString(m_context.PathTable))); } SandboxedProcessResult result = await ExecuteCMakeRunner(argumentsFile, searchLocations); string standardError = result.StandardError.CreateReader().ReadToEndAsync().GetAwaiter().GetResult(); if (result.ExitCode != 0) { if (!m_context.CancellationToken.IsCancellationRequested) { Tracing.Logger.Log.CMakeRunnerInternalError( m_context.LoggingContext, m_resolverSettings.Location(m_context.PathTable), standardError); } return(new CMakeGenerationError(m_resolverSettings.ModuleName, m_buildDirectory.ToString(m_context.PathTable))); } FrontEndUtilities.TrackToolFileAccesses(m_host.Engine, m_context, Name, result.AllUnexpectedFileAccesses, outputDirectory); return(Possible.Create(Unit.Void)); }
private void TrackFilesAndEnvironment(BuildParameters.IBuildParameters buildParameters, ISet <ReportedFileAccess> fileAccesses, AbsolutePath frontEndFolder) { // Register all build parameters passed to the graph construction process // TODO: we actually need the build parameters *used* by the graph construction process, but for now this is a compromise to keep // graph caching sound. We need to modify this when MsBuild static graph API starts providing used env vars. foreach (string key in buildParameters.ToDictionary().Keys) { Engine.TryGetBuildParameter(key, MsBuildFrontEnd.Name, out _); } FrontEndUtilities.TrackToolFileAccesses(Engine, Context, MsBuildFrontEnd.Name, fileAccesses, frontEndFolder); }
private void TrackFilesAndEnvironment(ISet <ReportedFileAccess> fileAccesses, AbsolutePath frontEndFolder) { // Register all build parameters passed to the graph construction process // Observe passthrough variables are explicitly skipped: we don't want the engine to track them // TODO: we actually need the build parameters *used* by the graph construction process, but for now this is a compromise to keep // graph caching sound. We need to modify this when MsBuild static graph API starts providing used env vars. foreach (string key in m_userDefinedEnvironment.Keys) { m_host.Engine.TryGetBuildParameter(key, MsBuildFrontEnd.Name, out _); } FrontEndUtilities.TrackToolFileAccesses(m_host.Engine, m_context, MsBuildFrontEnd.Name, fileAccesses, frontEndFolder); }
private async Task <Possible <NinjaGraphResult> > ComputeBuildGraphAsync() { AbsolutePath outputFile = SerializedGraphPath.Value; SandboxedProcessResult result = await RunNinjaGraphBuilderAsync(outputFile); string standardError = result.StandardError.CreateReader().ReadToEndAsync().GetAwaiter().GetResult(); if (result.ExitCode != 0) { if (!m_context.CancellationToken.IsCancellationRequested) { Tracing.Logger.Log.GraphConstructionInternalError( m_context.LoggingContext, m_resolverSettings.Location(m_context.PathTable), standardError); } return(new NinjaGraphConstructionFailure(m_resolverSettings.ModuleName, ProjectRoot.ToString(m_context.PathTable))); } // If the tool exited gracefully, but standard error is not empty, that is interpreted as a warning if (!string.IsNullOrEmpty(standardError)) { Tracing.Logger.Log.GraphConstructionFinishedSuccessfullyButWithWarnings( m_context.LoggingContext, m_resolverSettings.Location(m_context.PathTable), standardError); } FrontEndUtilities.TrackToolFileAccesses(m_host.Engine, m_context, Name, result.AllUnexpectedFileAccesses, outputFile.GetParent(m_context.PathTable)); var serializer = JsonSerializer.Create(GraphSerializationSettings.Settings); // Add custom deserializer for converting string arrays to AbsolutePath ReadOnlySets serializer.Converters.Add(new RootAwareAbsolutePathConverter(m_context.PathTable, SpecFile.GetParent(m_context.PathTable))); serializer.Converters.Add(new ToReadOnlySetJsonConverter <AbsolutePath>()); var outputFileString = outputFile.ToString(m_context.PathTable); Tracing.Logger.Log.LeftGraphToolOutputAt(m_context.LoggingContext, m_resolverSettings.Location(m_context.PathTable), outputFileString); NinjaGraphResult projectGraphWithPredictionResult; using (var sr = new StreamReader(outputFileString)) using (var reader = new JsonTextReader(sr)) { projectGraphWithPredictionResult = serializer.Deserialize <NinjaGraphResult>(reader); } return(projectGraphWithPredictionResult); }
private void TrackFilesAndEnvironment(ISet <ReportedFileAccess> fileAccesses, AbsolutePath frontEndFolder) { // Register all build parameters passed to the graph construction process if they were retrieved from the process environment // Otherwise, if build parameters were defined by the main config file, then there is nothing to register: if the definition // in the config file actually accessed the environment, that was already registered during config evaluation. // TODO: we actually need the build parameters *used* by the graph construction process, but for now this is a compromise to keep // graph caching sound. We need to modify this when MsBuild static graph API starts providing used env vars. if (m_processEnvironmentUsed) { foreach (string key in m_userDefinedEnvironment.Keys) { m_host.Engine.TryGetBuildParameter(key, MsBuildFrontEnd.Name, out _); } } FrontEndUtilities.TrackToolFileAccesses(m_host.Engine, m_context, MsBuildFrontEnd.Name, fileAccesses, frontEndFolder); }