/// <summary> /// Creates a new RemapWriter /// </summary> public RemapWriter(Stream stream, PipExecutionContext context, PipGraphFragmentContext pipGraphFragmentContext, bool debug = false, bool leaveOpen = true, bool logStats = false) : base(debug, stream, leaveOpen, logStats) { m_inliningWriter = new InnerInliningWriter(stream, context.PathTable, debug, leaveOpen, logStats); m_symbolTable = context.SymbolTable; m_context = pipGraphFragmentContext; }
public void TestReadWrite() { using (var stream1 = new MemoryStream()) using (var stream2 = new MemoryStream()) { var pt1 = new PathTable(); using (var writer1 = new InliningWriter(stream1, pt1, leaveOpen: true)) { writer1.Write(AbsolutePath.Create(pt1, A("C", "f", "g", "h1"))); writer1.Write(AbsolutePath.Create(pt1, A("C", "f", "g", "h"))); writer1.Write(PathAtom.Create(pt1.StringTable, "a1")); writer1.Write(PathAtom.Create(pt1.StringTable, "a")); writer1.Write(StringId.Create(pt1.StringTable, "s1")); writer1.Write(StringId.Create(pt1.StringTable, "s")); } var pt2 = new PathTable(); using (var writer2 = new InliningWriter(stream2, pt2, leaveOpen: true)) { writer2.Write(AbsolutePath.Create(pt2, A("C", "f", "g", "h2"))); writer2.Write(AbsolutePath.Create(pt2, A("C", "f", "g", "h"))); writer2.Write(PathAtom.Create(pt2.StringTable, "a2")); writer2.Write(PathAtom.Create(pt2.StringTable, "a")); writer2.Write(StringId.Create(pt2.StringTable, "s2")); writer2.Write(StringId.Create(pt2.StringTable, "s")); } stream1.Seek(0, SeekOrigin.Begin); stream2.Seek(0, SeekOrigin.Begin); var pt = new PathTable(); using (var reader1 = new InliningReader(stream1, pt, leaveOpen: true)) { XAssert.AreEqual(A("C", "f", "g", "h1").ToCanonicalizedPath(), reader1.ReadAbsolutePath().ToString(pt).ToCanonicalizedPath()); XAssert.AreEqual(A("C", "f", "g", "h").ToCanonicalizedPath(), reader1.ReadAbsolutePath().ToString(pt).ToCanonicalizedPath()); XAssert.AreEqual("a1".ToCanonicalizedPath(), reader1.ReadPathAtom().ToString(pt.StringTable).ToCanonicalizedPath()); XAssert.AreEqual("a".ToCanonicalizedPath(), reader1.ReadPathAtom().ToString(pt.StringTable).ToCanonicalizedPath()); XAssert.AreEqual("s1", reader1.ReadStringId().ToString(pt.StringTable)); XAssert.AreEqual("s", reader1.ReadStringId().ToString(pt.StringTable)); } using (var reader2 = new InliningReader(stream2, pt, leaveOpen: true)) { XAssert.AreEqual(A("C", "f", "g", "h2").ToCanonicalizedPath(), reader2.ReadAbsolutePath().ToString(pt).ToCanonicalizedPath()); XAssert.AreEqual(A("C", "f", "g", "h").ToCanonicalizedPath(), reader2.ReadAbsolutePath().ToString(pt).ToCanonicalizedPath()); XAssert.AreEqual("a2".ToCanonicalizedPath(), reader2.ReadPathAtom().ToString(pt.StringTable).ToCanonicalizedPath()); XAssert.AreEqual("a".ToCanonicalizedPath(), reader2.ReadPathAtom().ToString(pt.StringTable).ToCanonicalizedPath()); XAssert.AreEqual("s2", reader2.ReadStringId().ToString(pt.StringTable)); XAssert.AreEqual("s", reader2.ReadStringId().ToString(pt.StringTable)); } } }
/// <summary> /// Creates an instance of <see cref="PipRemapWriter"/>. /// </summary> public PipRemapWriter(PipExecutionContext pipExecutionContext, PipGraphFragmentContext pipGraphFragmentContext, Stream stream, bool debug = false, bool leaveOpen = true, bool logStats = false) : base(debug, stream, leaveOpen, logStats) { Contract.Requires(pipExecutionContext != null); Contract.Requires(pipGraphFragmentContext != null); Contract.Requires(stream != null); m_pipExecutionContext = pipExecutionContext; m_pipGraphFragmentContext = pipGraphFragmentContext; m_inliningWriter = new InliningWriter(stream, pipExecutionContext.PathTable, debug, leaveOpen, logStats); m_pipDataEntriesPointerInlineWriter = new PipDataEntriesPointerInlineWriter(m_inliningWriter, stream, pipExecutionContext.PathTable, debug, leaveOpen, logStats); }
/// <summary> /// Creates an instance of <see cref="PipRemapWriter"/>. /// </summary> public PipRemapWriter(PipExecutionContext pipExecutionContext, PipGraphFragmentContext pipGraphFragmentContext, Stream stream, bool leaveOpen = true, char alternateSymbolSeparator = default) : base(debug: false, stream, leaveOpen, logStats: false) { Contract.Requires(pipExecutionContext != null); Contract.Requires(pipGraphFragmentContext != null); Contract.Requires(stream != null); m_pipExecutionContext = pipExecutionContext; m_pipGraphFragmentContext = pipGraphFragmentContext; m_inliningWriter = new InliningWriter(stream, pipExecutionContext.PathTable, debug: false, leaveOpen, logStats: false); m_pipDataEntriesPointerInlineWriter = new PipDataEntriesPointerInlineWriter(this, stream, pipExecutionContext.PathTable, debug: false, leaveOpen, logStats: false); m_alternateSymbolSeparatorAsArray = alternateSymbolSeparator != default ? new char[] { alternateSymbolSeparator } : new char[0]; m_alternateSymbolSeparatorAsString = alternateSymbolSeparator != default ? alternateSymbolSeparator.ToString() : string.Empty; }
public void RoundTripInlining() { var pt = new PathTable(); var st = pt.StringTable; var paths = new AbsolutePath[] { AbsolutePath.Create(pt, A("c", "a", "b", "c", "d")), AbsolutePath.Create(pt, A("c", "a", "b", "c")), AbsolutePath.Create(pt, A("d", "AAA", "CCC")), AbsolutePath.Create(pt, A("D", "AAA", "CCC")), AbsolutePath.Create(pt, A("F", "BBB", "CCC")) }; var strings = new StringId[] { StringId.Create(st, "AAA"), StringId.Create(st, "hello"), StringId.Create(st, "繙BШЂЋЧЉЊЖ"), StringId.Create(st, "buildxl"), StringId.Create(st, "inline") }; using (var stream = new MemoryStream()) { using (var writer = new InliningWriter(stream, pt)) { for (int i = 0; i < paths.Length; i++) { writer.Write(paths[i]); writer.Write(strings[i]); } } stream.Position = 0; using (var reader = new InliningReader(stream, pt)) { for (int i = 0; i < paths.Length; i++) { var readPath = reader.ReadAbsolutePath(); var readString = reader.ReadStringId(); Assert.Equal(paths[i], readPath); Assert.Equal(strings[i], readString); } } stream.Position = 0; var pt2 = new PathTable(); var st2 = pt2.StringTable; AbsolutePath.Create(pt2, A("d")); AbsolutePath.Create(pt2, A("x", "dir", "buildxl", "file.txt")); using (var reader = new InliningReader(stream, pt2)) { for (int i = 0; i < paths.Length; i++) { var readPath = reader.ReadAbsolutePath(); var readString = reader.ReadStringId(); Assert.Equal(paths[i].ToString(pt).ToUpperInvariant(), readPath.ToString(pt2).ToUpperInvariant()); Assert.Equal(strings[i].ToString(st), readString.ToString(st2)); } } } }
public InliningWriterDedupOutputStream(InliningWriter writer) { m_writer = writer; }
public PipDataEntriesPointerInlineWriter(InliningWriter baseInliningWriter, Stream stream, PathTable pathTable, bool debug = false, bool leaveOpen = true, bool logStats = false) : base(stream, pathTable, debug, leaveOpen, logStats) { m_baseInliningWriter = baseInliningWriter; }