fix streaming
This commit is contained in:
+11
-17
@@ -97,28 +97,22 @@ static class CxxBuildTool
|
||||
FileStream error = scope .();
|
||||
proc.AttachStandardOutput(output);
|
||||
proc.AttachStandardError(error);
|
||||
StreamReader outputSr = scope .(output);
|
||||
StreamReader errorSr = scope .(error);
|
||||
|
||||
String str = scope .();
|
||||
Span<uint8> buffer = uint8[1024]();
|
||||
StringView bufferView = *(.)&buffer;
|
||||
while (!proc.HasExited || !output.IsEmpty || !error.IsEmpty)
|
||||
while (!proc.HasExited || !outputSr.EndOfStream)
|
||||
{
|
||||
while (output.TryRead(buffer) case .Ok(let val) && val > 0)
|
||||
str.Append(bufferView[..<val]);
|
||||
if (!str.IsEmpty)
|
||||
{
|
||||
Console.Write(str);
|
||||
str.Clear();
|
||||
}
|
||||
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 (outputSr.ReadLine(str) case .Ok && !str.IsEmpty)
|
||||
Console.WriteLine(str);
|
||||
|
||||
}
|
||||
|
||||
str.Clear();
|
||||
if (errorSr.ReadLine(str) case .Ok && !str.IsEmpty)
|
||||
Console.WriteLine(str);
|
||||
|
||||
Runtime.Assert(proc.ExitCode == 0, "command failed");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user