/// <nodoc /> public static SidebandWriter Deserialize(BuildXLReader reader) { return(new SidebandWriter( metadata: SidebandMetadata.Deserialize(reader), sidebandLogFile: reader.ReadString(), rootDirectories: reader.ReadNullable(r => r.ReadReadOnlyList(r2 => r2.ReadString())))); }
/// <summary> /// Creates a new output logger for a given process. /// /// Shared opaque directory outputs of <paramref name="process"/> are used as root directories and /// <see cref="GetSidebandFileForProcess"/> is used as log base name. /// /// <seealso cref="SidebandWriter(SidebandMetadata, string, IReadOnlyList{string})"/> /// </summary> public SidebandWriter(SidebandMetadata metadata, PipExecutionContext context, Process process, AbsolutePath sidebandRootDirectory) : this( metadata, GetSidebandFileForProcess(context.PathTable, sidebandRootDirectory, process), process.DirectoryOutputs.Where(d => d.IsSharedOpaque).Select(d => d.Path.ToString(context.PathTable)).ToList()) { Contract.Requires(process != null); Contract.Requires(context != null); Contract.Requires(sidebandRootDirectory.IsValid); Contract.Requires(Directory.Exists(sidebandRootDirectory.ToString(context.PathTable))); }
/// <summary> /// Creates a new output logger. /// /// The underlying file is created only upon first write. /// </summary> /// <param name="metadata">Metadata</param> /// <param name="sidebandLogFile">File to which to save the log.</param> /// <param name="rootDirectories">Only paths under one of these root directories will be recorded.</param> public SidebandWriter(SidebandMetadata metadata, string sidebandLogFile, [CanBeNull] IReadOnlyList <string> rootDirectories) { Metadata = metadata; SidebandLogFile = sidebandLogFile; RootDirectories = rootDirectories; m_recordedPathsCache = new HashSet <AbsolutePath>(); m_envelopeId = FileEnvelopeId.Create(); m_lazyBxlWriter = Lazy.Create(() => { Directory.CreateDirectory(Path.GetDirectoryName(SidebandLogFile)); var writer = new BuildXLWriter( stream: new FileStream(SidebandLogFile, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Delete), debug: false, logStats: false, leaveOpen: false); // write header and metadata before anything else FileEnvelope.WriteHeader(writer.BaseStream, m_envelopeId); Metadata.Serialize(writer); return(writer); }); }
/// <summary> /// Reads and returns the metadata. /// /// Before calling this method, <see cref="ReadHeader(bool)"/> must be called first. /// </summary> public SidebandMetadata ReadMetadata() { IncrementAndAssertOrder(cnt => cnt == 2, "ReadMetadata must be called second, right after ReadHeader"); return(SidebandMetadata.Deserialize(m_bxlReader)); }