diff options
-rw-r--r-- | modules/mono/editor/godotsharp_export.cpp | 2 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 23 | ||||
-rw-r--r-- | modules/mono/utils/macros.h | 6 |
3 files changed, 25 insertions, 6 deletions
diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp index 47341e3555..7e2487a6e7 100644 --- a/modules/mono/editor/godotsharp_export.cpp +++ b/modules/mono/editor/godotsharp_export.cpp @@ -124,7 +124,7 @@ void GodotSharpExport::_export_begin(const Set<String> &p_features, bool p_debug ERR_FAIL_COND(!load_success); Vector<String> search_dirs; - GDMonoAssembly::fill_search_dirs(search_dirs); + GDMonoAssembly::fill_search_dirs(search_dirs, build_config); Error depend_error = _get_assembly_dependencies(scripts_assembly, search_dirs, dependencies); ERR_FAIL_COND(depend_error != OK); } diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index ca1ff9f9ff..b45046cb6d 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -253,6 +253,29 @@ void GDMono::initialize() { mono_install_unhandled_exception_hook(&unhandled_exception_hook, NULL); +#ifdef TOOLS_ENABLED + if (!DirAccess::exists("res://.mono")) { + // 'res://.mono/' is missing so there is nothing to load. We don't need to initialize mono, but + // we still do so unless mscorlib is missing (which is the case for projects that don't use C#). + + String mscorlib_fname("mscorlib.dll"); + + Vector<String> search_dirs; + GDMonoAssembly::fill_search_dirs(search_dirs); + + bool found = false; + for (int i = 0; i < search_dirs.size(); i++) { + if (FileAccess::exists(search_dirs[i].plus_file(mscorlib_fname))) { + found = true; + break; + } + } + + if (!found) + return; // mscorlib is missing, do not initialize mono + } +#endif + root_domain = mono_jit_init_version("GodotEngine.RootDomain", "v4.0.30319"); ERR_EXPLAIN("Mono: Failed to initialize runtime"); diff --git a/modules/mono/utils/macros.h b/modules/mono/utils/macros.h index 87295a98f2..e44f254e1c 100644 --- a/modules/mono/utils/macros.h +++ b/modules/mono/utils/macros.h @@ -31,10 +31,6 @@ #ifndef UTIL_MACROS_H #define UTIL_MACROS_H -#ifndef __has_cpp_attribute -#define __has_cpp_attribute(attr_token) 0 -#endif - #define _GD_VARNAME_CONCAT_B_(m_ignore, m_name) m_name #define _GD_VARNAME_CONCAT_A_(m_a, m_b, m_c) _GD_VARNAME_CONCAT_B_(hello there, m_a##m_b##m_c) #define _GD_VARNAME_CONCAT_(m_a, m_b, m_c) _GD_VARNAME_CONCAT_A_(m_a, m_b, m_c) @@ -61,7 +57,7 @@ // noreturn // TODO: Get rid of this macro once we upgrade to C++11 -#if __has_cpp_attribute(deprecated) +#if (__cplusplus >= 201103L) #define GD_NORETURN [[noreturn]] #elif defined(__GNUC__) #define GD_NORETURN __attribute__((noreturn)) |