From 4e49db99f5e58e4fd0f1740b6e87bcc1b9a07df2 Mon Sep 17 00:00:00 2001 From: Justin Sasso Date: Sun, 6 Oct 2024 20:16:01 -0400 Subject: [PATCH] Add linux-bionic RID Export Option Adds an export option to enable the linux-bionic RID so Android can export with NativeAOT enabled. --- .../GodotTools/Export/ExportPlugin.cs | 48 ++++++++++++++++--- .../editor/GodotTools/GodotTools/Utils/OS.cs | 2 +- platform/android/export/export_plugin.cpp | 3 ++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index 6fd84d38349..d75db87a22a 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -37,8 +37,28 @@ namespace GodotTools.Export public override Godot.Collections.Array _GetExportOptions(EditorExportPlatform platform) { - return new Godot.Collections.Array() + var exportOptionList = new Godot.Collections.Array(); + + if (platform.GetOsName().Equals(OS.Platforms.Android, StringComparison.OrdinalIgnoreCase)) { + exportOptionList.Add + ( + new Godot.Collections.Dictionary() + { + { + "option", new Godot.Collections.Dictionary() + { + { "name", "dotnet/android_use_linux_bionic" }, + { "type", (int)Variant.Type.Bool } + } + }, + { "default_value", false } + } + ); + } + + exportOptionList.Add + ( new Godot.Collections.Dictionary() { { @@ -49,7 +69,10 @@ namespace GodotTools.Export } }, { "default_value", false } - }, + } + ); + exportOptionList.Add + ( new Godot.Collections.Dictionary() { { @@ -60,7 +83,10 @@ namespace GodotTools.Export } }, { "default_value", true } - }, + } + ); + exportOptionList.Add + ( new Godot.Collections.Dictionary() { { @@ -72,7 +98,8 @@ namespace GodotTools.Export }, { "default_value", false } } - }; + ); + return exportOptionList; } private void AddExceptionMessage(EditorExportPlatform platform, Exception exception) @@ -158,11 +185,12 @@ namespace GodotTools.Export throw new NotImplementedException("Target platform not yet implemented."); } + bool useAndroidLinuxBionic = (bool)GetOption("dotnet/android_use_linux_bionic"); PublishConfig publishConfig = new() { BuildConfig = isDebug ? "ExportDebug" : "ExportRelease", IncludeDebugSymbols = (bool)GetOption("dotnet/include_debug_symbols"), - RidOS = DetermineRuntimeIdentifierOS(platform), + RidOS = DetermineRuntimeIdentifierOS(platform, useAndroidLinuxBionic), Archs = new List(), UseTempDir = platform != OS.Platforms.iOS, // xcode project links directly to files in the publish dir, so use one that sticks around. BundleOutputs = true, @@ -440,8 +468,14 @@ namespace GodotTools.Export return path; } - private string DetermineRuntimeIdentifierOS(string platform) - => OS.DotNetOSPlatformMap[platform]; + private string DetermineRuntimeIdentifierOS(string platform, bool useAndroidLinuxBionic) + { + if (platform == OS.Platforms.Android && useAndroidLinuxBionic) + { + return OS.DotNetOS.LinuxBionic; + } + return OS.DotNetOSPlatformMap[platform]; + } private string DetermineRuntimeIdentifierArch(string arch) { diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index 355264e4b3b..7487b753e5f 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -55,6 +55,7 @@ namespace GodotTools.Utils public const string Linux = "linux"; public const string Win10 = "win10"; public const string Android = "android"; + public const string LinuxBionic = "linux-bionic"; public const string iOS = "ios"; public const string iOSSimulator = "iossimulator"; public const string Browser = "browser"; @@ -99,7 +100,6 @@ namespace GodotTools.Utils [Platforms.iOS] = DotNetOS.iOS, [Platforms.Web] = DotNetOS.Browser }; - private static bool IsOS(string name) { Internal.godot_icall_Utils_OS_GetPlatformName(out godot_string dest); diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 41f460ca8f3..de36d58e7f0 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1963,6 +1963,9 @@ bool EditorExportPlatformAndroid::get_export_option_visibility(const EditorExpor return false; } + if (p_option == "dotnet/android_use_linux_bionic") { + return advanced_options_enabled; + } return true; }