summaryrefslogtreecommitdiff
path: root/modules/mono
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono')
-rw-r--r--modules/mono/build_scripts/mono_configure.py11
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs14
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs8
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp14
-rw-r--r--modules/mono/glue/Managed/Files/StringExtensions.cs38
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp28
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp10
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp2
9 files changed, 66 insertions, 63 deletions
diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py
index 89d56def7d..033c467da9 100644
--- a/modules/mono/build_scripts/mono_configure.py
+++ b/modules/mono/build_scripts/mono_configure.py
@@ -446,18 +446,19 @@ def copy_mono_shared_libs(env, mono_root, target_mono_root_dir):
if not os.path.isdir(target_mono_lib_dir):
os.makedirs(target_mono_lib_dir)
+ lib_file_names = []
if platform == 'osx':
- # TODO: Make sure nothing is missing
- copy(os.path.join(mono_root, 'lib', 'libMonoPosixHelper.dylib'), target_mono_lib_dir)
+ lib_file_names = [lib_name + '.dylib' for lib_name in [
+ 'libmono-btls-shared', 'libmono-native-compat', 'libMonoPosixHelper'
+ ]]
elif is_unix_like(platform):
lib_file_names = [lib_name + '.so' for lib_name in [
'libmono-btls-shared', 'libmono-ee-interp', 'libmono-native', 'libMonoPosixHelper',
'libmono-profiler-aot', 'libmono-profiler-coverage', 'libmono-profiler-log', 'libMonoSupportW'
]]
- for lib_file_name in lib_file_names:
- copy_if_exists(os.path.join(mono_root, 'lib', lib_file_name), target_mono_lib_dir)
-
+ for lib_file_name in lib_file_names:
+ copy_if_exists(os.path.join(mono_root, 'lib', lib_file_name), target_mono_lib_dir)
def pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext):
tmpenv = Environment()
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
index b17a3f4491..96cafba87f 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
@@ -39,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)
@@ -78,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.
}
@@ -513,7 +519,7 @@ namespace GodotTools.Export
case OS.Platforms.HTML5:
return "wasm-wasm32";
default:
- throw new NotSupportedException();
+ throw new NotSupportedException($"Platform not supported: {platform}");
}
}
@@ -655,7 +661,7 @@ namespace GodotTools.Export
case OS.Platforms.HTML5:
return "wasm";
default:
- throw new NotSupportedException();
+ throw new NotSupportedException($"Platform not supported: {platform}");
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
index dbd774a66a..15b9e50a8d 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
@@ -34,7 +34,6 @@
<HintPath>..\packages\JetBrains.Annotations.2019.1.3\lib\net20\JetBrains.Annotations.dll</HintPath>
<Private>True</Private>
</Reference>
- <Reference Include="Mono.Posix" />
<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>
@@ -100,8 +99,5 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
- <ItemGroup>
- <Content Include="Ides\Rider\.editorconfig" />
- </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
index 5a867b7f8b..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";
@@ -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
@@ -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)
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index 443b4ba841..48a3259a90 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -30,6 +30,10 @@
#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"
@@ -370,6 +374,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
@@ -442,4 +455,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/glue/Managed/Files/StringExtensions.cs b/modules/mono/glue/Managed/Files/StringExtensions.cs
index 079e9912d6..b926037e5a 100644
--- a/modules/mono/glue/Managed/Files/StringExtensions.cs
+++ b/modules/mono/glue/Managed/Files/StringExtensions.cs
@@ -18,7 +18,7 @@ namespace Godot
int pos = 0;
int slices = 1;
- while ((pos = instance.Find(splitter, true, pos)) >= 0)
+ while ((pos = instance.Find(splitter, pos, caseSensitive: true)) >= 0)
{
slices++;
pos += splitter.Length;
@@ -229,7 +229,7 @@ namespace Godot
// </summary>
public static int CasecmpTo(this string instance, string to)
{
- return instance.CompareTo(to, true);
+ return instance.CompareTo(to, caseSensitive: true);
}
// <summary>
@@ -322,25 +322,29 @@ namespace Godot
return instance.Substring(pos + 1);
}
- // <summary>
- // Find the first occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
- // </summary>
- public static int Find(this string instance, string what, bool caseSensitive = true, int from = 0)
+ /// <summary>Find the first occurrence of a substring. Optionally, the search starting position can be passed.</summary>
+ /// <returns>The starting position of the substring, or -1 if not found.</returns>
+ public static int Find(this string instance, string what, int from = 0, bool caseSensitive = true)
{
return instance.IndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
}
- // <summary>
- // Find the last occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
- // </summary>
- public static int FindLast(this string instance, string what, bool caseSensitive = true, int from = 0)
+ /// <summary>Find the last occurrence of a substring.</summary>
+ /// <returns>The starting position of the substring, or -1 if not found.</returns>
+ public static int FindLast(this string instance, string what, bool caseSensitive = true)
+ {
+ return instance.FindLast(what, instance.Length - 1, caseSensitive);
+ }
+
+ /// <summary>Find the last occurrence of a substring specifying the search starting position.</summary>
+ /// <returns>The starting position of the substring, or -1 if not found.</returns>
+ public static int FindLast(this string instance, string what, int from, bool caseSensitive = true)
{
return instance.LastIndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
}
- // <summary>
- // Find the first occurrence of a substring but search as case-insensitive, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
- // </summary>
+ /// <summary>Find the first occurrence of a substring but search as case-insensitive. Optionally, the search starting position can be passed.</summary>
+ /// <returns>The starting position of the substring, or -1 if not found.</returns>
public static int FindN(this string instance, string what, int from = 0)
{
return instance.IndexOf(what, from, StringComparison.OrdinalIgnoreCase);
@@ -502,7 +506,7 @@ namespace Godot
// </summary>
public static bool IsSubsequenceOfI(this string instance, string text)
{
- return instance.IsSubsequenceOf(text, false);
+ return instance.IsSubsequenceOf(text, caseSensitive: false);
}
// <summary>
@@ -662,7 +666,7 @@ namespace Godot
// </summary>
public static bool MatchN(this string instance, string expr)
{
- return instance.ExprMatch(expr, false);
+ return instance.ExprMatch(expr, caseSensitive: false);
}
// <summary>
@@ -692,7 +696,7 @@ namespace Godot
// </summary>
public static int NocasecmpTo(this string instance, string to)
{
- return instance.CompareTo(to, false);
+ return instance.CompareTo(to, caseSensitive: false);
}
// <summary>
@@ -928,7 +932,7 @@ namespace Godot
while (true)
{
- int end = instance.Find(divisor, true, from);
+ int end = instance.Find(divisor, from, caseSensitive: true);
if (end < 0)
end = len;
if (allowEmpty || end > from)
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 29274be559..6cafa6709f 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -119,28 +119,6 @@ void gd_mono_profiler_init() {
#if defined(DEBUG_ENABLED)
-bool gd_mono_wait_for_debugger_msecs(uint32_t p_msecs) {
-
- do {
- if (mono_is_debugger_attached())
- return true;
-
- int last_tick = OS::get_singleton()->get_ticks_msec();
-
- OS::get_singleton()->delay_usec((p_msecs < 25 ? p_msecs : 25) * 1000);
-
- uint32_t tdiff = OS::get_singleton()->get_ticks_msec() - last_tick;
-
- if (tdiff > p_msecs) {
- p_msecs = 0;
- } else {
- p_msecs -= tdiff;
- }
- } while (p_msecs > 0);
-
- return mono_is_debugger_attached();
-}
-
void gd_mono_debug_init() {
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
@@ -402,12 +380,6 @@ void GDMono::initialize() {
Error domain_load_err = _load_scripts_domain();
ERR_FAIL_COND_MSG(domain_load_err != OK, "Mono: Failed to load scripts domain.");
-#if defined(DEBUG_ENABLED) && !defined(JAVASCRIPT_ENABLED)
- bool debugger_attached = gd_mono_wait_for_debugger_msecs(500);
- if (!debugger_attached && OS::get_singleton()->is_stdout_verbose())
- print_error("Mono: Debugger wait timeout");
-#endif
-
_register_internal_calls();
print_verbose("Mono: INITIALIZED");
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index d84359b1ab..56a9bf46a3 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -110,8 +110,14 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
} break;
case MONO_TYPE_STRING: {
- MonoString *mono_string = GDMonoMarshal::mono_string_from_godot(p_value);
- mono_field_set_value(p_object, mono_field, mono_string);
+ if (p_value.get_type() == Variant::NIL) {
+ // Otherwise, Variant -> String would return the string "Null"
+ MonoString *mono_string = NULL;
+ mono_field_set_value(p_object, mono_field, mono_string);
+ } else {
+ MonoString *mono_string = GDMonoMarshal::mono_string_from_godot(p_value);
+ mono_field_set_value(p_object, mono_field, mono_string);
+ }
} break;
case MONO_TYPE_VALUETYPE: {
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index f74fe5715c..9f55b31edc 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -374,6 +374,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
}
case MONO_TYPE_STRING: {
+ if (p_var->get_type() == Variant::NIL)
+ return NULL; // Otherwise, Variant -> String would return the string "Null"
return (MonoObject *)mono_string_from_godot(p_var->operator String());
} break;