fix android mono export causing conflicts

This commit is contained in:
Travis Lange 2024-10-12 15:03:54 -04:00
parent 842f982397
commit 4217a10f4f

View File

@ -216,6 +216,8 @@ namespace GodotTools.Export
bool embedBuildResults = ((bool)GetOption("dotnet/embed_build_outputs") || platform == OS.Platforms.Android) && platform != OS.Platforms.MacOS;
var exportedJars = new HashSet<string>();
foreach (PublishConfig config in targets)
{
string ridOS = config.RidOS;
@ -323,8 +325,27 @@ namespace GodotTools.Export
{
if (platform == OS.Platforms.Android)
{
if (IsSharedObject(Path.GetFileName(path)))
var fileName = Path.GetFileName(path);
if (IsSharedObject(fileName))
{
if (fileName.EndsWith(".jar"))
{
// Don't export the same dotnet jar twice. Otherwise we will have conflicts. This
// can happen when exporting for multiple architectures. The jars exported from
// godot for dotnet can be found in .godot/mono/temp/bin/Export[Debug|Release].
// If you compare the bytecode with AndroidStudio or IntelliJ, you will find that
// they are identical. Hence why we can only export one.
//
// Gradle does not distinguish jars between abi folders like it does with .so files. It will
// try to compile both into the application if they are both exported.
if (exportedJars.Contains(fileName))
{
return;
}
exportedJars.Add(fileName);
}
AddSharedObject(path, tags: new string[] { arch },
Path.Join(projectDataDirName,
Path.GetRelativePath(publishOutputDir,