fix streaming

This commit is contained in:
2026-06-12 21:36:36 +02:00
parent b64a6221b8
commit 7275aa3db3
+9 -15
View File
@@ -97,27 +97,21 @@ static class CxxBuildTool
FileStream error = scope .(); FileStream error = scope .();
proc.AttachStandardOutput(output); proc.AttachStandardOutput(output);
proc.AttachStandardError(error); proc.AttachStandardError(error);
StreamReader outputSr = scope .(output);
StreamReader errorSr = scope .(error);
String str = scope .(); String str = scope .();
Span<uint8> buffer = uint8[1024](); while (!proc.HasExited || !outputSr.EndOfStream)
StringView bufferView = *(.)&buffer;
while (!proc.HasExited || !output.IsEmpty || !error.IsEmpty)
{ {
while (output.TryRead(buffer) case .Ok(let val) && val > 0)
str.Append(bufferView[..<val]);
if (!str.IsEmpty)
{
Console.Write(str);
str.Clear(); str.Clear();
if (outputSr.ReadLine(str) case .Ok && !str.IsEmpty)
Console.WriteLine(str);
} }
while (error.TryRead(buffer) case .Ok(let val) && val > 0)
str.Append(bufferView[..<val]);
if (!str.IsEmpty)
{
Console.Write(str);
str.Clear(); str.Clear();
} if (errorSr.ReadLine(str) case .Ok && !str.IsEmpty)
} Console.WriteLine(str);
Runtime.Assert(proc.ExitCode == 0, "command failed"); Runtime.Assert(proc.ExitCode == 0, "command failed");
} }