-
Notifications
You must be signed in to change notification settings - Fork 564
[One .NET] rework .NET 6 AOT support #6562
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,13 +51,24 @@ public abstract class GetAotArguments : AndroidAsyncTask | |
|
|
||
| public ITaskItem [] Profiles { get; set; } = Array.Empty<ITaskItem> (); | ||
|
|
||
| public bool UsingAndroidNETSdk { get; set; } | ||
|
|
||
| public string AotAdditionalArguments { get; set; } = ""; | ||
|
|
||
| [Required, Output] | ||
| public ITaskItem [] ResolvedAssemblies { get; set; } = Array.Empty<ITaskItem> (); | ||
|
|
||
| [Output] | ||
| public string? Triple { get; set; } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming suggestion:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neither The We could use a different name, but is that worse? We'd still be using |
||
|
|
||
| [Output] | ||
| public string? ToolPrefix { get; set; } | ||
|
|
||
| [Output] | ||
| public string? MsymPath { get; set; } | ||
|
|
||
| [Output] | ||
| public string? LdName { get; set; } | ||
|
|
||
| [Output] | ||
| public string? LdFlags { get; set; } | ||
|
|
||
| protected AotMode AotMode; | ||
| protected SequencePointsMode SequencePointsMode; | ||
| protected string SdkBinDirectory = ""; | ||
|
|
@@ -208,22 +219,12 @@ int GetNdkApiLevel (NdkTools ndk, AndroidTargetArch arch) | |
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns a list of parameters to pass to the --aot switch | ||
| /// Fills [Output] parameters to pass to the --aot switch | ||
| /// </summary> | ||
| protected List<string> GetAotOptions (NdkTools ndk, AndroidTargetArch arch, int level, string outdir, string mtriple, string toolPrefix) | ||
| protected void GetAotOptions (NdkTools ndk, AndroidTargetArch arch, int level, string outdir, string toolPrefix) | ||
| { | ||
| List<string> aotOptions = new List<string> (); | ||
|
|
||
| if (!string.IsNullOrEmpty (AotAdditionalArguments)) | ||
| aotOptions.Add (AotAdditionalArguments); | ||
| if (SequencePointsMode == SequencePointsMode.Offline) | ||
| aotOptions.Add ($"msym-dir={outdir}"); | ||
| if (AotMode != AotMode.Normal) | ||
| aotOptions.Add (AotMode.ToString ().ToLowerInvariant ()); | ||
|
|
||
| aotOptions.Add ("asmwriter"); | ||
| aotOptions.Add ($"mtriple={mtriple}"); | ||
| aotOptions.Add ($"tool-prefix={toolPrefix}"); | ||
| MsymPath = outdir; | ||
|
|
||
| string ldName; | ||
| if (EnableLLVM) { | ||
|
|
@@ -238,16 +239,12 @@ protected List<string> GetAotOptions (NdkTools ndk, AndroidTargetArch arch, int | |
| ldName = "ld"; | ||
| } | ||
| string ldFlags = GetLdFlags (ndk, arch, level, toolPrefix); | ||
|
|
||
| // MUST be before `ld-flags`, otherwise Mono fails to parse it on Windows | ||
| if (!string.IsNullOrEmpty (ldName)) { | ||
| aotOptions.Add ($"ld-name={ldName}"); | ||
| LdName = ldName; | ||
| } | ||
| if (!string.IsNullOrEmpty (ldFlags)) { | ||
| aotOptions.Add ($"ld-flags={ldFlags}"); | ||
| LdFlags = ldFlags; | ||
| } | ||
|
|
||
| return aotOptions; | ||
| } | ||
|
|
||
| string GetLdFlags(NdkTools ndk, AndroidTargetArch arch, int level, string toolPrefix) | ||
|
|
@@ -292,13 +289,7 @@ string GetLdFlags(NdkTools ndk, AndroidTargetArch arch, int level, string toolPr | |
| libs.Add (Path.Combine (androidLibPath, "libc.so")); | ||
| libs.Add (Path.Combine (androidLibPath, "libm.so")); | ||
|
|
||
| if (UsingAndroidNETSdk) { | ||
| // NOTE: in .NET 6+ use space for the delimiter and escape spaces in paths | ||
| var escaped = libs.Select (l => l.Replace (" ", "\\ ")); | ||
| ldFlags = string.Join (" ", escaped); | ||
| } else { | ||
| ldFlags = $"\\\"{string.Join ("\\\";\\\"", libs)}\\\""; | ||
| } | ||
| ldFlags = $"\\\"{string.Join ("\\\";\\\"", libs)}\\\""; | ||
| } | ||
| return ldFlags; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using System; | ||
|
|
||
| namespace Xamarin.ProjectTools | ||
| { | ||
| public static class AbiUtils | ||
| { | ||
| public static string AbiToRuntimeIdentifier (string androidAbi) | ||
| { | ||
| if (androidAbi == "armeabi-v7a") { | ||
| return "android-arm"; | ||
| } else if (androidAbi == "arm64-v8a") { | ||
| return "android-arm64"; | ||
| } else if (androidAbi == "x86") { | ||
| return "android-x86"; | ||
| } else if (androidAbi == "x86_64") { | ||
| return "android-x64"; | ||
| } | ||
| throw new InvalidOperationException ($"Unknown abi: {androidAbi}"); | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.