summaryrefslogtreecommitdiff
path: root/modules/mono/editor
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/editor')
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotBuildLogger.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs8
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeClient.cs4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeConnection.cs4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotTools.IdeConnection.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageComposer.cs4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageParser.cs6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ApiSolutionGenerator.cs52
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj9
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs75
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/packages.config4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs24
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BuildManager.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BuildTab.cs8
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs8
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs127
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/ExternalEditorId.cs3
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs54
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj39
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs3
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeServer.cs4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs418
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs117
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/BindingsGenerator.cs87
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs8
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs8
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs20
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/User32Dll.cs10
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/packages.config5
-rw-r--r--modules/mono/editor/bindings_generator.cpp147
-rw-r--r--modules/mono/editor/bindings_generator.h8
-rw-r--r--modules/mono/editor/csharp_project.cpp52
-rw-r--r--modules/mono/editor/csharp_project.h7
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp26
-rw-r--r--modules/mono/editor/editor_internal_calls.h4
-rw-r--r--modules/mono/editor/godotsharp_export.cpp29
-rw-r--r--modules/mono/editor/godotsharp_export.h9
-rw-r--r--modules/mono/editor/script_class_parser.cpp59
-rw-r--r--modules/mono/editor/script_class_parser.h4
44 files changed, 946 insertions, 532 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotBuildLogger.cs b/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotBuildLogger.cs
index a0f6f1ff32..6015cb22b6 100644
--- a/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotBuildLogger.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotBuildLogger.cs
@@ -18,7 +18,7 @@ namespace GodotTools.BuildLogger
if (null == Parameters)
throw new LoggerException("Log directory was not set.");
- var parameters = Parameters.Split(new[] {';'});
+ var parameters = Parameters.Split(new[] { ';' });
string logDir = parameters[0];
diff --git a/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj b/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj
index dcfdd83831..1eaa36c1aa 100644
--- a/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.BuildLogger/GodotTools.BuildLogger.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
index 24c7cb1573..1974220f2f 100644
--- a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs
index 8cd7e76303..b531b6aeee 100644
--- a/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs
@@ -26,7 +26,7 @@ namespace GodotTools.Core
path = path.Replace('\\', '/');
- string[] parts = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
+ string[] parts = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
path = string.Join(Path.DirectorySeparatorChar.ToString(), parts).Trim();
@@ -44,7 +44,7 @@ namespace GodotTools.Core
public static string CsvEscape(this string value, char delimiter = ',')
{
- bool hasSpecialChar = value.IndexOfAny(new char[] {'\"', '\n', '\r', delimiter}) != -1;
+ bool hasSpecialChar = value.IndexOfAny(new char[] { '\"', '\n', '\r', delimiter }) != -1;
if (hasSpecialChar)
return "\"" + value.Replace("\"", "\"\"") + "\"";
@@ -54,8 +54,8 @@ namespace GodotTools.Core
public static string ToSafeDirName(this string dirName, bool allowDirSeparator)
{
- var invalidChars = new List<string> {":", "*", "?", "\"", "<", ">", "|"};
-
+ var invalidChars = new List<string> { ":", "*", "?", "\"", "<", ">", "|" };
+
if (allowDirSeparator)
{
// Directory separators are allowed, but disallow ".." to avoid going up the filesystem
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeClient.cs b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeClient.cs
index 4f56a8d71b..2bf3b83c75 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeClient.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeClient.cs
@@ -106,7 +106,7 @@ namespace GodotTools.IdeConnection
try
{
Logger.LogInfo("Connecting to Godot Ide Server");
-
+
tcpClient.Connect(IPAddress.Loopback, GodotIdeMetadata.Port);
Logger.LogInfo("Connection open with Godot Ide Server");
@@ -130,7 +130,7 @@ namespace GodotTools.IdeConnection
public void Start()
{
Logger.LogInfo("Starting Godot Ide Client");
-
+
fsWatcher.Changed += OnMetaFileChanged;
fsWatcher.Deleted += OnMetaFileDeleted;
fsWatcher.EnableRaisingEvents = true;
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeConnection.cs b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeConnection.cs
index e7e81f175e..6441be8d6e 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeConnection.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotIdeConnection.cs
@@ -149,7 +149,7 @@ namespace GodotTools.IdeConnection
public bool WriteMessage(Message message)
{
Logger.LogDebug($"Sending message {message}");
-
+
var messageComposer = new MessageComposer();
messageComposer.AddArgument(message.Id);
@@ -201,7 +201,7 @@ namespace GodotTools.IdeConnection
clientReader?.Dispose();
clientWriter?.Dispose();
- ((IDisposable) tcpClient)?.Dispose();
+ ((IDisposable)tcpClient)?.Dispose();
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotTools.IdeConnection.csproj b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotTools.IdeConnection.csproj
index 94e525715b..427a26508f 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotTools.IdeConnection.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/GodotTools.IdeConnection.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageComposer.cs b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageComposer.cs
index 9e4cd6ec1a..30ffe7a06e 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageComposer.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageComposer.cs
@@ -22,14 +22,14 @@ namespace GodotTools.IdeConnection
if (quoted)
{
stringBuilder.Append('"');
-
+
foreach (char @char in argument)
{
if (CharsToEscape.Contains(@char))
stringBuilder.Append('\\');
stringBuilder.Append(@char);
}
-
+
stringBuilder.Append('"');
}
else
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageParser.cs b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageParser.cs
index ed691e481f..4365d69989 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageParser.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeConnection/MessageParser.cs
@@ -37,7 +37,7 @@ namespace GodotTools.IdeConnection
while (i < messageLine.Length)
{
@char = messageLine[i];
-
+
if (quoted && @char == '"')
{
i++;
@@ -60,10 +60,10 @@ namespace GodotTools.IdeConnection
{
stringBuilder.Append(@char);
}
-
+
i++;
}
-
+
arguments.Add(stringBuilder.ToString());
stringBuilder.Clear();
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ApiSolutionGenerator.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ApiSolutionGenerator.cs
deleted file mode 100644
index bfae2afc13..0000000000
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ApiSolutionGenerator.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-
-namespace GodotTools.ProjectEditor
-{
- public static class ApiSolutionGenerator
- {
- public static void GenerateApiSolution(string solutionDir,
- string coreProjDir, IEnumerable<string> coreCompileItems,
- string editorProjDir, IEnumerable<string> editorCompileItems)
- {
- var solution = new DotNetSolution(ApiAssemblyNames.SolutionName);
-
- solution.DirectoryPath = solutionDir;
-
- // GodotSharp project
-
- const string coreApiAssemblyName = ApiAssemblyNames.Core;
-
- string coreGuid = ProjectGenerator.GenCoreApiProject(coreProjDir, coreCompileItems);
-
- var coreProjInfo = new DotNetSolution.ProjectInfo
- {
- Guid = coreGuid,
- PathRelativeToSolution = Path.Combine(coreApiAssemblyName, $"{coreApiAssemblyName}.csproj")
- };
- coreProjInfo.Configs.Add("Debug");
- coreProjInfo.Configs.Add("Release");
-
- solution.AddNewProject(coreApiAssemblyName, coreProjInfo);
-
- // GodotSharpEditor project
-
- const string editorApiAssemblyName = ApiAssemblyNames.Editor;
-
- string editorGuid = ProjectGenerator.GenEditorApiProject(editorProjDir,
- $"../{coreApiAssemblyName}/{coreApiAssemblyName}.csproj", editorCompileItems);
-
- var editorProjInfo = new DotNetSolution.ProjectInfo();
- editorProjInfo.Guid = editorGuid;
- editorProjInfo.PathRelativeToSolution = Path.Combine(editorApiAssemblyName, $"{editorApiAssemblyName}.csproj");
- editorProjInfo.Configs.Add("Debug");
- editorProjInfo.Configs.Add("Release");
-
- solution.AddNewProject(editorApiAssemblyName, editorProjInfo);
-
- // Save solution
-
- solution.Save();
- }
- }
-}
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj
index ab3a5d1aea..b6bb0aac34 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj
@@ -32,18 +32,11 @@
<Reference Include="System" />
<Reference Include="Microsoft.Build" />
<Reference Include="DotNet.Glob, Version=2.1.1.0, Culture=neutral, PublicKeyToken=b68cc888b4f632d1, processorArchitecture=MSIL">
- <!--
- When building Godot with 'mono_glue=no' SCons will build this project alone instead of the
- entire solution. $(SolutionDir) is not defined in that case, so we need to workaround that.
- We make SCons restore the NuGet packages in the project directory instead in this case.
- -->
- <HintPath Condition=" '$(SolutionDir)' != '' And Exists('$(SolutionDir)\packages\DotNet.Glob.2.1.1\lib\net45\DotNet.Glob.dll') ">$(SolutionDir)\packages\DotNet.Glob.2.1.1\lib\net45\DotNet.Glob.dll</HintPath>
- <HintPath Condition=" '$(SolutionDir)' == '' Or !Exists('$(SolutionDir)\packages\DotNet.Glob.2.1.1\lib\net45\DotNet.Glob.dll') ">$(ProjectDir)\packages\DotNet.Glob.2.1.1\lib\net45\DotNet.Glob.dll</HintPath>
+ <HintPath>$(SolutionDir)\packages\DotNet.Glob.2.1.1\lib\net45\DotNet.Glob.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ApiAssembliesInfo.cs" />
- <Compile Include="ApiSolutionGenerator.cs" />
<Compile Include="DotNetSolution.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="IdentifierUtils.cs" />
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs
index 4f21871f1a..82627de01a 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs
@@ -2,6 +2,7 @@ using GodotTools.Core;
using System;
using System.Collections.Generic;
using System.IO;
+using System.Reflection;
using Microsoft.Build.Construction;
namespace GodotTools.ProjectEditor
@@ -10,68 +11,13 @@ namespace GodotTools.ProjectEditor
{
private const string CoreApiProjectName = "GodotSharp";
private const string EditorApiProjectName = "GodotSharpEditor";
- private const string CoreApiProjectGuid = "{AEBF0036-DA76-4341-B651-A3F2856AB2FA}";
- private const string EditorApiProjectGuid = "{8FBEC238-D944-4074-8548-B3B524305905}";
-
- public static string GenCoreApiProject(string dir, IEnumerable<string> compileItems)
- {
- string path = Path.Combine(dir, CoreApiProjectName + ".csproj");
-
- ProjectPropertyGroupElement mainGroup;
- var root = CreateLibraryProject(CoreApiProjectName, out mainGroup);
-
- mainGroup.AddProperty("DocumentationFile", Path.Combine("$(OutputPath)", "$(AssemblyName).xml"));
- mainGroup.SetProperty("RootNamespace", "Godot");
- mainGroup.SetProperty("ProjectGuid", CoreApiProjectGuid);
- mainGroup.SetProperty("BaseIntermediateOutputPath", "obj");
-
- GenAssemblyInfoFile(root, dir, CoreApiProjectName,
- new[] {"[assembly: InternalsVisibleTo(\"" + EditorApiProjectName + "\")]"},
- new[] {"System.Runtime.CompilerServices"});
-
- foreach (var item in compileItems)
- {
- root.AddItem("Compile", item.RelativeToPath(dir).Replace("/", "\\"));
- }
-
- root.Save(path);
-
- return CoreApiProjectGuid;
- }
-
- public static string GenEditorApiProject(string dir, string coreApiProjPath, IEnumerable<string> compileItems)
- {
- string path = Path.Combine(dir, EditorApiProjectName + ".csproj");
-
- ProjectPropertyGroupElement mainGroup;
- var root = CreateLibraryProject(EditorApiProjectName, out mainGroup);
-
- mainGroup.AddProperty("DocumentationFile", Path.Combine("$(OutputPath)", "$(AssemblyName).xml"));
- mainGroup.SetProperty("RootNamespace", "Godot");
- mainGroup.SetProperty("ProjectGuid", EditorApiProjectGuid);
- mainGroup.SetProperty("BaseIntermediateOutputPath", "obj");
-
- GenAssemblyInfoFile(root, dir, EditorApiProjectName);
-
- foreach (var item in compileItems)
- {
- root.AddItem("Compile", item.RelativeToPath(dir).Replace("/", "\\"));
- }
-
- var coreApiRef = root.AddItem("ProjectReference", coreApiProjPath.Replace("/", "\\"));
- coreApiRef.AddMetadata("Private", "False");
-
- root.Save(path);
-
- return EditorApiProjectGuid;
- }
public static string GenGameProject(string dir, string name, IEnumerable<string> compileItems)
{
string path = Path.Combine(dir, name + ".csproj");
ProjectPropertyGroupElement mainGroup;
- var root = CreateLibraryProject(name, out mainGroup);
+ var root = CreateLibraryProject(name, "Tools", out mainGroup);
mainGroup.SetProperty("OutputPath", Path.Combine(".mono", "temp", "bin", "$(Configuration)"));
mainGroup.SetProperty("BaseIntermediateOutputPath", Path.Combine(".mono", "temp", "obj"));
@@ -110,7 +56,7 @@ namespace GodotTools.ProjectEditor
return root.GetGuid().ToString().ToUpper();
}
- public static void GenAssemblyInfoFile(ProjectRootElement root, string dir, string name, string[] assemblyLines = null, string[] usingDirectives = null)
+ private static void GenAssemblyInfoFile(ProjectRootElement root, string dir, string name, string[] assemblyLines = null, string[] usingDirectives = null)
{
string propertiesDir = Path.Combine(dir, "Properties");
if (!Directory.Exists(propertiesDir))
@@ -138,7 +84,7 @@ namespace GodotTools.ProjectEditor
root.AddItem("Compile", assemblyInfoFile.RelativeToPath(dir).Replace("/", "\\"));
}
- public static ProjectRootElement CreateLibraryProject(string name, out ProjectPropertyGroupElement mainGroup)
+ public static ProjectRootElement CreateLibraryProject(string name, string defaultConfig, out ProjectPropertyGroupElement mainGroup)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentException($"{nameof(name)} cannot be empty", nameof(name));
@@ -147,7 +93,7 @@ namespace GodotTools.ProjectEditor
root.DefaultTargets = "Build";
mainGroup = root.AddPropertyGroup();
- mainGroup.AddProperty("Configuration", "Debug").Condition = " '$(Configuration)' == '' ";
+ mainGroup.AddProperty("Configuration", defaultConfig).Condition = " '$(Configuration)' == '' ";
mainGroup.AddProperty("Platform", "AnyCPU").Condition = " '$(Platform)' == '' ";
mainGroup.AddProperty("ProjectGuid", "{" + Guid.NewGuid().ToString().ToUpper() + "}");
mainGroup.AddProperty("OutputType", "Library");
@@ -155,6 +101,7 @@ namespace GodotTools.ProjectEditor
mainGroup.AddProperty("RootNamespace", IdentifierUtils.SanitizeQualifiedIdentifier(name, allowEmptyIdentifiers: true));
mainGroup.AddProperty("AssemblyName", name);
mainGroup.AddProperty("TargetFrameworkVersion", "v4.5");
+ mainGroup.AddProperty("GodotProjectGeneratorVersion", Assembly.GetExecutingAssembly().GetName().Version.ToString());
var debugGroup = root.AddPropertyGroup();
debugGroup.Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ";
@@ -184,16 +131,6 @@ namespace GodotTools.ProjectEditor
return root;
}
- private static void AddItems(ProjectRootElement elem, string groupName, params string[] items)
- {
- var group = elem.AddItemGroup();
-
- foreach (var item in items)
- {
- group.AddItem(groupName, item);
- }
- }
-
private const string AssemblyInfoTemplate =
@"using System.Reflection;{0}
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/packages.config b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/packages.config
index 13915000e4..2db030f9d8 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/packages.config
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/packages.config
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNet.Glob" version="2.1.1" targetFramework="net45" />
-</packages> \ No newline at end of file
+</packages>
diff --git a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
index 44813f962c..4c76d2abf1 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
@@ -34,7 +34,7 @@ namespace GodotTools
for (int i = 0; i < buildTabs.GetChildCount(); i++)
{
- var tab = (BuildTab) buildTabs.GetChild(i);
+ var tab = (BuildTab)buildTabs.GetChild(i);
if (tab == null)
continue;
@@ -120,7 +120,7 @@ namespace GodotTools
if (currentTab < 0 || currentTab >= buildTabs.GetTabCount())
throw new InvalidOperationException("No tab selected");
- var buildTab = (BuildTab) buildTabs.GetChild(currentTab);
+ var buildTab = (BuildTab)buildTabs.GetChild(currentTab);
buildTab.WarningsVisible = pressed;
buildTab.UpdateIssuesList();
}
@@ -132,7 +132,7 @@ namespace GodotTools
if (currentTab < 0 || currentTab >= buildTabs.GetTabCount())
throw new InvalidOperationException("No tab selected");
- var buildTab = (BuildTab) buildTabs.GetChild(currentTab);
+ var buildTab = (BuildTab)buildTabs.GetChild(currentTab);
buildTab.ErrorsVisible = pressed;
buildTab.UpdateIssuesList();
}
@@ -193,7 +193,7 @@ namespace GodotTools
int selectedItem = selectedItems[0];
- var buildTab = (BuildTab) buildTabs.GetTabControl(selectedItem);
+ var buildTab = (BuildTab)buildTabs.GetTabControl(selectedItem);
OS.ShellOpen(Path.Combine(buildTab.BuildInfo.LogsDirPath, BuildManager.MsBuildLogFileName));
}
@@ -249,14 +249,14 @@ namespace GodotTools
var editorBaseControl = editorInterface.GetBaseControl();
- SizeFlagsVertical = (int) SizeFlags.ExpandFill;
+ SizeFlagsVertical = (int)SizeFlags.ExpandFill;
SetAnchorsAndMarginsPreset(LayoutPreset.Wide);
panelTabs = new TabContainer
{
TabAlign = TabContainer.TabAlignEnum.Left,
RectMinSize = new Vector2(0, 228) * EditorScale,
- SizeFlagsVertical = (int) SizeFlags.ExpandFill
+ SizeFlagsVertical = (int)SizeFlags.ExpandFill
};
panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles"));
panelTabs.AddStyleboxOverride("tab_fg", editorBaseControl.GetStylebox("DebuggerTabFG", "EditorStyles"));
@@ -268,11 +268,11 @@ namespace GodotTools
panelBuildsTab = new VBoxContainer
{
Name = "Builds".TTR(),
- SizeFlagsHorizontal = (int) SizeFlags.ExpandFill
+ SizeFlagsHorizontal = (int)SizeFlags.ExpandFill
};
panelTabs.AddChild(panelBuildsTab);
- var toolBarHBox = new HBoxContainer {SizeFlagsHorizontal = (int) SizeFlags.ExpandFill};
+ var toolBarHBox = new HBoxContainer { SizeFlagsHorizontal = (int)SizeFlags.ExpandFill };
panelBuildsTab.AddChild(toolBarHBox);
var buildProjectBtn = new Button
@@ -320,12 +320,12 @@ namespace GodotTools
var hsc = new HSplitContainer
{
- SizeFlagsHorizontal = (int) SizeFlags.ExpandFill,
- SizeFlagsVertical = (int) SizeFlags.ExpandFill
+ SizeFlagsHorizontal = (int)SizeFlags.ExpandFill,
+ SizeFlagsVertical = (int)SizeFlags.ExpandFill
};
panelBuildsTab.AddChild(hsc);
- buildTabsList = new ItemList {SizeFlagsHorizontal = (int) SizeFlags.ExpandFill};
+ buildTabsList = new ItemList { SizeFlagsHorizontal = (int)SizeFlags.ExpandFill };
buildTabsList.Connect("item_selected", this, nameof(_BuildTabsItemSelected));
buildTabsList.Connect("nothing_selected", this, nameof(_BuildTabsNothingSelected));
hsc.AddChild(buildTabsList);
@@ -333,7 +333,7 @@ namespace GodotTools
buildTabs = new TabContainer
{
TabAlign = TabContainer.TabAlignEnum.Left,
- SizeFlagsHorizontal = (int) SizeFlags.ExpandFill,
+ SizeFlagsHorizontal = (int)SizeFlags.ExpandFill,
TabsVisible = false
};
hsc.AddChild(buildTabs);
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs
index da90c960e5..43c96d2e30 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildSystem.cs
@@ -46,7 +46,7 @@ namespace GodotTools.Build
{
if (OS.IsWindows)
{
- return (BuildManager.BuildTool) EditorSettings.GetSetting("mono/builds/build_tool")
+ return (BuildManager.BuildTool)EditorSettings.GetSetting("mono/builds/build_tool")
== BuildManager.BuildTool.MsBuildMono;
}
@@ -55,7 +55,7 @@ namespace GodotTools.Build
}
private static bool PrintBuildOutput =>
- (bool) EditorSettings.GetSetting("mono/builds/print_build_output");
+ (bool)EditorSettings.GetSetting("mono/builds/print_build_output");
private static Process LaunchBuild(string solution, string config, string loggerOutputDir, IEnumerable<string> customProperties = null)
{
@@ -90,7 +90,7 @@ namespace GodotTools.Build
// Needed when running from Developer Command Prompt for VS
RemovePlatformVariable(startInfo.EnvironmentVariables);
- var process = new Process {StartInfo = startInfo};
+ var process = new Process { StartInfo = startInfo };
process.Start();
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs
index ad8a6516ab..c3db52aa9e 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs
@@ -19,7 +19,7 @@ namespace GodotTools.Build
public static string FindMsBuild()
{
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
- var buildTool = (BuildManager.BuildTool) editorSettings.GetSetting("mono/builds/build_tool");
+ var buildTool = (BuildManager.BuildTool)editorSettings.GetSetting("mono/builds/build_tool");
if (OS.IsWindows)
{
@@ -136,11 +136,11 @@ namespace GodotTools.Build
string vsWherePath = Environment.GetEnvironmentVariable(Internal.GodotIs32Bits() ? "ProgramFiles" : "ProgramFiles(x86)");
vsWherePath += "\\Microsoft Visual Studio\\Installer\\vswhere.exe";
- var vsWhereArgs = new[] {"-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"};
+ var vsWhereArgs = new[] { "-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild" };
var outputArray = new Godot.Collections.Array<string>();
int exitCode = Godot.OS.Execute(vsWherePath, vsWhereArgs,
- blocking: true, output: (Godot.Collections.Array) outputArray);
+ blocking: true, output: (Godot.Collections.Array)outputArray);
if (exitCode != 0)
return string.Empty;
diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs
index 217bf5c144..fa6bf4dafd 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs
@@ -172,7 +172,7 @@ namespace GodotTools
}
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
- var buildTool = (BuildTool) editorSettings.GetSetting("mono/builds/build_tool");
+ var buildTool = (BuildTool)editorSettings.GetSetting("mono/builds/build_tool");
using (var pr = new EditorProgress("mono_project_debug_build", "Building project solution...", 1))
{
diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
index 807a20d9a1..727581daab 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
@@ -113,7 +113,7 @@ namespace GodotTools
throw new IndexOutOfRangeException("Item list index out of range");
// Get correct issue idx from issue list
- int issueIndex = (int) issuesList.GetItemMetadata(idx);
+ int issueIndex = (int)issuesList.GetItemMetadata(idx);
if (idx < 0 || idx >= issues.Count)
throw new IndexOutOfRangeException("Issue index out of range");
@@ -134,7 +134,7 @@ namespace GodotTools
if (file.StartsWith("res://"))
{
- var script = (Script) ResourceLoader.Load(file, typeHint: Internal.CSharpLanguageType);
+ var script = (Script)ResourceLoader.Load(file, typeHint: Internal.CSharpLanguageType);
if (script != null && Internal.ScriptEditorEdit(script, issue.Line, issue.Column))
Internal.EditorNodeShowScriptScreen();
@@ -220,7 +220,7 @@ namespace GodotTools
issuesList.Clear();
- var issue = new BuildIssue {Message = cause, Warning = false};
+ var issue = new BuildIssue { Message = cause, Warning = false };
ErrorCount += 1;
issues.Add(issue);
@@ -250,7 +250,7 @@ namespace GodotTools
{
base._Ready();
- issuesList = new ItemList {SizeFlagsVertical = (int) SizeFlags.ExpandFill};
+ issuesList = new ItemList { SizeFlagsVertical = (int)SizeFlags.ExpandFill };
issuesList.Connect("item_activated", this, nameof(_IssueActivated));
AddChild(issuesList);
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs b/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs
index c021a9051e..174509dc5b 100644
--- a/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs
@@ -26,7 +26,7 @@ namespace GodotTools
public static void AddItem(string projectPath, string itemType, string include)
{
- if (!(bool) GlobalDef("mono/project/auto_update_project", true))
+ if (!(bool)GlobalDef("mono/project/auto_update_project", true))
return;
ProjectUtils.AddItemToProjectChecked(projectPath, itemType, include);
@@ -49,7 +49,7 @@ namespace GodotTools
private static ulong ConvertToTimestamp(this DateTime value)
{
TimeSpan elapsedTime = value - Epoch;
- return (ulong) elapsedTime.TotalSeconds;
+ return (ulong)elapsedTime.TotalSeconds;
}
public static void GenerateScriptsMetadata(string projectPath, string outputPath)
@@ -68,7 +68,7 @@ namespace GodotTools
if (oldDict.TryGetValue(projectIncludeFile, out var oldFileVar))
{
- var oldFileDict = (Dictionary) oldFileVar;
+ var oldFileDict = (Dictionary)oldFileVar;
if (ulong.TryParse(oldFileDict["modified_time"] as string, out ulong storedModifiedTime))
{
@@ -108,7 +108,7 @@ namespace GodotTools
if (classDict.Count == 0)
continue; // Not found
- newDict[projectIncludeFile] = new Dictionary {["modified_time"] = $"{modifiedTime}", ["class"] = classDict};
+ newDict[projectIncludeFile] = new Dictionary { ["modified_time"] = $"{modifiedTime}", ["class"] = classDict };
}
if (newDict.Count > 0)
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
index cf3823fd16..96cafba87f 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
@@ -22,6 +22,7 @@ namespace GodotTools.Export
// TODO: These would be better as export preset options, but that doesn't seem to be supported yet
GlobalDef("mono/export/include_scripts_content", false);
+ GlobalDef("mono/export/export_assemblies_inside_pck", true);
GlobalDef("mono/export/aot/enabled", false);
GlobalDef("mono/export/aot/full_aot", false);
@@ -38,7 +39,7 @@ namespace GodotTools.Export
private void AddFile(string srcPath, string dstPath, bool remap = false)
{
- AddFile(dstPath, File.ReadAllBytes(srcPath), remap);
+ AddFile(dstPath.Replace("\\", "/"), File.ReadAllBytes(srcPath), remap);
}
public override void _ExportFile(string path, string type, string[] features)
@@ -53,7 +54,7 @@ namespace GodotTools.Export
// TODO What if the source file is not part of the game's C# project
- bool includeScriptsContent = (bool) ProjectSettings.GetSetting("mono/export/include_scripts_content");
+ bool includeScriptsContent = (bool)ProjectSettings.GetSetting("mono/export/include_scripts_content");
if (!includeScriptsContent)
{
@@ -77,7 +78,13 @@ namespace GodotTools.Export
catch (Exception e)
{
maybeLastExportError = e.Message;
- GD.PushError($"Failed to export project: {e.Message}");
+
+ // 'maybeLastExportError' cannot be null or empty if there was an error, so we
+ // must consider the possibility of exceptions being thrown without a message.
+ if (string.IsNullOrEmpty(maybeLastExportError))
+ maybeLastExportError = $"Exception thrown: {e.GetType().Name}";
+
+ GD.PushError($"Failed to export project: {maybeLastExportError}");
Console.Error.WriteLine(e);
// TODO: Do something on error once _ExportBegin supports failing.
}
@@ -113,7 +120,7 @@ namespace GodotTools.Export
var dependencies = new Godot.Collections.Dictionary<string, string>();
- var projectDllName = (string) ProjectSettings.GetSetting("application/config/name");
+ var projectDllName = (string)ProjectSettings.GetSetting("application/config/name");
if (projectDllName.Empty())
{
projectDllName = "UnnamedProject";
@@ -124,31 +131,56 @@ namespace GodotTools.Export
dependencies[projectDllName] = projectDllSrcPath;
+ if (platform == OS.Platforms.Android)
{
- string platformBclDir = DeterminePlatformBclDir(platform);
+ string godotAndroidExtProfileDir = GetBclProfileDir("godot_android_ext");
+ string monoAndroidAssemblyPath = Path.Combine(godotAndroidExtProfileDir, "Mono.Android.dll");
+
+ if (!File.Exists(monoAndroidAssemblyPath))
+ throw new FileNotFoundException("Assembly not found: 'Mono.Android'", monoAndroidAssemblyPath);
- internal_GetExportedAssemblyDependencies(projectDllName, projectDllSrcPath, buildConfig, platformBclDir, dependencies);
+ dependencies["Mono.Android"] = monoAndroidAssemblyPath;
}
+ var initialDependencies = dependencies.Duplicate();
+ internal_GetExportedAssemblyDependencies(initialDependencies, buildConfig, DeterminePlatformBclDir(platform), dependencies);
+
+ string outputDataDir = null;
+
+ if (PlatformHasTemplateDir(platform))
+ outputDataDir = ExportDataDirectory(features, platform, isDebug, outputDir);
+
string apiConfig = isDebug ? "Debug" : "Release";
string resAssembliesDir = Path.Combine(GodotSharpDirs.ResAssembliesBaseDir, apiConfig);
- foreach (var dependency in dependencies)
+ bool assembliesInsidePck = (bool)ProjectSettings.GetSetting("mono/export/export_assemblies_inside_pck") || outputDataDir == null;
+
+ if (!assembliesInsidePck)
{
- string dependSrcPath = dependency.Value;
- string dependDstPath = Path.Combine(resAssembliesDir, dependSrcPath.GetFile());
- AddFile(dependSrcPath, dependDstPath);
+ string outputDataGameAssembliesDir = Path.Combine(outputDataDir, "Assemblies");
+ if (!Directory.Exists(outputDataGameAssembliesDir))
+ Directory.CreateDirectory(outputDataGameAssembliesDir);
}
- // Mono specific export template extras (data dir)
- string outputDataDir = null;
+ foreach (var dependency in dependencies)
+ {
+ string dependSrcPath = dependency.Value;
- if (PlatformHasTemplateDir(platform))
- outputDataDir = ExportDataDirectory(features, platform, isDebug, outputDir);
+ if (assembliesInsidePck)
+ {
+ string dependDstPath = Path.Combine(resAssembliesDir, dependSrcPath.GetFile());
+ AddFile(dependSrcPath, dependDstPath);
+ }
+ else
+ {
+ string dependDstPath = Path.Combine(outputDataDir, "Assemblies", dependSrcPath.GetFile());
+ File.Copy(dependSrcPath, dependDstPath);
+ }
+ }
// AOT
- if ((bool) ProjectSettings.GetSetting("mono/export/aot/enabled"))
+ if ((bool)ProjectSettings.GetSetting("mono/export/aot/enabled"))
{
AotCompileDependencies(features, platform, isDebug, outputDir, outputDataDir, dependencies);
}
@@ -183,23 +215,25 @@ namespace GodotTools.Export
string TemplateDirName() => $"data.mono.{platform}.{bits}.{target}";
string templateDirPath = Path.Combine(Internal.FullTemplatesDir, TemplateDirName());
+ bool validTemplatePathFound = true;
if (!Directory.Exists(templateDirPath))
{
- templateDirPath = null;
+ validTemplatePathFound = false;
if (isDebug)
{
target = "debug"; // Support both 'release_debug' and 'debug' for the template data directory name
templateDirPath = Path.Combine(Internal.FullTemplatesDir, TemplateDirName());
+ validTemplatePathFound = true;
if (!Directory.Exists(templateDirPath))
- templateDirPath = null;
+ validTemplatePathFound = false;
}
}
- if (templateDirPath == null)
- throw new FileNotFoundException("Data template directory not found");
+ if (!validTemplatePathFound)
+ throw new FileNotFoundException("Data template directory not found", templateDirPath);
string outputDataDir = Path.Combine(outputDir, DataDirName);
@@ -308,7 +342,7 @@ namespace GodotTools.Export
AotCompileAssembly(platform, isDebug, data, assemblyPath, outputFilePathForThisAbi);
- AddSharedObject(outputFilePathForThisAbi, tags: new[] {abi});
+ AddSharedObject(outputFilePathForThisAbi, tags: new[] { abi });
}
}
else
@@ -349,7 +383,7 @@ namespace GodotTools.Export
string compilerCommand = Path.Combine(monoCrossBin, $"{toolPrefix}{monoExeName}{exeExt}");
- bool fullAot = (bool) ProjectSettings.GetSetting("mono/export/aot/full_aot");
+ bool fullAot = (bool)ProjectSettings.GetSetting("mono/export/aot/full_aot");
string EscapeOption(string option) => option.Contains(',') ? $"\"{option}\"" : option;
string OptionsToString(IEnumerable<string> options) => string.Join(",", options.Select(EscapeOption));
@@ -366,7 +400,7 @@ namespace GodotTools.Export
{
string abi = data["abi"];
- string androidToolchain = (string) ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path");
+ string androidToolchain = (string)ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path");
if (string.IsNullOrEmpty(androidToolchain))
{
@@ -391,13 +425,13 @@ namespace GodotTools.Export
aotOptions.Add("tool-prefix=" + Path.Combine(androidToolchain, "bin", androidToolPrefixes[abi]));
string triple = GetAndroidTriple(abi);
- aotOptions.Add ($"mtriple={triple}");
+ aotOptions.Add($"mtriple={triple}");
}
aotOptions.Add($"outfile={outputFilePath}");
- var extraAotOptions = (string[]) ProjectSettings.GetSetting("mono/export/aot/extra_aot_options");
- var extraOptimizerOptions = (string[]) ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options");
+ var extraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options");
+ var extraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options");
if (extraAotOptions.Length > 0)
aotOptions.AddRange(extraAotOptions);
@@ -485,7 +519,7 @@ namespace GodotTools.Export
case OS.Platforms.HTML5:
return "wasm-wasm32";
default:
- throw new NotSupportedException();
+ throw new NotSupportedException($"Platform not supported: {platform}");
}
}
@@ -547,7 +581,7 @@ namespace GodotTools.Export
private static bool PlatformHasTemplateDir(string platform)
{
// OSX export templates are contained in a zip, so we place our custom template inside it and let Godot do the rest.
- return !new[] {OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.HTML5}.Contains(platform);
+ return !new[] { OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform);
}
private static string DeterminePlatformFromFeatures(IEnumerable<string> features)
@@ -561,6 +595,12 @@ namespace GodotTools.Export
return null;
}
+ private static string GetBclProfileDir(string profile)
+ {
+ string templatesDir = Internal.FullTemplatesDir;
+ return Path.Combine(templatesDir, "bcl", profile);
+ }
+
private static string DeterminePlatformBclDir(string platform)
{
string templatesDir = Internal.FullTemplatesDir;
@@ -572,18 +612,45 @@ namespace GodotTools.Export
platformBclDir = Path.Combine(templatesDir, "bcl", profile);
if (!File.Exists(Path.Combine(platformBclDir, "mscorlib.dll")))
+ {
+ if (PlatformRequiresCustomBcl(platform))
+ throw new FileNotFoundException($"Missing BCL (Base Class Library) for platform: {platform}");
+
platformBclDir = null; // Use the one we're running on
+ }
}
return platformBclDir;
}
+ /// <summary>
+ /// Determines whether the BCL bundled with the Godot editor can be used for the target platform,
+ /// or if it requires a custom BCL that must be distributed with the export templates.
+ /// </summary>
+ private static bool PlatformRequiresCustomBcl(string platform)
+ {
+ if (new[] { OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform))
+ return true;
+
+ // The 'net_4_x' BCL is not compatible between Windows and the other platforms.
+ // We use the names 'net_4_x_win' and 'net_4_x' to differentiate between the two.
+
+ bool isWinOrUwp = new[]
+ {
+ OS.Platforms.Windows,
+ OS.Platforms.UWP
+ }.Contains(platform);
+
+ return OS.IsWindows ? !isWinOrUwp : isWinOrUwp;
+ }
+
private static string DeterminePlatformBclProfile(string platform)
{
switch (platform)
{
case OS.Platforms.Windows:
case OS.Platforms.UWP:
+ return "net_4_x_win";
case OS.Platforms.OSX:
case OS.Platforms.X11:
case OS.Platforms.Server:
@@ -594,7 +661,7 @@ namespace GodotTools.Export
case OS.Platforms.HTML5:
return "wasm";
default:
- throw new NotSupportedException();
+ throw new NotSupportedException($"Platform not supported: {platform}");
}
}
@@ -602,14 +669,14 @@ namespace GodotTools.Export
{
get
{
- var appName = (string) ProjectSettings.GetSetting("application/config/name");
+ var appName = (string)ProjectSettings.GetSetting("application/config/name");
string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false);
return $"data_{appNameSafe}";
}
}
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void internal_GetExportedAssemblyDependencies(string projectDllName, string projectDllSrcPath,
+ private static extern void internal_GetExportedAssemblyDependencies(Godot.Collections.Dictionary<string, string> initialDependencies,
string buildConfig, string customBclDir, Godot.Collections.Dictionary<string, string> dependencies);
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/ExternalEditorId.cs b/modules/mono/editor/GodotTools/GodotTools/ExternalEditorId.cs
index 4312ca0230..bb218c2f19 100644
--- a/modules/mono/editor/GodotTools/GodotTools/ExternalEditorId.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/ExternalEditorId.cs
@@ -6,6 +6,7 @@ namespace GodotTools
VisualStudio, // TODO (Windows-only)
VisualStudioForMac, // Mac-only
MonoDevelop,
- VsCode
+ VsCode,
+ Rider
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index 2a5d3de126..147bc95bb8 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -6,8 +6,10 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using GodotTools.Ides;
+using GodotTools.Ides.Rider;
using GodotTools.Internals;
using GodotTools.ProjectEditor;
+using JetBrains.Annotations;
using static GodotTools.Internals.Globals;
using File = GodotTools.Utils.File;
using OS = GodotTools.Utils.OS;
@@ -42,7 +44,7 @@ namespace GodotTools
string resourceDir = ProjectSettings.GlobalizePath("res://");
string path = resourceDir;
- string name = (string) ProjectSettings.GetSetting("application/config/name");
+ string name = (string)ProjectSettings.GetSetting("application/config/name");
if (name.Empty())
name = "UnnamedProject";
@@ -59,7 +61,7 @@ namespace GodotTools
{
Guid = guid,
PathRelativeToSolution = name + ".csproj",
- Configs = new List<string> {"Debug", "Release", "Tools"}
+ Configs = new List<string> { "Debug", "Release", "Tools" }
};
solution.AddNewProject(name, projectInfo);
@@ -108,20 +110,20 @@ namespace GodotTools
private void _RemoveCreateSlnMenuOption()
{
- menuPopup.RemoveItem(menuPopup.GetItemIndex((int) MenuOptions.CreateSln));
+ menuPopup.RemoveItem(menuPopup.GetItemIndex((int)MenuOptions.CreateSln));
bottomPanelBtn.Show();
}
private void _ShowAboutDialog()
{
- bool showOnStart = (bool) editorSettings.GetSetting("mono/editor/show_info_on_start");
+ bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start");
aboutDialogCheckBox.Pressed = showOnStart;
aboutDialog.PopupCenteredMinsize();
}
private void _ToggleAboutDialogOnStart(bool enabled)
{
- bool showOnStart = (bool) editorSettings.GetSetting("mono/editor/show_info_on_start");
+ bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start");
if (showOnStart != enabled)
editorSettings.SetSetting("mono/editor/show_info_on_start", enabled);
}
@@ -158,7 +160,7 @@ namespace GodotTools
if (what == NotificationReady)
{
- bool showInfoDialog = (bool) editorSettings.GetSetting("mono/editor/show_info_on_start");
+ bool showInfoDialog = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start");
if (showInfoDialog)
{
aboutDialog.PopupExclusive = true;
@@ -189,9 +191,10 @@ namespace GodotTools
"code", "code-oss", "vscode", "vscode-oss", "visual-studio-code", "visual-studio-code-oss"
};
+ [UsedImplicitly]
public Error OpenInExternalEditor(Script script, int line, int col)
{
- var editor = (ExternalEditorId) editorSettings.GetSetting("mono/editor/external_editor");
+ var editor = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor");
switch (editor)
{
@@ -202,6 +205,12 @@ namespace GodotTools
throw new NotSupportedException();
case ExternalEditorId.VisualStudioForMac:
goto case ExternalEditorId.MonoDevelop;
+ case ExternalEditorId.Rider:
+ {
+ string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath);
+ RiderPathManager.OpenFile(GodotSharpDirs.ProjectSlnPath, scriptPath, line);
+ return Error.Ok;
+ }
case ExternalEditorId.MonoDevelop:
{
string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath);
@@ -306,9 +315,10 @@ namespace GodotTools
return Error.Ok;
}
+ [UsedImplicitly]
public bool OverridesExternalEditor()
{
- return (ExternalEditorId) editorSettings.GetSetting("mono/editor/external_editor") != ExternalEditorId.None;
+ return (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor") != ExternalEditorId.None;
}
public override bool Build()
@@ -336,7 +346,7 @@ namespace GodotTools
bottomPanelBtn = AddControlToBottomPanel(BottomPanel, "Mono".TTR());
- AddChild(new HotReloadAssemblyWatcher {Name = "HotReloadAssemblyWatcher"});
+ AddChild(new HotReloadAssemblyWatcher { Name = "HotReloadAssemblyWatcher" });
menuPopup = new PopupMenu();
menuPopup.Hide();
@@ -346,7 +356,7 @@ namespace GodotTools
// TODO: Remove or edit this info dialog once Mono support is no longer in alpha
{
- menuPopup.AddItem("About C# support".TTR(), (int) MenuOptions.AboutCSharp);
+ menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp);
aboutDialog = new AcceptDialog();
editorBaseControl.AddChild(aboutDialog);
aboutDialog.WindowTitle = "Important: C# support is not feature-complete";
@@ -369,7 +379,7 @@ namespace GodotTools
var aboutLabel = new Label();
aboutHBox.AddChild(aboutLabel);
aboutLabel.RectMinSize = new Vector2(600, 150) * EditorScale;
- aboutLabel.SizeFlagsVertical = (int) Control.SizeFlags.ExpandFill;
+ aboutLabel.SizeFlagsVertical = (int)Control.SizeFlags.ExpandFill;
aboutLabel.Autowrap = true;
aboutLabel.Text =
"C# support in Godot Engine is in late alpha stage and, while already usable, " +
@@ -384,7 +394,7 @@ namespace GodotTools
EditorDef("mono/editor/show_info_on_start", true);
// CheckBox in main container
- aboutDialogCheckBox = new CheckBox {Text = "Show this warning when starting the editor"};
+ aboutDialogCheckBox = new CheckBox { Text = "Show this warning when starting the editor" };
aboutDialogCheckBox.Connect("toggled", this, nameof(_ToggleAboutDialogOnStart));
aboutVBox.AddChild(aboutDialogCheckBox);
}
@@ -397,7 +407,7 @@ namespace GodotTools
else
{
bottomPanelBtn.Hide();
- menuPopup.AddItem("Create C# solution".TTR(), (int) MenuOptions.CreateSln);
+ menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
}
menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));
@@ -418,19 +428,22 @@ namespace GodotTools
if (OS.IsWindows)
{
- settingsHintStr += $",MonoDevelop:{(int) ExternalEditorId.MonoDevelop}" +
- $",Visual Studio Code:{(int) ExternalEditorId.VsCode}";
+ settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
+ $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
+ $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
}
else if (OS.IsOSX)
{
- settingsHintStr += $",Visual Studio:{(int) ExternalEditorId.VisualStudioForMac}" +
- $",MonoDevelop:{(int) ExternalEditorId.MonoDevelop}" +
- $",Visual Studio Code:{(int) ExternalEditorId.VsCode}";
+ settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
+ $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
+ $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
+ $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
}
else if (OS.IsUnixLike())
{
- settingsHintStr += $",MonoDevelop:{(int) ExternalEditorId.MonoDevelop}" +
- $",Visual Studio Code:{(int) ExternalEditorId.VsCode}";
+ settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
+ $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
+ $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
}
editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
@@ -448,6 +461,7 @@ namespace GodotTools
exportPluginWeak = WeakRef(exportPlugin);
BuildManager.Initialize();
+ RiderPathManager.Initialize();
GodotIdeManager = new GodotIdeManager();
AddChild(GodotIdeManager);
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
index fb2cbabc8e..618527f916 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -9,6 +9,7 @@
<AssemblyName>GodotTools</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<GodotSourceRootPath>$(SolutionDir)/../../../../</GodotSourceRootPath>
+ <DataDirToolsOutputPath>$(GodotSourceRootPath)/bin/GodotSharp/Tools</DataDirToolsOutputPath>
<GodotApiConfiguration>Debug</GodotApiConfiguration>
<LangVersion>7</LangVersion>
</PropertyGroup>
@@ -30,13 +31,22 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Mono.Posix" />
+ <Reference Include="JetBrains.Annotations, Version=2019.1.3.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325">
+ <HintPath>..\packages\JetBrains.Annotations.2019.1.3\lib\net20\JetBrains.Annotations.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
+ <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
<Reference Include="System" />
<Reference Include="GodotSharp">
<HintPath>$(GodotSourceRootPath)/bin/GodotSharp/Api/$(GodotApiConfiguration)/GodotSharp.dll</HintPath>
+ <Private>False</Private>
</Reference>
<Reference Include="GodotSharpEditor">
<HintPath>$(GodotSourceRootPath)/bin/GodotSharp/Api/$(GodotApiConfiguration)/GodotSharpEditor.dll</HintPath>
+ <Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -47,7 +57,8 @@
<Compile Include="Ides\GodotIdeServer.cs" />
<Compile Include="Ides\MonoDevelop\EditorId.cs" />
<Compile Include="Ides\MonoDevelop\Instance.cs" />
- <Compile Include="Internals\BindingsGenerator.cs" />
+ <Compile Include="Ides\Rider\RiderPathLocator.cs" />
+ <Compile Include="Ides\Rider\RiderPathManager.cs" />
<Compile Include="Internals\EditorProgress.cs" />
<Compile Include="Internals\GodotSharpDirs.cs" />
<Compile Include="Internals\Internal.cs" />
@@ -67,6 +78,7 @@
<Compile Include="BottomPanel.cs" />
<Compile Include="CsProjOperations.cs" />
<Compile Include="Utils\CollectionExtensions.cs" />
+ <Compile Include="Utils\User32Dll.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GodotTools.BuildLogger\GodotTools.BuildLogger.csproj">
@@ -86,5 +98,24 @@
<Name>GodotTools.Core</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <Target Name="CopyToDataDir" AfterTargets="Build">
+ <ItemGroup>
+ <GodotToolsCopy Include="$(OutputPath)\GodotTools*.dll" />
+ <GodotToolsCopy Include="$(OutputPath)\Newtonsoft.Json.dll" />
+ <GodotToolsCopy Include="$(OutputPath)\DotNet.Glob.dll" />
+ </ItemGroup>
+ <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
+ <GodotToolsCopy Include="$(OutputPath)\GodotTools*.pdb" />
+ </ItemGroup>
+ <Copy SourceFiles="@(GodotToolsCopy)" DestinationFolder="$(DataDirToolsOutputPath)" ContinueOnError="false" />
+ </Target>
+ <Target Name="BuildAlwaysCopyToDataDir">
+ <!-- Custom target run by SCons to make sure the CopyToDataDir target is always executed, without having to use DisableFastUpToDateCheck -->
+ <CallTarget Targets="Build" />
+ <CallTarget Targets="CopyToDataDir" />
+ </Target>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
index 0f6f5ffadc..0ed567afd1 100644
--- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
@@ -38,7 +38,7 @@ namespace GodotTools
watchTimer = new Timer
{
OneShot = false,
- WaitTime = (float) EditorDef("mono/assembly_watch_interval_sec", 0.5)
+ WaitTime = (float)EditorDef("mono/assembly_watch_interval_sec", 0.5)
};
watchTimer.Connect("timeout", this, nameof(TimerTimeout));
AddChild(watchTimer);
diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs
index f94d6f998c..54f0ffab96 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeManager.cs
@@ -64,7 +64,7 @@ namespace GodotTools.Ides
private void LaunchIde()
{
- var editor = (ExternalEditorId) GodotSharpEditor.Instance.GetEditorInterface()
+ var editor = (ExternalEditorId)GodotSharpEditor.Instance.GetEditorInterface()
.GetEditorSettings().GetSetting("mono/editor/external_editor");
switch (editor)
@@ -72,6 +72,7 @@ namespace GodotTools.Ides
case ExternalEditorId.None:
case ExternalEditorId.VisualStudio:
case ExternalEditorId.VsCode:
+ case ExternalEditorId.Rider:
throw new NotSupportedException();
case ExternalEditorId.VisualStudioForMac:
goto case ExternalEditorId.MonoDevelop;
diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeServer.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeServer.cs
index 309b917c71..72676a8b24 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeServer.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Ides/GodotIdeServer.cs
@@ -45,7 +45,7 @@ namespace GodotTools.Ides
listener = new TcpListener(new IPEndPoint(IPAddress.Loopback, port: 0));
listener.Start();
- int port = ((IPEndPoint) listener.Server.LocalEndPoint).Port;
+ int port = ((IPEndPoint)listener.Server.LocalEndPoint).Port;
using (var metaFileWriter = new StreamWriter(metaFile, Encoding.UTF8))
{
metaFileWriter.WriteLine(port);
@@ -57,7 +57,7 @@ namespace GodotTools.Ides
public void StartServer()
{
- var serverThread = new Thread(RunServerThread) {Name = "Godot Ide Connection Server"};
+ var serverThread = new Thread(RunServerThread) { Name = "Godot Ide Connection Server" };
serverThread.Start();
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs
new file mode 100644
index 0000000000..9038333d38
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs
@@ -0,0 +1,418 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Godot;
+using JetBrains.Annotations;
+using Microsoft.Win32;
+using Newtonsoft.Json;
+using Directory = System.IO.Directory;
+using Environment = System.Environment;
+using File = System.IO.File;
+using Path = System.IO.Path;
+using OS = GodotTools.Utils.OS;
+
+namespace GodotTools.Ides.Rider
+{
+ /// <summary>
+ /// This code is a modified version of the JetBrains resharper-unity plugin listed under Apache License 2.0 license:
+ /// https://github.com/JetBrains/resharper-unity/blob/master/unity/JetBrains.Rider.Unity.Editor/EditorPlugin/RiderPathLocator.cs
+ /// </summary>
+ public static class RiderPathLocator
+ {
+ public static RiderInfo[] GetAllRiderPaths()
+ {
+ try
+ {
+ if (OS.IsWindows)
+ {
+ return CollectRiderInfosWindows();
+ }
+ if (OS.IsOSX)
+ {
+ return CollectRiderInfosMac();
+ }
+ if (OS.IsUnixLike())
+ {
+ return CollectAllRiderPathsLinux();
+ }
+ throw new Exception("Unexpected OS.");
+ }
+ catch (Exception e)
+ {
+ GD.PushWarning(e.Message);
+ }
+
+ return new RiderInfo[0];
+ }
+
+ private static RiderInfo[] CollectAllRiderPathsLinux()
+ {
+ var installInfos = new List<RiderInfo>();
+ var home = Environment.GetEnvironmentVariable("HOME");
+ if (!string.IsNullOrEmpty(home))
+ {
+ var toolboxRiderRootPath = GetToolboxBaseDir();
+ installInfos.AddRange(CollectPathsFromToolbox(toolboxRiderRootPath, "bin", "rider.sh", false)
+ .Select(a => new RiderInfo(a, true)).ToList());
+
+ //$Home/.local/share/applications/jetbrains-rider.desktop
+ var shortcut = new FileInfo(Path.Combine(home, @".local/share/applications/jetbrains-rider.desktop"));
+
+ if (shortcut.Exists)
+ {
+ var lines = File.ReadAllLines(shortcut.FullName);
+ foreach (var line in lines)
+ {
+ if (!line.StartsWith("Exec=\""))
+ continue;
+ var path = line.Split('"').Where((item, index) => index == 1).SingleOrDefault();
+ if (string.IsNullOrEmpty(path))
+ continue;
+
+ if (installInfos.Any(a => a.Path == path)) // avoid adding similar build as from toolbox
+ continue;
+ installInfos.Add(new RiderInfo(path, false));
+ }
+ }
+ }
+
+ // snap install
+ var snapInstallPath = "/snap/rider/current/bin/rider.sh";
+ if (new FileInfo(snapInstallPath).Exists)
+ installInfos.Add(new RiderInfo(snapInstallPath, false));
+
+ return installInfos.ToArray();
+ }
+
+ private static RiderInfo[] CollectRiderInfosMac()
+ {
+ var installInfos = new List<RiderInfo>();
+ // "/Applications/*Rider*.app"
+ // should be combined with "Contents/MacOS/rider"
+ var folder = new DirectoryInfo("/Applications");
+ if (folder.Exists)
+ {
+ installInfos.AddRange(folder.GetDirectories("*Rider*.app")
+ .Select(a => new RiderInfo(Path.Combine(a.FullName, "Contents/MacOS/rider"), false))
+ .ToList());
+ }
+
+ // /Users/user/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-1/181.3870.267/Rider EAP.app
+ // should be combined with "Contents/MacOS/rider"
+ var toolboxRiderRootPath = GetToolboxBaseDir();
+ var paths = CollectPathsFromToolbox(toolboxRiderRootPath, "", "Rider*.app", true)
+ .Select(a => new RiderInfo(Path.Combine(a, "Contents/MacOS/rider"), true));
+ installInfos.AddRange(paths);
+
+ return installInfos.ToArray();
+ }
+
+ private static RiderInfo[] CollectRiderInfosWindows()
+ {
+ var installInfos = new List<RiderInfo>();
+ var toolboxRiderRootPath = GetToolboxBaseDir();
+ var installPathsToolbox = CollectPathsFromToolbox(toolboxRiderRootPath, "bin", "rider64.exe", false).ToList();
+ installInfos.AddRange(installPathsToolbox.Select(a => new RiderInfo(a, true)).ToList());
+
+ var installPaths = new List<string>();
+ const string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
+ CollectPathsFromRegistry(registryKey, installPaths);
+ const string wowRegistryKey = @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
+ CollectPathsFromRegistry(wowRegistryKey, installPaths);
+
+ installInfos.AddRange(installPaths.Select(a => new RiderInfo(a, false)).ToList());
+
+ return installInfos.ToArray();
+ }
+
+ private static string GetToolboxBaseDir()
+ {
+ if (OS.IsWindows)
+ {
+ var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+ return Path.Combine(localAppData, @"JetBrains\Toolbox\apps\Rider");
+ }
+
+ if (OS.IsOSX)
+ {
+ var home = Environment.GetEnvironmentVariable("HOME");
+ if (!string.IsNullOrEmpty(home))
+ {
+ return Path.Combine(home, @"Library/Application Support/JetBrains/Toolbox/apps/Rider");
+ }
+ }
+
+ if (OS.IsUnixLike())
+ {
+ var home = Environment.GetEnvironmentVariable("HOME");
+ if (!string.IsNullOrEmpty(home))
+ {
+ return Path.Combine(home, @".local/share/JetBrains/Toolbox/apps/Rider");
+ }
+ }
+
+ throw new Exception("Unexpected OS.");
+ }
+
+ internal static ProductInfo GetBuildVersion(string path)
+ {
+ var buildTxtFileInfo = new FileInfo(Path.Combine(path, GetRelativePathToBuildTxt()));
+ var dir = buildTxtFileInfo.DirectoryName;
+ if (!Directory.Exists(dir))
+ return null;
+ var buildVersionFile = new FileInfo(Path.Combine(dir, "product-info.json"));
+ if (!buildVersionFile.Exists)
+ return null;
+ var json = File.ReadAllText(buildVersionFile.FullName);
+ return ProductInfo.GetProductInfo(json);
+ }
+
+ internal static Version GetBuildNumber(string path)
+ {
+ var file = new FileInfo(Path.Combine(path, GetRelativePathToBuildTxt()));
+ if (!file.Exists)
+ return null;
+ var text = File.ReadAllText(file.FullName);
+ if (text.Length <= 3)
+ return null;
+
+ var versionText = text.Substring(3);
+ return Version.TryParse(versionText, out var v) ? v : null;
+ }
+
+ internal static bool IsToolbox(string path)
+ {
+ return path.StartsWith(GetToolboxBaseDir());
+ }
+
+ private static string GetRelativePathToBuildTxt()
+ {
+ if (OS.IsWindows || OS.IsUnixLike())
+ return "../../build.txt";
+ if (OS.IsOSX)
+ return "Contents/Resources/build.txt";
+ throw new Exception("Unknown OS.");
+ }
+
+ private static void CollectPathsFromRegistry(string registryKey, List<string> installPaths)
+ {
+ using (var key = Registry.LocalMachine.OpenSubKey(registryKey))
+ {
+ if (key == null) return;
+ foreach (var subkeyName in key.GetSubKeyNames().Where(a => a.Contains("Rider")))
+ {
+ using (var subkey = key.OpenSubKey(subkeyName))
+ {
+ var folderObject = subkey?.GetValue("InstallLocation");
+ if (folderObject == null) continue;
+ var folder = folderObject.ToString();
+ var possiblePath = Path.Combine(folder, @"bin\rider64.exe");
+ if (File.Exists(possiblePath))
+ installPaths.Add(possiblePath);
+ }
+ }
+ }
+ }
+
+ private static string[] CollectPathsFromToolbox(string toolboxRiderRootPath, string dirName, string searchPattern,
+ bool isMac)
+ {
+ if (!Directory.Exists(toolboxRiderRootPath))
+ return new string[0];
+
+ var channelDirs = Directory.GetDirectories(toolboxRiderRootPath);
+ var paths = channelDirs.SelectMany(channelDir =>
+ {
+ try
+ {
+ // use history.json - last entry stands for the active build https://jetbrains.slack.com/archives/C07KNP99D/p1547807024066500?thread_ts=1547731708.057700&cid=C07KNP99D
+ var historyFile = Path.Combine(channelDir, ".history.json");
+ if (File.Exists(historyFile))
+ {
+ var json = File.ReadAllText(historyFile);
+ var build = ToolboxHistory.GetLatestBuildFromJson(json);
+ if (build != null)
+ {
+ var buildDir = Path.Combine(channelDir, build);
+ var executablePaths = GetExecutablePaths(dirName, searchPattern, isMac, buildDir);
+ if (executablePaths.Any())
+ return executablePaths;
+ }
+ }
+
+ var channelFile = Path.Combine(channelDir, ".channel.settings.json");
+ if (File.Exists(channelFile))
+ {
+ var json = File.ReadAllText(channelFile).Replace("active-application", "active_application");
+ var build = ToolboxInstallData.GetLatestBuildFromJson(json);
+ if (build != null)
+ {
+ var buildDir = Path.Combine(channelDir, build);
+ var executablePaths = GetExecutablePaths(dirName, searchPattern, isMac, buildDir);
+ if (executablePaths.Any())
+ return executablePaths;
+ }
+ }
+
+ // changes in toolbox json files format may brake the logic above, so return all found Rider installations
+ return Directory.GetDirectories(channelDir)
+ .SelectMany(buildDir => GetExecutablePaths(dirName, searchPattern, isMac, buildDir));
+ }
+ catch (Exception e)
+ {
+ // do not write to Debug.Log, just log it.
+ Logger.Warn($"Failed to get RiderPath from {channelDir}", e);
+ }
+
+ return new string[0];
+ })
+ .Where(c => !string.IsNullOrEmpty(c))
+ .ToArray();
+ return paths;
+ }
+
+ private static string[] GetExecutablePaths(string dirName, string searchPattern, bool isMac, string buildDir)
+ {
+ var folder = new DirectoryInfo(Path.Combine(buildDir, dirName));
+ if (!folder.Exists)
+ return new string[0];
+
+ if (!isMac)
+ return new[] { Path.Combine(folder.FullName, searchPattern) }.Where(File.Exists).ToArray();
+ return folder.GetDirectories(searchPattern).Select(f => f.FullName)
+ .Where(Directory.Exists).ToArray();
+ }
+
+ // Disable the "field is never assigned" compiler warning. We never assign it, but Unity does.
+ // Note that Unity disable this warning in the generated C# projects
+#pragma warning disable 0649
+
+ [Serializable]
+ class ToolboxHistory
+ {
+ public List<ItemNode> history;
+
+ public static string GetLatestBuildFromJson(string json)
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject<ToolboxHistory>(json).history.LastOrDefault()?.item.build;
+ }
+ catch (Exception)
+ {
+ Logger.Warn($"Failed to get latest build from json {json}");
+ }
+
+ return null;
+ }
+ }
+
+ [Serializable]
+ class ItemNode
+ {
+ public BuildNode item;
+ }
+
+ [Serializable]
+ class BuildNode
+ {
+ public string build;
+ }
+
+ [Serializable]
+ public class ProductInfo
+ {
+ public string version;
+ public string versionSuffix;
+
+ [CanBeNull]
+ internal static ProductInfo GetProductInfo(string json)
+ {
+ try
+ {
+ var productInfo = JsonConvert.DeserializeObject<ProductInfo>(json);
+ return productInfo;
+ }
+ catch (Exception)
+ {
+ Logger.Warn($"Failed to get version from json {json}");
+ }
+
+ return null;
+ }
+ }
+
+ // ReSharper disable once ClassNeverInstantiated.Global
+ [Serializable]
+ class ToolboxInstallData
+ {
+ // ReSharper disable once InconsistentNaming
+ public ActiveApplication active_application;
+
+ [CanBeNull]
+ public static string GetLatestBuildFromJson(string json)
+ {
+ try
+ {
+ var toolbox = JsonConvert.DeserializeObject<ToolboxInstallData>(json);
+ var builds = toolbox.active_application.builds;
+ if (builds != null && builds.Any())
+ return builds.First();
+ }
+ catch (Exception)
+ {
+ Logger.Warn($"Failed to get latest build from json {json}");
+ }
+
+ return null;
+ }
+ }
+
+ [Serializable]
+ class ActiveApplication
+ {
+ // ReSharper disable once InconsistentNaming
+ public List<string> builds;
+ }
+
+#pragma warning restore 0649
+
+ public struct RiderInfo
+ {
+ public bool IsToolbox;
+ public string Presentation;
+ public Version BuildNumber;
+ public ProductInfo ProductInfo;
+ public string Path;
+
+ public RiderInfo(string path, bool isToolbox)
+ {
+ BuildNumber = GetBuildNumber(path);
+ ProductInfo = GetBuildVersion(path);
+ Path = new FileInfo(path).FullName; // normalize separators
+ var presentation = $"Rider {BuildNumber}";
+
+ if (ProductInfo != null && !string.IsNullOrEmpty(ProductInfo.version))
+ {
+ var suffix = string.IsNullOrEmpty(ProductInfo.versionSuffix) ? "" : $" {ProductInfo.versionSuffix}";
+ presentation = $"Rider {ProductInfo.version}{suffix}";
+ }
+
+ if (isToolbox)
+ presentation += " (JetBrains Toolbox)";
+
+ Presentation = presentation;
+ IsToolbox = isToolbox;
+ }
+ }
+
+ private static class Logger
+ {
+ internal static void Warn(string message, Exception e = null)
+ {
+ throw new Exception(message, e);
+ }
+ }
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs
new file mode 100644
index 0000000000..558a242bf9
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Godot;
+using GodotTools.Internals;
+
+namespace GodotTools.Ides.Rider
+{
+ public static class RiderPathManager
+ {
+ private static readonly string editorPathSettingName = "mono/editor/editor_path_optional";
+
+ private static string GetRiderPathFromSettings()
+ {
+ var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
+ if (editorSettings.HasSetting(editorPathSettingName))
+ return (string)editorSettings.GetSetting(editorPathSettingName);
+ return null;
+ }
+
+ public static void Initialize()
+ {
+ var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
+ var editor = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor");
+ if (editor == ExternalEditorId.Rider)
+ {
+ if (!editorSettings.HasSetting(editorPathSettingName))
+ {
+ Globals.EditorDef(editorPathSettingName, "Optional");
+ editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
+ {
+ ["type"] = Variant.Type.String,
+ ["name"] = editorPathSettingName,
+ ["hint"] = PropertyHint.File,
+ ["hint_string"] = ""
+ });
+ }
+
+ var riderPath = (string)editorSettings.GetSetting(editorPathSettingName);
+ if (IsRiderAndExists(riderPath))
+ {
+ Globals.EditorDef(editorPathSettingName, riderPath);
+ return;
+ }
+
+ var paths = RiderPathLocator.GetAllRiderPaths();
+
+ if (!paths.Any())
+ return;
+
+ var newPath = paths.Last().Path;
+ Globals.EditorDef(editorPathSettingName, newPath);
+ editorSettings.SetSetting(editorPathSettingName, newPath);
+ }
+ }
+
+ private static bool IsRider(string path)
+ {
+ if (string.IsNullOrEmpty(path))
+ {
+ return false;
+ }
+
+ var fileInfo = new FileInfo(path);
+ var filename = fileInfo.Name.ToLowerInvariant();
+ return filename.StartsWith("rider", StringComparison.Ordinal);
+ }
+
+ private static string CheckAndUpdatePath(string riderPath)
+ {
+ if (IsRiderAndExists(riderPath))
+ {
+ return riderPath;
+ }
+
+ var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
+ var paths = RiderPathLocator.GetAllRiderPaths();
+
+ if (!paths.Any())
+ return null;
+
+ var newPath = paths.Last().Path;
+ editorSettings.SetSetting(editorPathSettingName, newPath);
+ Globals.EditorDef(editorPathSettingName, newPath);
+ return newPath;
+ }
+
+ private static bool IsRiderAndExists(string riderPath)
+ {
+ return !string.IsNullOrEmpty(riderPath) && IsRider(riderPath) && new FileInfo(riderPath).Exists;
+ }
+
+ public static void OpenFile(string slnPath, string scriptPath, int line)
+ {
+ var pathFromSettings = GetRiderPathFromSettings();
+ var path = CheckAndUpdatePath(pathFromSettings);
+
+ var args = new List<string>();
+ args.Add(slnPath);
+ if (line >= 0)
+ {
+ args.Add("--line");
+ args.Add(line.ToString());
+ }
+ args.Add(scriptPath);
+ try
+ {
+ Utils.OS.RunProcess(path, args);
+ }
+ catch (Exception e)
+ {
+ GD.PushError($"Error when trying to run code editor: JetBrains Rider. Exception message: '{e.Message}'");
+ }
+ }
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/BindingsGenerator.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/BindingsGenerator.cs
deleted file mode 100644
index 1daa5e138e..0000000000
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/BindingsGenerator.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using System;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace GodotTools.Internals
-{
- public class BindingsGenerator : IDisposable
- {
- class BindingsGeneratorSafeHandle : SafeHandle
- {
- public BindingsGeneratorSafeHandle(IntPtr handle) : base(IntPtr.Zero, true)
- {
- this.handle = handle;
- }
-
- public override bool IsInvalid => handle == IntPtr.Zero;
-
- protected override bool ReleaseHandle()
- {
- internal_Dtor(handle);
- return true;
- }
- }
-
- private BindingsGeneratorSafeHandle safeHandle;
- private bool disposed = false;
-
- public bool LogPrintEnabled
- {
- get => internal_LogPrintEnabled(GetPtr());
- set => internal_SetLogPrintEnabled(GetPtr(), value);
- }
-
- public static uint Version => internal_Version();
- public static uint CsGlueVersion => internal_CsGlueVersion();
-
- public Godot.Error GenerateCsApi(string outputDir) => internal_GenerateCsApi(GetPtr(), outputDir);
-
- internal IntPtr GetPtr()
- {
- if (disposed)
- throw new ObjectDisposedException(GetType().FullName);
-
- return safeHandle.DangerousGetHandle();
- }
-
- public void Dispose()
- {
- if (disposed)
- return;
-
- if (safeHandle != null && !safeHandle.IsInvalid)
- {
- safeHandle.Dispose();
- safeHandle = null;
- }
-
- disposed = true;
- }
-
- public BindingsGenerator()
- {
- safeHandle = new BindingsGeneratorSafeHandle(internal_Ctor());
- }
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern IntPtr internal_Ctor();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void internal_Dtor(IntPtr handle);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern bool internal_LogPrintEnabled(IntPtr handle);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void internal_SetLogPrintEnabled(IntPtr handle, bool enabled);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern Godot.Error internal_GenerateCsApi(IntPtr handle, string outputDir);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern uint internal_Version();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern uint internal_CsGlueVersion();
- }
-}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs
index ddf3b829b5..6893bc1974 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs
@@ -33,10 +33,10 @@ namespace GodotTools.Internals
#region Windows-only
public static string DataMonoBinDir => internal_DataMonoBinDir();
#endregion
-
-
+
+
#region Internal
-
+
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string internal_ResDataDir();
[MethodImpl(MethodImplOptions.InternalCall)]
@@ -85,7 +85,7 @@ namespace GodotTools.Internals
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern string internal_DataMonoBinDir();
#endregion
-
+
#endregion
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs
index 2497d276a9..80e45b3a3c 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs
@@ -39,10 +39,10 @@ namespace GodotTools.Internals
foreach (var classDeclDict in classesArray)
{
classesList.Add(new ClassDecl(
- (string) classDeclDict["name"],
- (string) classDeclDict["namespace"],
- (bool) classDeclDict["nested"],
- (int) classDeclDict["base_count"]
+ (string)classDeclDict["name"],
+ (string)classDeclDict["namespace"],
+ (bool)classDeclDict["nested"],
+ (int)classDeclDict["base_count"]
));
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
index 1a8c26acd7..279e67b3eb 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
@@ -5,7 +5,6 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
-using Mono.Unix.Native;
namespace GodotTools.Utils
{
@@ -15,6 +14,9 @@ namespace GodotTools.Utils
[MethodImpl(MethodImplOptions.InternalCall)]
static extern string GetPlatformName();
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ static extern bool UnixFileHasExecutableAccess(string filePath);
+
public static class Names
{
public const string Windows = "Windows";
@@ -65,7 +67,7 @@ namespace GodotTools.Utils
private static readonly Lazy<bool> _isAndroid = new Lazy<bool>(() => IsOS(Names.Android));
private static readonly Lazy<bool> _isHTML5 = new Lazy<bool>(() => IsOS(Names.HTML5));
- public static bool IsWindows => _isWindows.Value;
+ public static bool IsWindows => _isWindows.Value || IsUWP;
public static bool IsOSX => _isOSX.Value;
public static bool IsX11 => _isX11.Value;
public static bool IsServer => _isServer.Value;
@@ -75,7 +77,7 @@ namespace GodotTools.Utils
public static bool IsHTML5 => _isHTML5.Value;
private static bool? _isUnixCache;
- private static readonly string[] UnixLikePlatforms = {Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android};
+ private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android };
public static bool IsUnixLike()
{
@@ -105,7 +107,7 @@ namespace GodotTools.Utils
searchDirs.AddRange(pathDirs);
string nameExt = Path.GetExtension(name);
- bool hasPathExt = string.IsNullOrEmpty(nameExt) || windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase);
+ bool hasPathExt = !string.IsNullOrEmpty(nameExt) && windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase);
searchDirs.Add(System.IO.Directory.GetCurrentDirectory()); // last in the list
@@ -113,10 +115,10 @@ namespace GodotTools.Utils
return searchDirs.Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists);
return (from dir in searchDirs
- select Path.Combine(dir, name)
+ select Path.Combine(dir, name)
into path
- from ext in windowsExts
- select path + ext).FirstOrDefault(File.Exists);
+ from ext in windowsExts
+ select path + ext).FirstOrDefault(File.Exists);
}
private static string PathWhichUnix(string name)
@@ -131,7 +133,7 @@ namespace GodotTools.Utils
searchDirs.Add(System.IO.Directory.GetCurrentDirectory()); // last in the list
return searchDirs.Select(dir => Path.Combine(dir, name))
- .FirstOrDefault(path => File.Exists(path) && Syscall.access(path, AccessModes.X_OK) == 0);
+ .FirstOrDefault(path => File.Exists(path) && UnixFileHasExecutableAccess(path));
}
public static void RunProcess(string command, IEnumerable<string> arguments)
@@ -157,6 +159,8 @@ namespace GodotTools.Utils
process.BeginOutputReadLine();
process.BeginErrorReadLine();
+ if (IsWindows && process.Id > 0)
+ User32Dll.AllowSetForegroundWindow(process.Id); // allows application to focus itself
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/User32Dll.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/User32Dll.cs
new file mode 100644
index 0000000000..6810a991b3
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/User32Dll.cs
@@ -0,0 +1,10 @@
+using System.Runtime.InteropServices;
+
+namespace GodotTools.Utils
+{
+ public static class User32Dll
+ {
+ [DllImport("user32.dll")]
+ public static extern bool AllowSetForegroundWindow(int dwProcessId);
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools/packages.config b/modules/mono/editor/GodotTools/GodotTools/packages.config
new file mode 100644
index 0000000000..dd3de2865a
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="JetBrains.Annotations" version="2019.1.3" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
+</packages>
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 2252f7676d..9beadb1778 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -40,7 +40,6 @@
#include "core/os/os.h"
#include "core/ucaps.h"
-#include "../glue/cs_compressed.gen.h"
#include "../glue/cs_glue_version.gen.h"
#include "../godotsharp_defs.h"
#include "../mono_gd/gd_mono_marshal.h"
@@ -874,7 +873,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
p_output.append("\n#pragma warning restore CS1591\n");
}
-Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vector<String> &r_compile_items) {
+Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED);
@@ -887,22 +886,24 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vect
}
da->change_dir(p_proj_dir);
- da->make_dir("Core");
- da->make_dir("ObjectType");
+ da->make_dir("Generated");
+ da->make_dir("Generated/GodotObjects");
- String core_dir = path::join(p_proj_dir, "Core");
- String obj_type_dir = path::join(p_proj_dir, "ObjectType");
+ String base_gen_dir = path::join(p_proj_dir, "Generated");
+ String godot_objects_gen_dir = path::join(base_gen_dir, "GodotObjects");
+
+ Vector<String> compile_items;
// Generate source file for global scope constants and enums
{
StringBuilder constants_source;
_generate_global_constants(constants_source);
- String output_file = path::join(core_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_constants.cs");
+ String output_file = path::join(base_gen_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_constants.cs");
Error save_err = _save_file(output_file, constants_source);
if (save_err != OK)
return save_err;
- r_compile_items.push_back(output_file);
+ compile_items.push_back(output_file);
}
for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) {
@@ -911,7 +912,7 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vect
if (itype.api_type == ClassDB::API_EDITOR)
continue;
- String output_file = path::join(obj_type_dir, itype.proxy_name + ".cs");
+ String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
Error err = _generate_cs_type(itype, output_file);
if (err == ERR_SKIP)
@@ -920,39 +921,11 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vect
if (err != OK)
return err;
- r_compile_items.push_back(output_file);
+ compile_items.push_back(output_file);
}
// Generate sources from compressed files
- Map<String, GodotCsCompressedFile> compressed_files;
- get_compressed_files(compressed_files);
-
- for (Map<String, GodotCsCompressedFile>::Element *E = compressed_files.front(); E; E = E->next()) {
- const String &file_name = E->key();
- const GodotCsCompressedFile &file_data = E->value();
-
- String output_file = path::join(core_dir, file_name);
-
- Vector<uint8_t> data;
- data.resize(file_data.uncompressed_size);
- Compression::decompress(data.ptrw(), file_data.uncompressed_size, file_data.data, file_data.compressed_size, Compression::MODE_DEFLATE);
-
- String output_dir = output_file.get_base_dir();
-
- if (!DirAccess::exists(output_dir)) {
- Error err = da->make_dir_recursive(ProjectSettings::get_singleton()->globalize_path(output_dir));
- ERR_FAIL_COND_V(err != OK, ERR_CANT_CREATE);
- }
-
- FileAccessRef file = FileAccess::open(output_file, FileAccess::WRITE);
- ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE);
- file->store_buffer(data.ptr(), data.size());
- file->close();
-
- r_compile_items.push_back(output_file);
- }
-
StringBuilder cs_icalls_content;
cs_icalls_content.append("using System;\n"
@@ -986,18 +959,36 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vect
cs_icalls_content.append(INDENT1 CLOSE_BLOCK CLOSE_BLOCK);
- String internal_methods_file = path::join(core_dir, BINDINGS_CLASS_NATIVECALLS ".cs");
+ String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS ".cs");
Error err = _save_file(internal_methods_file, cs_icalls_content);
if (err != OK)
return err;
- r_compile_items.push_back(internal_methods_file);
+ compile_items.push_back(internal_methods_file);
+
+ StringBuilder includes_props_content;
+ includes_props_content.append("<Project>\n"
+ " <ItemGroup>\n");
+
+ for (int i = 0; i < compile_items.size(); i++) {
+ String include = path::relative_to(compile_items[i], p_proj_dir).replace("/", "\\");
+ includes_props_content.append(" <Compile Include=\"" + include + "\" />\n");
+ }
+
+ includes_props_content.append(" </ItemGroup>\n"
+ "</Project>\n");
+
+ String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props");
+
+ err = _save_file(includes_props_file, includes_props_content);
+ if (err != OK)
+ return err;
return OK;
}
-Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir, Vector<String> &r_compile_items) {
+Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED);
@@ -1010,11 +1001,13 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir, Ve
}
da->change_dir(p_proj_dir);
- da->make_dir("Core");
- da->make_dir("ObjectType");
+ da->make_dir("Generated");
+ da->make_dir("Generated/GodotObjects");
- String core_dir = path::join(p_proj_dir, "Core");
- String obj_type_dir = path::join(p_proj_dir, "ObjectType");
+ String base_gen_dir = path::join(p_proj_dir, "Generated");
+ String godot_objects_gen_dir = path::join(base_gen_dir, "GodotObjects");
+
+ Vector<String> compile_items;
for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) {
const TypeInterface &itype = E.get();
@@ -1022,7 +1015,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir, Ve
if (itype.api_type != ClassDB::API_EDITOR)
continue;
- String output_file = path::join(obj_type_dir, itype.proxy_name + ".cs");
+ String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
Error err = _generate_cs_type(itype, output_file);
if (err == ERR_SKIP)
@@ -1031,7 +1024,7 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir, Ve
if (err != OK)
return err;
- r_compile_items.push_back(output_file);
+ compile_items.push_back(output_file);
}
StringBuilder cs_icalls_content;
@@ -1068,13 +1061,31 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir, Ve
cs_icalls_content.append(INDENT1 CLOSE_BLOCK CLOSE_BLOCK);
- String internal_methods_file = path::join(core_dir, BINDINGS_CLASS_NATIVECALLS_EDITOR ".cs");
+ String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS_EDITOR ".cs");
Error err = _save_file(internal_methods_file, cs_icalls_content);
if (err != OK)
return err;
- r_compile_items.push_back(internal_methods_file);
+ compile_items.push_back(internal_methods_file);
+
+ StringBuilder includes_props_content;
+ includes_props_content.append("<Project>\n"
+ " <ItemGroup>\n");
+
+ for (int i = 0; i < compile_items.size(); i++) {
+ String include = path::relative_to(compile_items[i], p_proj_dir).replace("/", "\\");
+ includes_props_content.append(" <Compile Include=\"" + include + "\" />\n");
+ }
+
+ includes_props_content.append(" </ItemGroup>\n"
+ "</Project>\n");
+
+ String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props");
+
+ err = _save_file(includes_props_file, includes_props_content);
+ if (err != OK)
+ return err;
return OK;
}
@@ -1098,9 +1109,8 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
// Generate GodotSharp source files
String core_proj_dir = output_dir.plus_file(CORE_API_ASSEMBLY_NAME);
- Vector<String> core_compile_items;
- proj_err = generate_cs_core_project(core_proj_dir, core_compile_items);
+ proj_err = generate_cs_core_project(core_proj_dir);
if (proj_err != OK) {
ERR_PRINT("Generation of the Core API C# project failed.");
return proj_err;
@@ -1109,22 +1119,14 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
// Generate GodotSharpEditor source files
String editor_proj_dir = output_dir.plus_file(EDITOR_API_ASSEMBLY_NAME);
- Vector<String> editor_compile_items;
- proj_err = generate_cs_editor_project(editor_proj_dir, editor_compile_items);
+ proj_err = generate_cs_editor_project(editor_proj_dir);
if (proj_err != OK) {
ERR_PRINT("Generation of the Editor API C# project failed.");
return proj_err;
}
- // Generate solution
-
- if (!CSharpProject::generate_api_solution(output_dir,
- core_proj_dir, core_compile_items, editor_proj_dir, editor_compile_items)) {
- return ERR_CANT_CREATE;
- }
-
- _log("The solution for the Godot API was generated successfully\n");
+ _log("The Godot API sources were successfully generated\n");
return OK;
}
@@ -1600,7 +1602,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
// Apparently the name attribute must not include the @
String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1, iarg.name.length()) : iarg.name;
- default_args_doc.append(INDENT2 "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + def_arg + "</param>\n");
+ default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + def_arg + "</param>");
} else {
icall_params += arg_type->cs_in.empty() ? iarg.name : sformat(arg_type->cs_in, iarg.name);
}
@@ -1619,7 +1621,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
String xml_summary = bbcode_to_xml(fix_doc_description(p_imethod.method_doc->description), &p_itype);
Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
- if (summary_lines.size() || default_args_doc.get_string_length()) {
+ if (summary_lines.size()) {
p_output.append(MEMBER_BEGIN "/// <summary>\n");
for (int i = 0; i < summary_lines.size(); i++) {
@@ -1628,11 +1630,14 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
p_output.append("\n");
}
- p_output.append(default_args_doc.as_string());
p_output.append(INDENT2 "/// </summary>");
}
}
+ if (default_args_doc.get_string_length()) {
+ p_output.append(default_args_doc.as_string());
+ }
+
if (!p_imethod.is_internal) {
p_output.append(MEMBER_BEGIN "[GodotMethod(\"");
p_output.append(p_imethod.name);
@@ -2064,9 +2069,11 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ".ptr()" : "NULL");
p_output.append(", total_length, vcall_error);\n");
- // See the comment on the C_LOCAL_VARARG_RET declaration
- if (return_type->cname != name_cache.type_Variant) {
- p_output.append("\t" C_LOCAL_RET " = " C_LOCAL_VARARG_RET ";\n");
+ if (!ret_void) {
+ // See the comment on the C_LOCAL_VARARG_RET declaration
+ if (return_type->cname != name_cache.type_Variant) {
+ p_output.append("\t" C_LOCAL_RET " = " C_LOCAL_VARARG_RET ";\n");
+ }
}
} else {
p_output.append("\t" CS_PARAM_METHODBIND "->ptrcall(" CS_PARAM_INSTANCE ", ");
@@ -3170,7 +3177,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
if (bindings_generator.generate_glue(glue_dir_path) != OK)
ERR_PRINTS(generate_all_glue_option + ": Failed to generate the C++ glue.");
- if (bindings_generator.generate_cs_api(glue_dir_path.plus_file("Managed/Generated")) != OK)
+ if (bindings_generator.generate_cs_api(glue_dir_path.plus_file(API_SOLUTION_NAME)) != OK)
ERR_PRINTS(generate_all_glue_option + ": Failed to generate the C# API.");
}
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index 07918a2d03..d3a8937313 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -635,8 +635,8 @@ class BindingsGenerator {
void _initialize();
public:
- Error generate_cs_core_project(const String &p_proj_dir, Vector<String> &r_compile_files);
- Error generate_cs_editor_project(const String &p_proj_dir, Vector<String> &r_compile_items);
+ Error generate_cs_core_project(const String &p_proj_dir);
+ Error generate_cs_editor_project(const String &p_proj_dir);
Error generate_cs_api(const String &p_output_dir);
Error generate_glue(const String &p_output_dir);
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index 748447005f..872f45ba91 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -44,54 +44,6 @@
namespace CSharpProject {
-bool generate_api_solution_impl(const String &p_solution_dir, const String &p_core_proj_dir, const Vector<String> &p_core_compile_items,
- const String &p_editor_proj_dir, const Vector<String> &p_editor_compile_items,
- GDMonoAssembly *p_tools_project_editor_assembly) {
-
- GDMonoClass *klass = p_tools_project_editor_assembly->get_class("GodotTools.ProjectEditor", "ApiSolutionGenerator");
-
- Variant solution_dir = p_solution_dir;
- Variant core_proj_dir = p_core_proj_dir;
- Variant core_compile_items = p_core_compile_items;
- Variant editor_proj_dir = p_editor_proj_dir;
- Variant editor_compile_items = p_editor_compile_items;
- const Variant *args[5] = { &solution_dir, &core_proj_dir, &core_compile_items, &editor_proj_dir, &editor_compile_items };
- MonoException *exc = NULL;
- klass->get_method("GenerateApiSolution", 5)->invoke(NULL, args, &exc);
-
- if (exc) {
- GDMonoUtils::debug_print_unhandled_exception(exc);
- ERR_FAIL_V(false);
- }
-
- return true;
-}
-
-bool generate_api_solution(const String &p_solution_dir, const String &p_core_proj_dir, const Vector<String> &p_core_compile_items,
- const String &p_editor_proj_dir, const Vector<String> &p_editor_compile_items) {
-
- if (GDMono::get_singleton()->get_tools_project_editor_assembly()) {
- return generate_api_solution_impl(p_solution_dir, p_core_proj_dir, p_core_compile_items,
- p_editor_proj_dir, p_editor_compile_items,
- GDMono::get_singleton()->get_tools_project_editor_assembly());
- } else {
- MonoDomain *temp_domain = GDMonoUtils::create_domain("GodotEngine.Domain.ApiSolutionGeneration");
- CRASH_COND(temp_domain == NULL);
- _GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(temp_domain);
-
- _GDMONO_SCOPE_DOMAIN_(temp_domain);
-
- GDMonoAssembly *tools_project_editor_asm = NULL;
-
- bool assembly_loaded = GDMono::get_singleton()->load_assembly(TOOLS_PROJECT_EDITOR_ASM_NAME, &tools_project_editor_asm);
- ERR_FAIL_COND_V_MSG(!assembly_loaded, false, "Failed to load assembly: '" TOOLS_PROJECT_EDITOR_ASM_NAME "'.");
-
- return generate_api_solution_impl(p_solution_dir, p_core_proj_dir, p_core_compile_items,
- p_editor_proj_dir, p_editor_compile_items,
- tools_project_editor_asm);
- }
-}
-
void add_item(const String &p_project_path, const String &p_item_type, const String &p_include) {
if (!GLOBAL_DEF("mono/project/auto_update_project", true))
diff --git a/modules/mono/editor/csharp_project.h b/modules/mono/editor/csharp_project.h
index b42762cea2..515b8d3d62 100644
--- a/modules/mono/editor/csharp_project.h
+++ b/modules/mono/editor/csharp_project.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,9 +35,6 @@
namespace CSharpProject {
-bool generate_api_solution(const String &p_solution_dir, const String &p_core_proj_dir, const Vector<String> &p_core_compile_items,
- const String &p_editor_proj_dir, const Vector<String> &p_editor_compile_items);
-
void add_item(const String &p_project_path, const String &p_item_type, const String &p_include);
} // namespace CSharpProject
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index 4055ec005a..cfc869cd39 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,9 +30,14 @@
#include "editor_internal_calls.h"
+#ifdef UNIX_ENABLED
+#include <unistd.h> // access
+#endif
+
#include "core/os/os.h"
#include "core/version.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor/script_editor_debugger.h"
#include "main/main.h"
@@ -219,15 +224,14 @@ int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObje
return err;
}
-uint32_t godot_icall_ExportPlugin_GetExportedAssemblyDependencies(MonoString *p_project_dll_name, MonoString *p_project_dll_src_path,
+uint32_t godot_icall_ExportPlugin_GetExportedAssemblyDependencies(MonoObject *p_initial_dependencies,
MonoString *p_build_config, MonoString *p_custom_bcl_dir, MonoObject *r_dependencies) {
- String project_dll_name = GDMonoMarshal::mono_string_to_godot(p_project_dll_name);
- String project_dll_src_path = GDMonoMarshal::mono_string_to_godot(p_project_dll_src_path);
+ Dictionary initial_dependencies = GDMonoMarshal::mono_object_to_variant(p_initial_dependencies);
String build_config = GDMonoMarshal::mono_string_to_godot(p_build_config);
String custom_bcl_dir = GDMonoMarshal::mono_string_to_godot(p_custom_bcl_dir);
Dictionary dependencies = GDMonoMarshal::mono_object_to_variant(r_dependencies);
- return GodotSharpExport::get_exported_assembly_dependencies(project_dll_name, project_dll_src_path, build_config, custom_bcl_dir, dependencies);
+ return GodotSharpExport::get_exported_assembly_dependencies(initial_dependencies, build_config, custom_bcl_dir, dependencies);
}
MonoString *godot_icall_Internal_UpdateApiAssembliesFromPrebuilt(MonoString *p_config) {
@@ -371,6 +375,15 @@ MonoString *godot_icall_Utils_OS_GetPlatformName() {
return GDMonoMarshal::mono_string_from_godot(os_name);
}
+MonoBoolean godot_icall_Utils_OS_UnixFileHasExecutableAccess(MonoString *p_file_path) {
+#ifdef UNIX_ENABLED
+ String file_path = GDMonoMarshal::mono_string_to_godot(p_file_path);
+ return access(file_path.utf8().get_data(), X_OK) == 0;
+#else
+ ERR_FAIL_V(false);
+#endif
+}
+
void register_editor_internal_calls() {
// GodotSharpDirs
@@ -443,4 +456,5 @@ void register_editor_internal_calls() {
// Utils.OS
mono_add_internal_call("GodotTools.Utils.OS::GetPlatformName", (void *)godot_icall_Utils_OS_GetPlatformName);
+ mono_add_internal_call("GodotTools.Utils.OS::UnixFileHasExecutableAccess", (void *)godot_icall_Utils_OS_UnixFileHasExecutableAccess);
}
diff --git a/modules/mono/editor/editor_internal_calls.h b/modules/mono/editor/editor_internal_calls.h
index 1682da66e5..ef4e639161 100644
--- a/modules/mono/editor/editor_internal_calls.h
+++ b/modules/mono/editor/editor_internal_calls.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp
index 9ae9399e1d..ce0b6ad0e6 100644
--- a/modules/mono/editor/godotsharp_export.cpp
+++ b/modules/mono/editor/godotsharp_export.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -101,23 +101,32 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String>
return OK;
}
-Error get_exported_assembly_dependencies(const String &p_project_dll_name, const String &p_project_dll_src_path, const String &p_build_config, const String &p_custom_bcl_dir, Dictionary &r_dependencies) {
+Error get_exported_assembly_dependencies(const Dictionary &p_initial_dependencies,
+ const String &p_build_config, const String &p_custom_bcl_dir, Dictionary &r_dependencies) {
MonoDomain *export_domain = GDMonoUtils::create_domain("GodotEngine.Domain.ProjectExport");
ERR_FAIL_NULL_V(export_domain, FAILED);
_GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(export_domain);
_GDMONO_SCOPE_DOMAIN_(export_domain);
- GDMonoAssembly *scripts_assembly = NULL;
- bool load_success = GDMono::get_singleton()->load_assembly_from(p_project_dll_name,
- p_project_dll_src_path, &scripts_assembly, /* refonly: */ true);
-
- ERR_FAIL_COND_V_MSG(!load_success, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + p_project_dll_name + "'.");
-
Vector<String> search_dirs;
GDMonoAssembly::fill_search_dirs(search_dirs, p_build_config, p_custom_bcl_dir);
- return get_assembly_dependencies(scripts_assembly, search_dirs, r_dependencies);
+ for (const Variant *key = p_initial_dependencies.next(); key; key = p_initial_dependencies.next(key)) {
+ String assembly_name = *key;
+ String assembly_path = p_initial_dependencies[*key];
+
+ GDMonoAssembly *assembly = NULL;
+ bool load_success = GDMono::get_singleton()->load_assembly_from(assembly_name, assembly_path, &assembly, /* refonly: */ true);
+
+ ERR_FAIL_COND_V_MSG(!load_success, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + assembly_name + "'.");
+
+ Error err = get_assembly_dependencies(assembly, search_dirs, r_dependencies);
+ if (err != OK)
+ return err;
+ }
+
+ return OK;
}
} // namespace GodotSharpExport
diff --git a/modules/mono/editor/godotsharp_export.h b/modules/mono/editor/godotsharp_export.h
index 58e46e2f2d..36138f81b7 100644
--- a/modules/mono/editor/godotsharp_export.h
+++ b/modules/mono/editor/godotsharp_export.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,9 +41,8 @@ namespace GodotSharpExport {
Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_dependencies);
-Error get_exported_assembly_dependencies(const String &p_project_dll_name,
- const String &p_project_dll_src_path, const String &p_build_config,
- const String &p_custom_lib_dir, Dictionary &r_dependencies);
+Error get_exported_assembly_dependencies(const Dictionary &p_initial_dependencies,
+ const String &p_build_config, const String &p_custom_lib_dir, Dictionary &r_dependencies);
} // namespace GodotSharpExport
diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp
index dcb0ca5a80..c400479b89 100644
--- a/modules/mono/editor/script_class_parser.cpp
+++ b/modules/mono/editor/script_class_parser.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -501,12 +501,15 @@ Error ScriptClassParser::parse(const String &p_code) {
int type_curly_stack = 0;
while (!error && tk != TK_EOF) {
- if (tk == TK_IDENTIFIER && String(value) == "class") {
+ String identifier = value;
+ if (tk == TK_IDENTIFIER && (identifier == "class" || identifier == "struct")) {
+ bool is_class = identifier == "class";
+
tk = get_token();
if (tk == TK_IDENTIFIER) {
String name = value;
- int at_level = type_curly_stack;
+ int at_level = curly_stack;
ClassDecl class_decl;
@@ -568,48 +571,22 @@ Error ScriptClassParser::parse(const String &p_code) {
NameDecl name_decl;
name_decl.name = name;
- name_decl.type = NameDecl::CLASS_DECL;
+ name_decl.type = is_class ? NameDecl::CLASS_DECL : NameDecl::STRUCT_DECL;
name_stack[at_level] = name_decl;
- if (!generic) { // no generics, thanks
- classes.push_back(class_decl);
- } else if (OS::get_singleton()->is_stdout_verbose()) {
- String full_name = class_decl.namespace_;
- if (full_name.length())
- full_name += ".";
- full_name += class_decl.name;
- OS::get_singleton()->print("Ignoring generic class declaration: %s\n", class_decl.name.utf8().get_data());
- }
- }
- } else if (tk == TK_IDENTIFIER && String(value) == "struct") {
- String name;
- int at_level = type_curly_stack;
- while (true) {
- tk = get_token();
- if (tk == TK_IDENTIFIER && name.empty()) {
- name = String(value);
- } else if (tk == TK_CURLY_BRACKET_OPEN) {
- if (name.empty()) {
- error_str = "Expected " + get_token_name(TK_IDENTIFIER) + " after keyword 'struct', found " + get_token_name(TK_CURLY_BRACKET_OPEN);
- error = true;
- return ERR_PARSE_ERROR;
+ if (is_class) {
+ if (!generic) { // no generics, thanks
+ classes.push_back(class_decl);
+ } else if (OS::get_singleton()->is_stdout_verbose()) {
+ String full_name = class_decl.namespace_;
+ if (full_name.length())
+ full_name += ".";
+ full_name += class_decl.name;
+ OS::get_singleton()->print("Ignoring generic class declaration: %s\n", full_name.utf8().get_data());
}
-
- curly_stack++;
- type_curly_stack++;
- break;
- } else if (tk == TK_EOF) {
- error_str = "Expected " + get_token_name(TK_CURLY_BRACKET_OPEN) + " after struct decl, found " + get_token_name(TK_EOF);
- error = true;
- return ERR_PARSE_ERROR;
}
}
-
- NameDecl name_decl;
- name_decl.name = name;
- name_decl.type = NameDecl::STRUCT_DECL;
- name_stack[at_level] = name_decl;
- } else if (tk == TK_IDENTIFIER && String(value) == "namespace") {
+ } else if (tk == TK_IDENTIFIER && identifier == "namespace") {
if (type_curly_stack > 0) {
error_str = "Found namespace nested inside type.";
error = true;
diff --git a/modules/mono/editor/script_class_parser.h b/modules/mono/editor/script_class_parser.h
index 39003336ac..a76a3a50a9 100644
--- a/modules/mono/editor/script_class_parser.h
+++ b/modules/mono/editor/script_class_parser.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */