From cea77d0b48523425b92c1d0fb1fcd53ced693456 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Wed, 4 Oct 2023 04:31:44 +0200 Subject: [PATCH] C#: Add checks to Android export - Add .NET 7.0 TFM when the platform is Anroid to the created csproj. - Prevent exporting to Android when the architecture is not supported. --- .../GodotTools.ProjectEditor/ProjectGenerator.cs | 6 +++++- .../GodotTools/GodotTools/Export/ExportPlugin.cs | 2 +- platform/android/export/export_plugin.cpp | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs index 1e5d7c901ee5..04ea46e9ef3b 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs @@ -23,11 +23,15 @@ namespace GodotTools.ProjectEditor var mainGroup = root.AddPropertyGroup(); mainGroup.AddProperty("TargetFramework", "net6.0"); - mainGroup.AddProperty("EnableDynamicLoading", "true"); + + var net7 = mainGroup.AddProperty("TargetFramework", "net7.0"); + net7.Condition = " '$(GodotTargetPlatform)' == 'android' "; var net8 = mainGroup.AddProperty("TargetFramework", "net8.0"); net8.Condition = " '$(GodotTargetPlatform)' == 'ios' "; + mainGroup.AddProperty("EnableDynamicLoading", "true"); + string sanitizedName = IdentifierUtils.SanitizeQualifiedIdentifier(name, allowEmptyIdentifiers: true); // If the name is not a valid namespace, manually set RootNamespace to a sanitized one. diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index 595c9a126841..018298cb3362 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -187,7 +187,7 @@ namespace GodotTools.Export List outputPaths = new(); - bool embedBuildResults = (bool)GetOption("dotnet/embed_build_outputs") || features.Contains("android"); + bool embedBuildResults = (bool)GetOption("dotnet/embed_build_outputs") || platform == OS.Platforms.Android; foreach (PublishConfig config in targets) { diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index aeaa7b9ce705..c3015ec260a2 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -2238,6 +2238,19 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref enabled_abis = get_enabled_abis(p_preset); + for (ABI abi : enabled_abis) { + if (abi.arch != "arm64" && abi.arch != "x86_64") { + err += vformat(TTR("Android architecture %s not supported in C# projects."), abi.arch) + "\n"; + unsupported_arch = true; + } + } + if (unsupported_arch) { + r_error = err; + return false; + } #endif // Look for export templates (first official, and if defined custom templates).