diff options
Diffstat (limited to 'modules/mono/editor')
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs | 47 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs | 2 | ||||
-rw-r--r-- | modules/mono/editor/editor_internal_calls.cpp | 7 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_export.cpp | 25 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_export.h | 5 |
5 files changed, 67 insertions, 19 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index aed25f5ac5..b9b2b0fded 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -125,12 +125,20 @@ 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)) @@ -579,6 +587,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; @@ -590,18 +604,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: @@ -627,7 +668,7 @@ namespace GodotTools.Export } [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/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index 1a8c26acd7..e89ea0c476 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -65,7 +65,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; diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 4055ec005a..443b4ba841 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -219,15 +219,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) { diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp index 9ae9399e1d..e02bd3be58 100644 --- a/modules/mono/editor/godotsharp_export.cpp +++ b/modules/mono/editor/godotsharp_export.cpp @@ -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..8eb5a4d9dc 100644 --- a/modules/mono/editor/godotsharp_export.h +++ b/modules/mono/editor/godotsharp_export.h @@ -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 |