From 6718279a9ff89648718969aca33699521e28e543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sat, 24 Oct 2026 17:13:43 +0200 Subject: [PATCH] Add option to clean rebuild scripts --- GlitchyEditor/src/Editor.bf | 4 ++-- GlitchyEditor/src/EditorLayer.bf | 5 +++++ .../BuildScriptsBackgroundTask.bf | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/GlitchyEditor/src/Editor.bf b/GlitchyEditor/src/Editor.bf index 93ae1d3..acf6245 100644 --- a/GlitchyEditor/src/Editor.bf +++ b/GlitchyEditor/src/Editor.bf @@ -232,11 +232,11 @@ namespace GlitchyEditor } /// Rebuilds the C# scripts. - public BuildScriptsBackgroundTask BuildScripts(bool reloadAfterBuild = true) + public BuildScriptsBackgroundTask BuildScripts(bool reloadAfterBuild = true, bool doCleanRebuild = false) { ScriptEngine.SuspendAssemblyWatcher(); - BuildScriptsBackgroundTask task = new .(EditorApp.Instance.Settings.ScriptSettings.DotNetExecutablePath, EditorApp.Instance.EditorLayer.CurrentProject, false){ DeleteWhenEnded = true }; + BuildScriptsBackgroundTask task = new .(EditorApp.Instance.Settings.ScriptSettings.DotNetExecutablePath, EditorApp.Instance.EditorLayer.CurrentProject, releaseBuild: false, doCleanRebuild){ DeleteWhenEnded = true }; task.ContinueWith(new (task) => { ScriptEngine.ResumeAssemblyWatcher(); diff --git a/GlitchyEditor/src/EditorLayer.bf b/GlitchyEditor/src/EditorLayer.bf index 9f35cbd..28a783b 100644 --- a/GlitchyEditor/src/EditorLayer.bf +++ b/GlitchyEditor/src/EditorLayer.bf @@ -1543,6 +1543,11 @@ namespace GlitchyEditor ImGui.AttachTooltip("Compiles the C# script project."); + if(ImGui.MenuItem("Clean and build Scripts", "Ctrl+Shift+B")) + _editor.BuildScripts(doCleanRebuild: true); + + ImGui.AttachTooltip("Makes a clean rebuild of the C# script project."); + if(ImGui.MenuItem("Reload Scripts", "Ctrl+Shift+R")) _editor.ReloadScripts(); diff --git a/GlitchyEditor/src/Multithreading/BuildScriptsBackgroundTask.bf b/GlitchyEditor/src/Multithreading/BuildScriptsBackgroundTask.bf index 6984b77..6dde7c1 100644 --- a/GlitchyEditor/src/Multithreading/BuildScriptsBackgroundTask.bf +++ b/GlitchyEditor/src/Multithreading/BuildScriptsBackgroundTask.bf @@ -19,16 +19,18 @@ class BuildScriptsBackgroundTask : BackgroundTask private Project _project; private bool _releaseBuild; private StringView _dotnetPath; + private bool _doCleanRebuild; private String _buildLog = new .() ~ delete _; private SpawnedProcess _process ~ delete _; - public this(StringView dotnetPath, Project project, bool releaseBuild) + public this(StringView dotnetPath, Project project, bool releaseBuild, bool doCleanRebuild) { _dotnetPath = dotnetPath; _project = project; _releaseBuild = releaseBuild; + _doCleanRebuild = doCleanRebuild; } public override RunResult Run() @@ -81,10 +83,22 @@ class BuildScriptsBackgroundTask : BackgroundTask processInfo.SetFileName(EditorApp.Instance.Settings.ScriptSettings.DotNetExecutablePath); + StringView target; + + if (_doCleanRebuild) + { + target = "build -t:Rebuild"; + } + else + { + target = "build"; + } + + // -sc|--self-contained... Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine. // -> This might be useful to build the final game // -o|--ouput ... might be useful for building the final game - processInfo.SetArguments(scope $"build -c {(_releaseBuild ? "Release" : "Debug")}"); + processInfo.SetArguments(scope $"{target} -c {(_releaseBuild ? "Release" : "Debug")}"); _process = new SpawnedProcess();