1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-01 16:38:31 +00:00

Mono: Fix custom defines for Mono's MSBuild; remove xbuild

Mono's MSBuild and System/VisualStudio's MSBuild expect a different format for surrounding property values with quotes on the command line.

xbuild does not seem to support semicolons in property values from the command line: https://xamarin.github.io/bugzilla-archives/16/16465/bug.html
It's a good time to just remove xbuild support entirely.
This commit is contained in:
Ignacio Etcheverry
2019-07-26 16:16:53 +02:00
parent ad0d87b4dd
commit 8821569689
3 changed files with 16 additions and 39 deletions

View File

@@ -137,7 +137,7 @@ namespace GodotTools.Build
private static string BuildArguments(string solution, string config, string loggerOutputDir, List<string> customProperties) private static string BuildArguments(string solution, string config, string loggerOutputDir, List<string> customProperties)
{ {
string arguments = $@"""{solution}"" /v:normal /t:Rebuild ""/p:{"Configuration=" + config}"" " + string arguments = $@"""{solution}"" /v:normal /t:Build ""/p:{"Configuration=" + config}"" " +
$@"""/l:{typeof(GodotBuildLogger).FullName},{GodotBuildLogger.AssemblyPath};{loggerOutputDir}"""; $@"""/l:{typeof(GodotBuildLogger).FullName},{GodotBuildLogger.AssemblyPath};{loggerOutputDir}""";
foreach (string customProperty in customProperties) foreach (string customProperty in customProperties)

View File

@@ -15,7 +15,6 @@ namespace GodotTools.Build
{ {
private static string _msbuildToolsPath = string.Empty; private static string _msbuildToolsPath = string.Empty;
private static string _msbuildUnixPath = string.Empty; private static string _msbuildUnixPath = string.Empty;
private static string _xbuildUnixPath = string.Empty;
public static string FindMsBuild() public static string FindMsBuild()
{ {
@@ -44,7 +43,6 @@ namespace GodotTools.Build
return Path.Combine(_msbuildToolsPath, "MSBuild.exe"); return Path.Combine(_msbuildToolsPath, "MSBuild.exe");
} }
case GodotSharpBuilds.BuildTool.MsBuildMono: case GodotSharpBuilds.BuildTool.MsBuildMono:
{ {
string msbuildPath = Path.Combine(Internal.MonoWindowsInstallRoot, "bin", "msbuild.bat"); string msbuildPath = Path.Combine(Internal.MonoWindowsInstallRoot, "bin", "msbuild.bat");
@@ -56,19 +54,6 @@ namespace GodotTools.Build
return msbuildPath; return msbuildPath;
} }
case GodotSharpBuilds.BuildTool.XBuild:
{
string xbuildPath = Path.Combine(Internal.MonoWindowsInstallRoot, "bin", "xbuild.bat");
if (!File.Exists(xbuildPath))
{
throw new FileNotFoundException($"Cannot find executable for '{GodotSharpBuilds.PropNameXbuild}'. Tried with path: {xbuildPath}");
}
return xbuildPath;
}
default: default:
throw new IndexOutOfRangeException("Invalid build tool in editor settings"); throw new IndexOutOfRangeException("Invalid build tool in editor settings");
} }
@@ -76,20 +61,7 @@ namespace GodotTools.Build
if (OS.IsUnix()) if (OS.IsUnix())
{ {
if (buildTool == GodotSharpBuilds.BuildTool.XBuild) if (buildTool == GodotSharpBuilds.BuildTool.MsBuildMono)
{
if (_xbuildUnixPath.Empty() || !File.Exists(_xbuildUnixPath))
{
// Try to search it again if it wasn't found last time or if it was removed from its location
_xbuildUnixPath = FindBuildEngineOnUnix("msbuild");
}
if (_xbuildUnixPath.Empty())
{
throw new FileNotFoundException($"Cannot find binary for '{GodotSharpBuilds.PropNameXbuild}'");
}
}
else
{ {
if (_msbuildUnixPath.Empty() || !File.Exists(_msbuildUnixPath)) if (_msbuildUnixPath.Empty() || !File.Exists(_msbuildUnixPath))
{ {
@@ -101,9 +73,13 @@ namespace GodotTools.Build
{ {
throw new FileNotFoundException($"Cannot find binary for '{GodotSharpBuilds.PropNameMsbuildMono}'"); throw new FileNotFoundException($"Cannot find binary for '{GodotSharpBuilds.PropNameMsbuildMono}'");
} }
}
return buildTool != GodotSharpBuilds.BuildTool.XBuild ? _msbuildUnixPath : _xbuildUnixPath; return _msbuildUnixPath;
}
else
{
throw new IndexOutOfRangeException("Invalid build tool in editor settings");
}
} }
throw new PlatformNotSupportedException(); throw new PlatformNotSupportedException();

View File

@@ -18,7 +18,6 @@ namespace GodotTools
public const string PropNameMsbuildMono = "MSBuild (Mono)"; public const string PropNameMsbuildMono = "MSBuild (Mono)";
public const string PropNameMsbuildVs = "MSBuild (VS Build Tools)"; public const string PropNameMsbuildVs = "MSBuild (VS Build Tools)";
public const string PropNameXbuild = "xbuild (Deprecated)";
public const string MsBuildIssuesFileName = "msbuild_issues.csv"; public const string MsBuildIssuesFileName = "msbuild_issues.csv";
public const string MsBuildLogFileName = "msbuild_log.txt"; public const string MsBuildLogFileName = "msbuild_log.txt";
@@ -26,8 +25,7 @@ namespace GodotTools
public enum BuildTool public enum BuildTool
{ {
MsBuildMono, MsBuildMono,
MsBuildVs, MsBuildVs
XBuild // Deprecated
} }
private static void RemoveOldIssuesFile(MonoBuildInfo buildInfo) private static void RemoveOldIssuesFile(MonoBuildInfo buildInfo)
@@ -202,6 +200,9 @@ namespace GodotTools
// case the user decided to delete them at some point after they were loaded. // case the user decided to delete them at some point after they were loaded.
Internal.UpdateApiAssembliesFromPrebuilt(); Internal.UpdateApiAssembliesFromPrebuilt();
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
var buildTool = (BuildTool)editorSettings.GetSetting("mono/builds/build_tool");
using (var pr = new EditorProgress("mono_project_debug_build", "Building project solution...", 1)) using (var pr = new EditorProgress("mono_project_debug_build", "Building project solution...", 1))
{ {
pr.Step("Building project solution", 0); pr.Step("Building project solution", 0);
@@ -209,7 +210,7 @@ namespace GodotTools
var buildInfo = new MonoBuildInfo(GodotSharpDirs.ProjectSlnPath, config); var buildInfo = new MonoBuildInfo(GodotSharpDirs.ProjectSlnPath, config);
// Add Godot defines // Add Godot defines
string constants = OS.IsWindows() ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\""; string constants = buildTool == BuildTool.MsBuildVs ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\"";
foreach (var godotDefine in godotDefines) foreach (var godotDefine in godotDefines)
constants += $"GODOT_{godotDefine.ToUpper().Replace("-", "_").Replace(" ", "_").Replace(";", "_")};"; constants += $"GODOT_{godotDefine.ToUpper().Replace("-", "_").Replace(" ", "_").Replace(";", "_")};";
@@ -217,7 +218,7 @@ namespace GodotTools
if (Internal.GodotIsRealTDouble()) if (Internal.GodotIsRealTDouble())
constants += "GODOT_REAL_T_IS_DOUBLE;"; constants += "GODOT_REAL_T_IS_DOUBLE;";
constants += OS.IsWindows() ? "\"" : "\\\""; constants += buildTool == BuildTool.MsBuildVs ? "\"" : "\\\"";
buildInfo.CustomProperties.Add(constants); buildInfo.CustomProperties.Add(constants);
@@ -267,8 +268,8 @@ namespace GodotTools
["name"] = "mono/builds/build_tool", ["name"] = "mono/builds/build_tool",
["hint"] = Godot.PropertyHint.Enum, ["hint"] = Godot.PropertyHint.Enum,
["hint_string"] = OS.IsWindows() ? ["hint_string"] = OS.IsWindows() ?
$"{PropNameMsbuildMono},{PropNameMsbuildVs},{PropNameXbuild}" : $"{PropNameMsbuildMono},{PropNameMsbuildVs}" :
$"{PropNameMsbuildMono},{PropNameXbuild}" $"{PropNameMsbuildMono}"
}); });
EditorDef("mono/builds/print_build_output", false); EditorDef("mono/builds/print_build_output", false);