C#: Add option to disable exporting debug symbols

- Add export option to configure if the exported game should include debug symbols (PDB).
- Remove unused `outputDir` local variable.
- Replace `Process.GetCurrentProcess().Id` with `System.Environment.ProcessId` (CA1837).
This commit is contained in:
Raul Santos 2023-02-25 18:13:35 +01:00
parent dc8a0c3cd1
commit 0aa1f3440e
No known key found for this signature in database
GPG key ID: B532473AE3A803E4
2 changed files with 27 additions and 10 deletions

View file

@ -279,12 +279,19 @@ namespace GodotTools.Build
[DisallowNull] string configuration,
[DisallowNull] string platform,
[DisallowNull] string runtimeIdentifier,
[DisallowNull] string publishOutputDir
[DisallowNull] string publishOutputDir,
bool includeDebugSymbols = true
)
{
var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, GodotSharpDirs.ProjectCsProjPath, configuration,
runtimeIdentifier, publishOutputDir, restore: true, rebuild: false, onlyClean: false);
if (!includeDebugSymbols)
{
buildInfo.CustomProperties.Add("DebugType=None");
buildInfo.CustomProperties.Add("DebugSymbols=false");
}
buildInfo.CustomProperties.Add($"GodotTargetPlatform={platform}");
if (Internal.GodotIsRealTDouble())
@ -308,9 +315,10 @@ namespace GodotTools.Build
[DisallowNull] string configuration,
[DisallowNull] string platform,
[DisallowNull] string runtimeIdentifier,
string publishOutputDir
string publishOutputDir,
bool includeDebugSymbols = true
) => PublishProjectBlocking(CreatePublishBuildInfo(configuration,
platform, runtimeIdentifier, publishOutputDir));
platform, runtimeIdentifier, publishOutputDir, includeDebugSymbols));
public static bool EditorBuildCallback()
{

View file

@ -1,7 +1,6 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using GodotTools.Build;
@ -35,6 +34,17 @@ namespace GodotTools.Export
}
},
{ "default_value", false }
},
new Godot.Collections.Dictionary()
{
{
"option", new Godot.Collections.Dictionary()
{
{ "name", "dotnet/include_debug_symbols" },
{ "type", (int)Variant.Type.Bool }
}
},
{ "default_value", true }
}
};
}
@ -110,11 +120,10 @@ namespace GodotTools.Export
throw new NotImplementedException("Target platform not yet implemented.");
}
string outputDir = new FileInfo(path).Directory?.FullName ??
throw new FileNotFoundException("Output base directory not found.");
string buildConfig = isDebug ? "ExportDebug" : "ExportRelease";
bool includeDebugSymbols = (bool)GetOption("dotnet/include_debug_symbols");
var archs = new List<string>();
if (features.Contains("x86_64"))
{
@ -151,7 +160,7 @@ namespace GodotTools.Export
// Create temporary publish output directory
string publishOutputTempDir = Path.Combine(Path.GetTempPath(), "godot-publish-dotnet",
$"{Process.GetCurrentProcess().Id}-{buildConfig}-{runtimeIdentifier}");
$"{System.Environment.ProcessId}-{buildConfig}-{runtimeIdentifier}");
_tempFolders.Add(publishOutputTempDir);
@ -161,7 +170,7 @@ namespace GodotTools.Export
// Execute dotnet publish
if (!BuildManager.PublishProjectBlocking(buildConfig, platform,
runtimeIdentifier, publishOutputTempDir))
runtimeIdentifier, publishOutputTempDir, includeDebugSymbols))
{
throw new InvalidOperationException("Failed to build project.");
}
@ -215,7 +224,7 @@ namespace GodotTools.Export
{
base._ExportEnd();
string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{Process.GetCurrentProcess().Id}");
string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{System.Environment.ProcessId}");
if (Directory.Exists(aotTempDir))
Directory.Delete(aotTempDir, recursive: true);