fix streaming
This commit is contained in:
+9
-15
@@ -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");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user