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

[msbuild/dotnet] Add support for passing --aot arguments to the AOT compiler. #14936

Merged
merged 1 commit into from
May 10, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@
<AOTCompile
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AotArguments="@(_AotArguments)"
Assemblies="@(_AssembliesToAOT)"
AOTCompilerPath="$(_AOTCompiler)"
InputDirectory="$(_AOTInputDirectory)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Xamarin.MacDev.Tasks {
public abstract class AOTCompileTaskBase : XamarinTask {
public ITaskItem [] AotArguments { get; set; } = Array.Empty<ITaskItem> ();

[Required]
public string AOTCompilerPath { get; set; } = string.Empty;

Expand Down Expand Up @@ -71,6 +73,7 @@ public override bool Execute ()
{ "MONO_PATH", Path.GetFullPath (InputDirectory) },
};

var globalAotArguments = AotArguments?.Select (v => v.ItemSpec).ToList ();
for (var i = 0; i < Assemblies.Length; i++) {
var asm = Assemblies [i];
var input = inputs [i];
Expand All @@ -95,6 +98,8 @@ public override bool Execute ()
return false;
}
arguments.Add ($"{string.Join (",", parsedArguments)}");
if (globalAotArguments is not null)
arguments.Add ($"--aot={string.Join (",", globalAotArguments)}");
arguments.AddRange (parsedProcessArguments);
arguments.Add (input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Xamarin.MacDev.Tasks {
public abstract class ParseBundlerArgumentsTaskBase : XamarinTask {
public string ExtraArgs { get; set; }

[Output]
public ITaskItem [] Aot { get; set; }

[Output]
public ITaskItem [] DlSym { get; set; }

Expand Down Expand Up @@ -65,6 +68,7 @@ public override bool Execute ()
var args = CommandLineArgumentBuilder.Parse (ExtraArgs);
List<string> xml = null;
List<string> customLinkFlags = null;
var aot = new List<ITaskItem> ();
var envVariables = new List<ITaskItem> ();
var dlsyms = new List<ITaskItem> ();

Expand Down Expand Up @@ -100,6 +104,9 @@ public override bool Execute ()
}

switch (name) {
case "aot":
aot.Add (new TaskItem (value));
break;
case "nosymbolstrip":
// There's also a version that takes symbols as arguments:
// --nosymbolstrip:symbol1,symbol2
Expand Down Expand Up @@ -207,6 +214,12 @@ public override bool Execute ()
dlsyms.AddRange (DlSym);
DlSym = dlsyms.ToArray ();
}

if (aot.Count > 0) {
if (Aot is not null)
aot.AddRange (Aot);
Aot = aot.ToArray ();
}
}

return !Log.HasLoggedErrors;
Expand Down
2 changes: 2 additions & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1763,12 +1763,14 @@ Copyright (C) 2018 Microsoft. All rights reserved.

<Target Name="_ParseBundlerArguments">
<ParseBundlerArguments
Aot="@(_AotArguments)"
ExtraArgs="$(_BundlerArguments)"
NoSymbolStrip="$(NoSymbolStrip)"
NoDSymUtil="$(NoDSymUtil)"
PackageDebugSymbols="$(PackageDebugSymbols)"
Verbosity="$(_BundlerVerbosity)"
>
<Output TaskParameter="Aot" ItemName="_AotArguments" />
<Output TaskParameter="CustomBundleName" PropertyName="_CustomBundleName" />
<Output TaskParameter="CustomLinkFlags" ItemName="_CustomLinkFlags" />
<Output TaskParameter="DlSym" ItemName="_BundlerDlsym" />
Expand Down