Skip to content

Commit

Permalink
[XABT] Use a response file for D8 task.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Nov 22, 2024
1 parent 78f8863 commit 1a891ab
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions src/Xamarin.Android.Build.Tasks/Tasks/D8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using Xamarin.Android.Tools;
using Microsoft.Android.Build.Tasks;
using System.Text;

namespace Xamarin.Android.Tasks
{
Expand Down Expand Up @@ -47,6 +48,44 @@ protected override string GenerateCommandLineCommands ()
return GetCommandLineBuilder ().ToString ();
}

protected override string GenerateResponseFileCommands ()
{
var cmd = new CommandLineBuilder ();

var injars = new List<string> ();
var libjars = new List<string> ();
if (AlternativeJarLibrariesToEmbed?.Length > 0) {
Log.LogDebugMessage (" processing AlternativeJarLibrariesToEmbed...");
foreach (var jar in AlternativeJarLibrariesToEmbed) {
injars.Add (jar.ItemSpec);
}
} else if (JavaLibrariesToEmbed != null) {
Log.LogDebugMessage (" processing ClassesZip, JavaLibrariesToEmbed...");
if (!string.IsNullOrEmpty (ClassesZip) && File.Exists (ClassesZip)) {
injars.Add (ClassesZip);
}
foreach (var jar in JavaLibrariesToEmbed) {
injars.Add (jar.ItemSpec);
}
}
libjars.Add (JavaPlatformJarPath);
if (JavaLibrariesToReference != null) {
foreach (var jar in JavaLibrariesToReference) {
libjars.Add (jar.ItemSpec);
}
}

//foreach (var jar in libjars)
// cmd.AppendSwitchIfNotNull ("--lib ", jar);

foreach (var jar in injars)
cmd.AppendFileNameIfNotNull (jar);

return cmd.ToString ();
}

protected override Encoding ResponseFileEncoding => Encoding.UTF8;

protected virtual string MainClass => "com.android.tools.r8.D8";

protected int MinSdkVersion { get; set; }
Expand Down Expand Up @@ -81,6 +120,8 @@ protected virtual CommandLineBuilder GetCommandLineBuilder ()
if (!EnableDesugar)
cmd.AppendSwitch ("--no-desugaring");

cmd.AppendSwitchIfNotNull ("--output ", OutputDirectory);

var injars = new List<string> ();
var libjars = new List<string> ();
if (AlternativeJarLibrariesToEmbed?.Length > 0) {
Expand All @@ -104,11 +145,12 @@ protected virtual CommandLineBuilder GetCommandLineBuilder ()
}
}

cmd.AppendSwitchIfNotNull ("--output ", OutputDirectory);
foreach (var jar in libjars)
cmd.AppendSwitchIfNotNull ("--lib ", jar);
foreach (var jar in injars)
cmd.AppendFileNameIfNotNull (jar);

//foreach (var jar in injars)
// cmd.AppendFileNameIfNotNull (jar);


if (MapDiagnostics != null) {
foreach (var diagnostic in MapDiagnostics) {
Expand Down

0 comments on commit 1a891ab

Please sign in to comment.