Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XABT] Use a response file for D8 task. #9546

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading