-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helpful reading: * https://github.com/dotnet/runtime/blob/15dec9a2aa5a4236d6ba70de2e9c146867b9d2e0/src/tasks/AotCompilerTask/MonoAOTCompiler.cs * https://github.com/dotnet/runtime/blob/15dec9a2aa5a4236d6ba70de2e9c146867b9d2e0/src/mono/netcore/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/README.md TODO / limitations: * We only have the osx-x64 host packages * I have not updated the installers yet. The AOT packs are placed in `~/android-toolchain/dotnet` for local testing. * Many other `TODO` comments To make this work, I moved the existing `<Aot/>` MSBuild task calls to a new `_AndroidAot` MSBuild target in `Xamarin.Android.Legacy.targets`. In the .NET 6 targets, there is a *different* `_AndroidAot` MSBuild target that runs the new `<MonoAOTCompiler/>` MSBuild task. In order to acquire the AOT packages, I created a new `mono-aot-compiler.proj` that is invoked such as: <Exec Command="$(DotNetPreviewTool) build @(_GlobalProperties, ' ') "$(MSBuildThisFileDirectory)..\mono-aot-compiler\mono-aot-compiler.proj"" EnvironmentVariables="NUGET_PACKAGES=$(DotNetPreviewPath)packs" /> Setting `$NUGET_PACKAGES` allows us to extract the AOT NuGet packages directly to `dotnet/packs` when this project is restored. Then we conditionally import the Sdk: <Import Project="..\build\Microsoft.NET.Runtime.MonoAOTCompiler.Task.props" Sdk="Microsoft.NET.Runtime.MonoAOTCompiler.Task" Condition=" '$(AotAssemblies)' == 'true' " /> Which allows us to use `$(MonoAOTCompilerTaskAssemblyPath)`: <UsingTask Condition=" '$(AotAssemblies)' == 'true' " TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTaskAssemblyPath)" /> I still need to add the new packs to our installers.
- Loading branch information
1 parent
c677a16
commit 482210f
Showing
7 changed files
with
403 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...marin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!-- | ||
*********************************************************************************************** | ||
Microsoft.Android.Sdk.Aot.targets | ||
.NET 6 AOT support. You can find "legacy" Xamarin.Android AOT support | ||
in Xamarin.Android.Legacy.targets. | ||
For <MonoAOTCompiler/> usage, see: | ||
* https://github.com/dotnet/runtime/blob/15dec9a2aa5a4236d6ba70de2e9c146867b9d2e0/src/tasks/AotCompilerTask/MonoAOTCompiler.cs | ||
* https://github.com/dotnet/runtime/blob/15dec9a2aa5a4236d6ba70de2e9c146867b9d2e0/src/mono/netcore/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/README.md | ||
*********************************************************************************************** | ||
--> | ||
<Project> | ||
|
||
<UsingTask TaskName="Xamarin.Android.Tasks.GetAotArguments" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" /> | ||
|
||
<Target Name="_AndroidAot" | ||
Condition=" '$(RunAOTCompilation)' == 'true' " | ||
Inputs="$(_BuildApkEmbedInputs)" | ||
Outputs="$(_BuildApkEmbedOutputs)"> | ||
|
||
<!--TODO: $(MonoAotCrossCompilerPath) is only set to the arm64 path --> | ||
<Error | ||
Condition=" '$(RuntimeIdentifier)' != 'android-arm64' " | ||
Text=" AOT is currently only supported when %24(RuntimeIdentifier) is set to 'android-arm64'." | ||
/> | ||
|
||
<GetAotArguments | ||
AndroidAotMode="$(AndroidAotMode)" | ||
AndroidNdkDirectory="$(_AndroidNdkDirectory)" | ||
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" | ||
AndroidApiLevel="$(_AndroidApiLevel)" | ||
ManifestFile="$(IntermediateOutputPath)android\AndroidManifest.xml" | ||
AndroidSequencePointsMode="$(_SequencePointsMode)" | ||
AotAdditionalArguments="$(AndroidAotAdditionalArguments)" | ||
AotOutputDirectory="$(_AndroidAotBinDirectory)" | ||
RuntimeIdentifier="$(RuntimeIdentifier)" | ||
EnableLLVM="$(EnableLLVM)" | ||
Profiles="@(_AotProfiles)"> | ||
<Output PropertyName="_AotArguments" TaskParameter="Arguments" /> | ||
</GetAotArguments> | ||
<ItemGroup> | ||
<_MonoAOTAssemblies Include="@(_ShrunkAssemblies->'%(FullPath)')" AotArguments="$(_AotArguments)" /> | ||
</ItemGroup> | ||
<MakeDir Directories="$(IntermediateOutputPath)aot\$(RuntimeIdentifier)\" /> | ||
<!-- | ||
TODO: | ||
* I set every [Input] with a non-existent property. | ||
* AotProfilePath is a single string, not sure how to pass @(_AotProfiles)? | ||
--> | ||
<MonoAOTCompiler | ||
AotProfilePath="$(_AotProfilePath)" | ||
Assemblies="@(_MonoAOTAssemblies)" | ||
CompilerBinaryPath="$(MonoAotCrossCompilerPath)" | ||
DisableParallelAot="$(_DisableParallelAot)" | ||
LLVMPath="$(_LLVMPath)" | ||
Mode="$(AndroidAotMode)" | ||
OutputDir="$(IntermediateOutputPath)aot\$(RuntimeIdentifier)\" | ||
Profilers="@(_AotProfiles)" | ||
UseAotDataFile="$(_UseAotDataFile)" | ||
UseLLVM="$(EnableLLVM)"> | ||
<Output TaskParameter="CompiledAssemblies" ItemName="_AotCompiledAssemblies" /> | ||
<Output TaskParameter="FileWrites" ItemName="FileWrites" /> | ||
</MonoAOTCompiler> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.