output build logs

This commit is contained in:
Matt Parker
2025-08-27 20:50:27 +10:00
parent a00f5a414b
commit ff2cea5c7a
3 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
using GDExtensionBindgen;
using Godot;
namespace SharpIDE.Godot.Features.Build;
public partial class BuildPanel : Control
{
private Terminal _terminal = null!;
private Task _writeTask = Task.CompletedTask;
public override void _Ready()
{
_terminal = new Terminal(GetNode<Control>("%Terminal"));
Singletons.BuildService.BuildStarted += OnBuildStarted;
}
private async Task OnBuildStarted()
{
if (_writeTask.IsCompleted is not true)
{
// If the write task is already running, just clear the terminal - we reuse the channel for the build output 🤷‍♂️
await this.InvokeAsync(() => _terminal.Clear());
return;
}
_writeTask = GodotTask.Run(async () =>
{
await this.InvokeAsync(() => _terminal.Clear());
await foreach (var str in Singletons.BuildService.BuildTextWriter.ConsoleChannel.Reader.ReadAllAsync().ConfigureAwait(false))
{
await this.InvokeAsync(() => _terminal.Write(str));
}
});
}
}

View File

@@ -0,0 +1 @@
uid://dt46krpl6ds28

View File

@@ -1,4 +1,6 @@
[gd_scene format=3 uid="uid://co6dkhdolriej"]
[gd_scene load_steps=2 format=3 uid="uid://co6dkhdolriej"]
[ext_resource type="Script" uid="uid://dt46krpl6ds28" path="res://Features/Build/BuildPanel.cs" id="1_tx1bg"]
[node name="BuildPanel" type="Control"]
layout_mode = 3
@@ -7,6 +9,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_tx1bg")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
@@ -33,6 +36,7 @@ layout_mode = 2
size_flags_vertical = 3
[node name="Terminal" type="Terminal" parent="VBoxContainer/TerminalContainer"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0