summaryrefslogtreecommitdiff
path: root/modules/mono/editor/GodotSharpTools/Editor
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2019-07-03 09:44:53 +0200
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2019-07-05 09:38:23 +0200
commit270af6fa089ccfb93ace68ada8d476bd902b10fa (patch)
treefee771a4f58a8d799f70d37547391831f52b5cd2 /modules/mono/editor/GodotSharpTools/Editor
parent7b569e91c0c6b84965cad416b8e86dcfdacbcfc4 (diff)
Re-write mono module editor code in C#
Make the build system automatically build the C# Api assemblies to be shipped with the editor. Make the editor, editor player and debug export templates use Api assemblies built with debug symbols. Always run MSBuild to build the editor tools and Api assemblies when building Godot. Several bugs fixed related to assembly hot reloading and restoring state. Fix StringExtensions internal calls not being registered correctly, resulting in MissingMethodException.
Diffstat (limited to 'modules/mono/editor/GodotSharpTools/Editor')
-rw-r--r--modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs75
-rw-r--r--modules/mono/editor/GodotSharpTools/Editor/MonoDevelopInstance.cs145
2 files changed, 0 insertions, 220 deletions
diff --git a/modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs b/modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs
deleted file mode 100644
index 44a43f0ddd..0000000000
--- a/modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.CompilerServices;
-
-namespace GodotSharpTools.Editor
-{
- public static class GodotSharpExport
- {
- public static void _ExportBegin(string[] features, bool debug, string path, int flags)
- {
- var featureSet = new HashSet<string>(features);
-
- if (PlatformHasTemplateDir(featureSet))
- {
- string templateDirName = "data.mono";
-
- if (featureSet.Contains("Windows"))
- {
- templateDirName += ".windows";
- templateDirName += featureSet.Contains("64") ? ".64" : ".32";
- }
- else if (featureSet.Contains("X11"))
- {
- templateDirName += ".x11";
- templateDirName += featureSet.Contains("64") ? ".64" : ".32";
- }
- else
- {
- throw new NotSupportedException("Target platform not supported");
- }
-
- templateDirName += debug ? ".release_debug" : ".release";
-
- string templateDirPath = Path.Combine(GetTemplatesDir(), templateDirName);
-
- if (!Directory.Exists(templateDirPath))
- throw new FileNotFoundException("Data template directory not found");
-
- string outputDir = new FileInfo(path).Directory.FullName;
-
- string outputDataDir = Path.Combine(outputDir, GetDataDirName());
-
- if (Directory.Exists(outputDataDir))
- Directory.Delete(outputDataDir, recursive: true); // Clean first
-
- Directory.CreateDirectory(outputDataDir);
-
- foreach (string dir in Directory.GetDirectories(templateDirPath, "*", SearchOption.AllDirectories))
- {
- Directory.CreateDirectory(Path.Combine(outputDataDir, dir.Substring(templateDirPath.Length + 1)));
- }
-
- foreach (string file in Directory.GetFiles(templateDirPath, "*", SearchOption.AllDirectories))
- {
- File.Copy(file, Path.Combine(outputDataDir, file.Substring(templateDirPath.Length + 1)));
- }
- }
- }
-
- public static bool PlatformHasTemplateDir(HashSet<string> featureSet)
- {
- // OSX export templates are contained in a zip, so we place
- // our custom template inside it and let Godot do the rest.
- return !featureSet.Any(f => new[] {"OSX", "Android"}.Contains(f));
- }
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- extern static string GetTemplatesDir();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- extern static string GetDataDirName();
- }
-}
diff --git a/modules/mono/editor/GodotSharpTools/Editor/MonoDevelopInstance.cs b/modules/mono/editor/GodotSharpTools/Editor/MonoDevelopInstance.cs
deleted file mode 100644
index fba4a8f65c..0000000000
--- a/modules/mono/editor/GodotSharpTools/Editor/MonoDevelopInstance.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
-
-namespace GodotSharpTools.Editor
-{
- public class MonoDevelopInstance
- {
- public enum EditorId
- {
- MonoDevelop = 0,
- VisualStudioForMac = 1
- }
-
- readonly string solutionFile;
- readonly EditorId editorId;
-
- Process process;
-
- public void Execute(string[] files)
- {
- bool newWindow = process == null || process.HasExited;
-
- List<string> args = new List<string>();
-
- string command;
-
- if (Utils.OS.IsOSX())
- {
- string bundleId = codeEditorBundleIds[editorId];
-
- if (IsApplicationBundleInstalled(bundleId))
- {
- command = "open";
-
- args.Add("-b");
- args.Add(bundleId);
-
- // The 'open' process must wait until the application finishes
- if (newWindow)
- args.Add("--wait-apps");
-
- args.Add("--args");
- }
- else
- {
- command = codeEditorPaths[editorId];
- }
- }
- else
- {
- command = codeEditorPaths[editorId];
- }
-
- args.Add("--ipc-tcp");
-
- if (newWindow)
- args.Add("\"" + Path.GetFullPath(solutionFile) + "\"");
-
- foreach (var file in files)
- {
- int semicolonIndex = file.IndexOf(';');
-
- string filePath = semicolonIndex < 0 ? file : file.Substring(0, semicolonIndex);
- string cursor = semicolonIndex < 0 ? string.Empty : file.Substring(semicolonIndex);
-
- args.Add("\"" + Path.GetFullPath(filePath.NormalizePath()) + cursor + "\"");
- }
-
- if (newWindow)
- {
- process = Process.Start(new ProcessStartInfo()
- {
- FileName = command,
- Arguments = string.Join(" ", args),
- UseShellExecute = false
- });
- }
- else
- {
- Process.Start(new ProcessStartInfo()
- {
- FileName = command,
- Arguments = string.Join(" ", args),
- UseShellExecute = false
- });
- }
- }
-
- public MonoDevelopInstance(string solutionFile, EditorId editorId)
- {
- if (editorId == EditorId.VisualStudioForMac && !Utils.OS.IsOSX())
- throw new InvalidOperationException($"{nameof(EditorId.VisualStudioForMac)} not supported on this platform");
-
- this.solutionFile = solutionFile;
- this.editorId = editorId;
- }
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private extern static bool IsApplicationBundleInstalled(string bundleId);
-
- static readonly IReadOnlyDictionary<EditorId, string> codeEditorPaths;
- static readonly IReadOnlyDictionary<EditorId, string> codeEditorBundleIds;
-
- static MonoDevelopInstance()
- {
- if (Utils.OS.IsOSX())
- {
- codeEditorPaths = new Dictionary<EditorId, string>
- {
- // Rely on PATH
- { EditorId.MonoDevelop, "monodevelop" },
- { EditorId.VisualStudioForMac, "VisualStudio" }
- };
- codeEditorBundleIds = new Dictionary<EditorId, string>
- {
- // TODO EditorId.MonoDevelop
- { EditorId.VisualStudioForMac, "com.microsoft.visual-studio" }
- };
- }
- else if (Utils.OS.IsWindows())
- {
- codeEditorPaths = new Dictionary<EditorId, string>
- {
- // XamarinStudio is no longer a thing, and the latest version is quite old
- // MonoDevelop is available from source only on Windows. The recommendation
- // is to use Visual Studio instead. Since there are no official builds, we
- // will rely on custom MonoDevelop builds being added to PATH.
- { EditorId.MonoDevelop, "MonoDevelop.exe" }
- };
- }
- else if (Utils.OS.IsUnix())
- {
- codeEditorPaths = new Dictionary<EditorId, string>
- {
- // Rely on PATH
- { EditorId.MonoDevelop, "monodevelop" }
- };
- }
- }
- }
-}