summaryrefslogtreecommitdiffstats
path: root/modules/mono/mono_gd/gd_mono.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/mono_gd/gd_mono.cpp')
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 247968e251..3eb746677d 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -322,7 +322,7 @@ godot_plugins_initialize_fn try_load_native_aot_library(void *&r_aot_dll_handle)
#if defined(WINDOWS_ENABLED)
String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".dll");
-#elif defined(MACOS_ENABLED)
+#elif defined(MACOS_ENABLED) || defined(IOS_ENABLED)
String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".dylib");
#elif defined(UNIX_ENABLED)
String native_aot_so_path = GodotSharpDirs::get_api_assemblies_dir().path_join(assembly_name + ".so");
@@ -330,28 +330,33 @@ godot_plugins_initialize_fn try_load_native_aot_library(void *&r_aot_dll_handle)
#error "Platform not supported (yet?)"
#endif
- if (FileAccess::exists(native_aot_so_path)) {
- Error err = OS::get_singleton()->open_dynamic_library(native_aot_so_path, r_aot_dll_handle);
-
- if (err != OK) {
- return nullptr;
- }
+ Error err = OS::get_singleton()->open_dynamic_library(native_aot_so_path, r_aot_dll_handle);
- void *lib = r_aot_dll_handle;
+ if (err != OK) {
+ return nullptr;
+ }
- void *symbol = nullptr;
+ void *lib = r_aot_dll_handle;
- err = OS::get_singleton()->get_dynamic_library_symbol_handle(lib, "godotsharp_game_main_init", symbol);
- ERR_FAIL_COND_V(err != OK, nullptr);
- return (godot_plugins_initialize_fn)symbol;
- }
+ void *symbol = nullptr;
- return nullptr;
+ err = OS::get_singleton()->get_dynamic_library_symbol_handle(lib, "godotsharp_game_main_init", symbol);
+ ERR_FAIL_COND_V(err != OK, nullptr);
+ return (godot_plugins_initialize_fn)symbol;
}
#endif
} // namespace
+bool GDMono::should_initialize() {
+#ifdef TOOLS_ENABLED
+ // The editor always needs to initialize the .NET module for now.
+ return true;
+#else
+ return OS::get_singleton()->has_feature("dotnet");
+#endif
+}
+
static bool _on_core_api_assembly_loaded() {
if (!GDMonoCache::godot_api_cache_updated) {
return false;
@@ -376,11 +381,13 @@ void GDMono::initialize() {
godot_plugins_initialize_fn godot_plugins_initialize = nullptr;
+#if !defined(IOS_ENABLED)
// Check that the .NET assemblies directory exists before trying to use it.
if (!DirAccess::exists(GodotSharpDirs::get_api_assemblies_dir())) {
OS::get_singleton()->alert(vformat(RTR("Unable to find the .NET assemblies directory.\nMake sure the '%s' directory exists and contains the .NET assemblies."), GodotSharpDirs::get_api_assemblies_dir()), RTR(".NET assemblies not found"));
ERR_FAIL_MSG(".NET: Assemblies not found");
}
+#endif
if (!load_hostfxr(hostfxr_dll_handle)) {
#if !defined(TOOLS_ENABLED)
@@ -437,11 +444,15 @@ void GDMono::initialize() {
_on_core_api_assembly_loaded();
+#ifdef TOOLS_ENABLED
+ _try_load_project_assembly();
+#endif
+
initialized = true;
}
#ifdef TOOLS_ENABLED
-void GDMono::initialize_load_assemblies() {
+void GDMono::_try_load_project_assembly() {
if (Engine::get_singleton()->is_project_manager_hint()) {
return;
}
@@ -545,12 +556,6 @@ GDMono::GDMono() {
GDMono::~GDMono() {
finalizing_scripts_domain = true;
- if (is_runtime_initialized()) {
- if (GDMonoCache::godot_api_cache_updated) {
- GDMonoCache::managed_callbacks.DisposablesTracker_OnGodotShuttingDown();
- }
- }
-
if (hostfxr_dll_handle) {
OS::get_singleton()->close_dynamic_library(hostfxr_dll_handle);
}