|
| 1 | +<!-- |
| 2 | +*********************************************************************************************** |
| 3 | +Microsoft.Android.Sdk.Aot.targets |
| 4 | +
|
| 5 | +.NET 6 AOT support. You can find "legacy" Xamarin.Android AOT support |
| 6 | +in Xamarin.Android.Legacy.targets. |
| 7 | +
|
| 8 | +For <MonoAOTCompiler/> usage, see: |
| 9 | +* https://github.com/dotnet/runtime/blob/15dec9a2aa5a4236d6ba70de2e9c146867b9d2e0/src/tasks/AotCompilerTask/MonoAOTCompiler.cs |
| 10 | +* https://github.com/dotnet/runtime/blob/15dec9a2aa5a4236d6ba70de2e9c146867b9d2e0/src/mono/netcore/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/README.md |
| 11 | +
|
| 12 | +These targets are running within the _ComputeFilesToPublishForRuntimeIdentifiers target. |
| 13 | +They run in a context of an inner build with a single $(RuntimeIdentifier). |
| 14 | +
|
| 15 | +*********************************************************************************************** |
| 16 | +--> |
| 17 | +<Project> |
| 18 | + |
| 19 | + <!-- |
| 20 | + NOTE: currently, the only way to allow $(AotAssemblies) in |
| 21 | + .csproj files is to import these in the Android workload |
| 22 | + when $(MonoAOTCompilerTasksAssemblyPath) is blank: |
| 23 | + https://github.com/dotnet/runtime/blob/69711860262e44458bbe276393ea3eb9f7a2192a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets.in#L20-L25 |
| 24 | + --> |
| 25 | + <ImportGroup Condition=" '$(MonoAOTCompilerTasksAssemblyPath)' == '' and '$(AotAssemblies)' == 'true' "> |
| 26 | + <Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoAOTCompiler.Task" /> |
| 27 | + <Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.android-x86" /> |
| 28 | + <Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.android-x64" /> |
| 29 | + <Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.android-arm" /> |
| 30 | + <Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.android-arm64" /> |
| 31 | + </ImportGroup> |
| 32 | + |
| 33 | + <UsingTask TaskName="Xamarin.Android.Tasks.GetAotArguments" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" /> |
| 34 | + |
| 35 | + <Target Name="_AndroidAotInputs"> |
| 36 | + <ItemGroup> |
| 37 | + <_AndroidAotInputs Include="@(ResolvedFileToPublish)" Condition=" '%(Extension)' == '.dll' " /> |
| 38 | + </ItemGroup> |
| 39 | + </Target> |
| 40 | + |
| 41 | + <Target Name="_AndroidAot" |
| 42 | + Condition=" '$(AotAssemblies)' == 'true' and '$(RuntimeIdentifier)' != '' " |
| 43 | + DependsOnTargets="_AndroidAotInputs" |
| 44 | + Inputs="@(_AndroidAotInputs)" |
| 45 | + Outputs="$(_AndroidStampDirectory)_AndroidAot.stamp"> |
| 46 | + <GetAotArguments |
| 47 | + AndroidAotMode="$(AndroidAotMode)" |
| 48 | + AndroidNdkDirectory="$(_AndroidNdkDirectory)" |
| 49 | + AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" |
| 50 | + AndroidApiLevel="$(_AndroidApiLevel)" |
| 51 | + MinimumSupportedApiLevel="$(AndroidMinimumSupportedApiLevel)" |
| 52 | + AndroidSequencePointsMode="$(_SequencePointsMode)" |
| 53 | + AotAdditionalArguments="$(AndroidAotAdditionalArguments)" |
| 54 | + AotOutputDirectory="$(_AndroidAotBinDirectory)" |
| 55 | + RuntimeIdentifier="$(RuntimeIdentifier)" |
| 56 | + EnableLLVM="$(EnableLLVM)" |
| 57 | + Profiles="@(_AotProfiles)"> |
| 58 | + <Output PropertyName="_AotArguments" TaskParameter="Arguments" /> |
| 59 | + <Output PropertyName="_LLVMPath" TaskParameter="LLVMPath" /> |
| 60 | + </GetAotArguments> |
| 61 | + <ItemGroup> |
| 62 | + <_MonoAOTAssemblies Include="@(_AndroidAotInputs->'%(FullPath)')" AotArguments="$(_AotArguments)" /> |
| 63 | + </ItemGroup> |
| 64 | + <MakeDir Directories="$(IntermediateOutputPath)aot\" /> |
| 65 | + <MonoAOTCompiler |
| 66 | + Assemblies="@(_MonoAOTAssemblies)" |
| 67 | + CompilerBinaryPath="@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier', '$(RuntimeIdentifier)'))" |
| 68 | + DisableParallelAot="$(_DisableParallelAot)" |
| 69 | + LibraryFormat="So" |
| 70 | + Mode="$(AndroidAotMode)" |
| 71 | + OutputDir="$(IntermediateOutputPath)aot\" |
| 72 | + OutputType="Library" |
| 73 | + UseAotDataFile="false" |
| 74 | + UseLLVM="$(EnableLLVM)" |
| 75 | + LLVMPath="$(_LLVMPath)"> |
| 76 | + <Output TaskParameter="CompiledAssemblies" ItemName="_AotCompiledAssemblies" /> |
| 77 | + <Output TaskParameter="FileWrites" ItemName="FileWrites" /> |
| 78 | + </MonoAOTCompiler> |
| 79 | + <Touch Files="$(_AndroidStampDirectory)_AndroidAot.stamp" AlwaysCreate="true" /> |
| 80 | + <ItemGroup> |
| 81 | + <ResolvedFileToPublish |
| 82 | + Include="@(_AotCompiledAssemblies->'%(LibraryFile)')" |
| 83 | + ArchiveFileName="libaot-$([System.IO.Path]::GetFileNameWithoutExtension('%(_AotCompiledAssemblies.LibraryFile)')).so" |
| 84 | + /> |
| 85 | + </ItemGroup> |
| 86 | + </Target> |
| 87 | +</Project> |
0 commit comments