Add new settings about MSBuild
- toggle creation of binary logs - manage log verbosity - toggle logging in console
This commit is contained in:
parent
7cf42dbdee
commit
9bf2a0bcda
3 changed files with 89 additions and 4 deletions
|
@ -7,6 +7,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
using GodotTools.BuildLogger;
|
||||
using GodotTools.Utils;
|
||||
|
||||
|
@ -126,6 +127,8 @@ namespace GodotTools.Build
|
|||
|
||||
private static void BuildArguments(BuildInfo buildInfo, Collection<string> arguments)
|
||||
{
|
||||
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
|
||||
|
||||
// `dotnet clean` / `dotnet build` commands
|
||||
arguments.Add(buildInfo.OnlyClean ? "clean" : "build");
|
||||
|
||||
|
@ -150,12 +153,14 @@ namespace GodotTools.Build
|
|||
arguments.Add(buildInfo.Configuration);
|
||||
|
||||
// Verbosity
|
||||
arguments.Add("-v");
|
||||
arguments.Add("normal");
|
||||
AddVerbosityArguments(buildInfo, arguments, editorSettings);
|
||||
|
||||
// Logger
|
||||
AddLoggerArgument(buildInfo, arguments);
|
||||
|
||||
// Binary log
|
||||
AddBinaryLogArgument(buildInfo, arguments, editorSettings);
|
||||
|
||||
// Custom properties
|
||||
foreach (var customProperty in buildInfo.CustomProperties)
|
||||
{
|
||||
|
@ -165,6 +170,8 @@ namespace GodotTools.Build
|
|||
|
||||
private static void BuildPublishArguments(BuildInfo buildInfo, Collection<string> arguments)
|
||||
{
|
||||
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
|
||||
|
||||
arguments.Add("publish"); // `dotnet publish` command
|
||||
|
||||
// Solution
|
||||
|
@ -193,12 +200,14 @@ namespace GodotTools.Build
|
|||
arguments.Add("true");
|
||||
|
||||
// Verbosity
|
||||
arguments.Add("-v");
|
||||
arguments.Add("normal");
|
||||
AddVerbosityArguments(buildInfo, arguments, editorSettings);
|
||||
|
||||
// Logger
|
||||
AddLoggerArgument(buildInfo, arguments);
|
||||
|
||||
// Binary log
|
||||
AddBinaryLogArgument(buildInfo, arguments, editorSettings);
|
||||
|
||||
// Custom properties
|
||||
foreach (var customProperty in buildInfo.CustomProperties)
|
||||
{
|
||||
|
@ -213,6 +222,25 @@ namespace GodotTools.Build
|
|||
}
|
||||
}
|
||||
|
||||
private static void AddVerbosityArguments(BuildInfo buildInfo, Collection<string> arguments,
|
||||
EditorSettings editorSettings)
|
||||
{
|
||||
var verbosityLevel =
|
||||
editorSettings.GetSetting(GodotSharpEditor.Settings.VerbosityLevel).As<VerbosityLevelId>();
|
||||
arguments.Add("-v");
|
||||
arguments.Add(verbosityLevel switch
|
||||
{
|
||||
VerbosityLevelId.Quiet => "quiet",
|
||||
VerbosityLevelId.Minimal => "minimal",
|
||||
VerbosityLevelId.Detailed => "detailed",
|
||||
VerbosityLevelId.Diagnostic => "diagnostic",
|
||||
_ => "normal",
|
||||
});
|
||||
|
||||
if ((bool)editorSettings.GetSetting(GodotSharpEditor.Settings.NoConsoleLogging))
|
||||
arguments.Add("-noconlog");
|
||||
}
|
||||
|
||||
private static void AddLoggerArgument(BuildInfo buildInfo, Collection<string> arguments)
|
||||
{
|
||||
string buildLoggerPath = Path.Combine(Internals.GodotSharpDirs.DataEditorToolsDir,
|
||||
|
@ -222,6 +250,16 @@ namespace GodotTools.Build
|
|||
$"-l:{typeof(GodotBuildLogger).FullName},{buildLoggerPath};{buildInfo.LogsDirPath}");
|
||||
}
|
||||
|
||||
private static void AddBinaryLogArgument(BuildInfo buildInfo, Collection<string> arguments,
|
||||
EditorSettings editorSettings)
|
||||
{
|
||||
if (!(bool)editorSettings.GetSetting(GodotSharpEditor.Settings.CreateBinaryLog))
|
||||
return;
|
||||
|
||||
arguments.Add($"-bl:{Path.Combine(buildInfo.LogsDirPath, "msbuild.binlog")}");
|
||||
arguments.Add("-ds:False"); // Honestly never understood why -bl also switches -ds on.
|
||||
}
|
||||
|
||||
private static void RemovePlatformVariable(StringDictionary environmentVariables)
|
||||
{
|
||||
// EnvironmentVariables is case sensitive? Seriously?
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace GodotTools
|
|||
public static class Settings
|
||||
{
|
||||
public const string ExternalEditor = "dotnet/editor/external_editor";
|
||||
public const string VerbosityLevel = "dotnet/build/verbosity_level";
|
||||
public const string NoConsoleLogging = "dotnet/build/no_console_logging";
|
||||
public const string CreateBinaryLog = "dotnet/build/create_binary_log";
|
||||
}
|
||||
|
||||
private EditorSettings _editorSettings;
|
||||
|
@ -458,6 +461,9 @@ namespace GodotTools
|
|||
|
||||
// External editor settings
|
||||
EditorDef(Settings.ExternalEditor, Variant.From(ExternalEditorId.None));
|
||||
EditorDef(Settings.VerbosityLevel, Variant.From(VerbosityLevelId.Normal));
|
||||
EditorDef(Settings.NoConsoleLogging, false);
|
||||
EditorDef(Settings.CreateBinaryLog, false);
|
||||
|
||||
string settingsHintStr = "Disabled";
|
||||
|
||||
|
@ -490,6 +496,18 @@ namespace GodotTools
|
|||
["hint_string"] = settingsHintStr
|
||||
});
|
||||
|
||||
var verbosityLevels = Enum.GetValues<VerbosityLevelId>().Select(level => $"{Enum.GetName(level)}:{(int)level}");
|
||||
_editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
|
||||
{
|
||||
["type"] = (int)Variant.Type.Int,
|
||||
["name"] = Settings.VerbosityLevel,
|
||||
["hint"] = (int)PropertyHint.Enum,
|
||||
["hint_string"] = string.Join(",", verbosityLevels),
|
||||
});
|
||||
|
||||
OnSettingsChanged();
|
||||
_editorSettings.SettingsChanged += OnSettingsChanged;
|
||||
|
||||
// Export plugin
|
||||
var exportPlugin = new ExportPlugin();
|
||||
AddExportPlugin(exportPlugin);
|
||||
|
@ -514,6 +532,24 @@ namespace GodotTools
|
|||
AddChild(GodotIdeManager);
|
||||
}
|
||||
|
||||
public override void _DisablePlugin()
|
||||
{
|
||||
base._DisablePlugin();
|
||||
|
||||
_editorSettings.SettingsChanged -= OnSettingsChanged;
|
||||
}
|
||||
|
||||
private void OnSettingsChanged()
|
||||
{
|
||||
// We want to force NoConsoleLogging to true when the VerbosityLevel is at Detailed or above.
|
||||
// At that point, there's so much info logged that it doesn't make sense to display it in
|
||||
// the tiny editor window, and it'd make the editor hang or crash anyway.
|
||||
var verbosityLevel = _editorSettings.GetSetting(Settings.VerbosityLevel).As<VerbosityLevelId>();
|
||||
var hideConsoleLog = (bool)_editorSettings.GetSetting(Settings.NoConsoleLogging);
|
||||
if (verbosityLevel >= VerbosityLevelId.Detailed && !hideConsoleLog)
|
||||
_editorSettings.SetSetting(Settings.NoConsoleLogging, Variant.From(true));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
namespace GodotTools
|
||||
{
|
||||
public enum VerbosityLevelId : long
|
||||
{
|
||||
Quiet,
|
||||
Minimal,
|
||||
Normal,
|
||||
Detailed,
|
||||
Diagnostic,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue