-
Notifications
You must be signed in to change notification settings - Fork 564
[NativeAOT] improve build logic, part 1 #9614
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 |
|---|---|---|
|
|
@@ -24,10 +24,13 @@ | |
| See: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L16 | ||
| --> | ||
| <_GetChildProjectCopyToPublishDirectoryItems>false</_GetChildProjectCopyToPublishDirectoryItems> | ||
| <UseMonoRuntime Condition=" '$(PublishAot)' == 'true' and '$(UseMonoRuntime)' == '' ">false</UseMonoRuntime> | ||
| <!-- Define a $(_AndroidNativeAot) property, as the logic detecting NativeAOT may change in the future --> | ||
| <_AndroidNativeAot Condition=" '$(PublishAot)' == 'true' ">true</_AndroidNativeAot> | ||
| <_AndroidNativeAot Condition=" '$(_AndroidNativeAot)' == '' ">false</_AndroidNativeAot> | ||
| <UseMonoRuntime Condition=" '$(_AndroidNativeAot)' == 'true' and '$(UseMonoRuntime)' == '' ">false</UseMonoRuntime> | ||
|
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. What happens/what should happen when Perhaps we should warn?
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. Customers usually would not set iOS has the following logic in .NET 9, that is up for discussion:
I don't think we should change anything, until we know what it should do and align with iOS. I kind of feel like |
||
| <UseMonoRuntime Condition=" '$(UseMonoRuntime)' == '' ">true</UseMonoRuntime> | ||
| <!-- HACK: make dotnet restore include Microsoft.NETCore.App.Runtime.NativeAOT.linux-bionic-arm64 --> | ||
| <_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(PublishAot)' == 'true' ">true</_IsPublishing> | ||
| <_IsPublishing Condition=" '$(_IsPublishing)' == '' and '$(_AndroidNativeAot)' == 'true' ">true</_IsPublishing> | ||
|
|
||
| <!-- Use $(AndroidMinimumSupportedApiLevel) for $(SupportedOSPlatformVersion) if unset --> | ||
| <SupportedOSPlatformVersion Condition=" '$(SupportedOSPlatformVersion)' == '' ">$(AndroidMinimumSupportedApiLevel)</SupportedOSPlatformVersion> | ||
|
|
@@ -94,7 +97,7 @@ | |
| <RuntimeIdentifier Condition=" '$(RuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' != '' " /> | ||
| <GenerateApplicationManifest Condition=" '$(GenerateApplicationManifest)' == '' ">true</GenerateApplicationManifest> | ||
| <!-- Default to Mono's AOT in Release mode --> | ||
| <RunAOTCompilation Condition=" '$(RunAOTCompilation)' == '' and '$(AotAssemblies)' == '' and '$(Configuration)' == 'Release' and '$(PublishAot)' != 'true' ">true</RunAOTCompilation> | ||
| <RunAOTCompilation Condition=" '$(RunAOTCompilation)' == '' and '$(AotAssemblies)' == '' and '$(Configuration)' == 'Release' and '$(_AndroidNativeAot)' != 'true' ">true</RunAOTCompilation> | ||
|
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. I realize that this is pre-existing logic, but we really shouldn't be using <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
…
</PropertyGroup>Do we need to check
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.
This is the same way the .NET SDK specifies For SDK-style projects, we basically have to declare defaults based on
We could move this expression up to be inside |
||
| <RunAOTCompilation Condition=" '$(RunAOTCompilation)' == '' and '$(AotAssemblies)' == 'true' ">true</RunAOTCompilation> | ||
| <RunAOTCompilation Condition=" '$(RunAOTCompilation)' == '' ">false</RunAOTCompilation> | ||
| <_AndroidXA1029 Condition=" '$(AotAssemblies)' != '' ">true</_AndroidXA1029> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,11 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android. | |
| --> | ||
| <Project> | ||
|
|
||
| <!-- Default property values for NativeAOT --> | ||
| <PropertyGroup> | ||
| <_AndroidRuntimePackRuntime>NativeAOT</_AndroidRuntimePackRuntime> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Make IlcCompile depend on the trimmer --> | ||
| <PropertyGroup> | ||
| <IlcCompileDependsOn> | ||
|
|
@@ -60,12 +65,17 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android. | |
| <SuppressTrimAnalysisWarnings>$(_OriginalSuppressTrimAnalysisWarnings)</SuppressTrimAnalysisWarnings> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <!-- Android needs a proper soname property or it will refuse to load the library --> | ||
| <LinkerArg Include="-Wl,-soname,lib$(TargetName)$(NativeBinaryExt)" /> | ||
| <!-- Give ILLink's output to ILC --> | ||
| <IlcCompileInput Remove="@(IlcCompileInput)" /> | ||
| <IlcCompileInput Include="$(IntermediateLinkDir)$(TargetName)$(TargetExt)" /> | ||
| <_AndroidILLinkAssemblies Include="@(ManagedAssemblyToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" Condition="Exists('$(IntermediateLinkDir)%(Filename)%(Extension)')" /> | ||
| <IlcReference Remove="@(IlcReference)" /> | ||
| <IlcReference Include="@(PrivateSdkAssemblies)" /> | ||
| <IlcReference Include="@(ManagedAssemblyToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" Condition="Exists('$(IntermediateLinkDir)%(Filename)%(Extension)')" Exclude="@(IlcCompileInput)" /> | ||
| <IlcReference Include="@(_AndroidILLinkAssemblies)" /> | ||
| <!-- Passes linked assemblies to outer MSBuild tasks/targets --> | ||
| <ResolvedFileToPublish Include="@(IlcCompileInput);@(_AndroidILLinkAssemblies)" RuntimeIdentifier="$(_OriginalRuntimeIdentifier)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
|
|
@@ -76,4 +86,11 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android. | |
| </PropertyGroup> | ||
| </Target> | ||
|
|
||
| <Target Name="_AndroidFixNativeLibraryFileName" AfterTargets="ComputeFilesToPublish"> | ||
| <ItemGroup> | ||
| <!-- Fix paths to contain lib-prefix --> | ||
| <ResolvedFileToPublish Update="@(ResolvedFileToPublish)" ArchiveFileName="lib%(FileName)%(Extension)" Condition=" '%(Filename)%(Extension)' == '$(TargetName)$(NativeBinaryExt)' " /> | ||
|
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. This means that if I don't know if this is an actual problem. |
||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| </Project> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now set in
Microsoft.Android.Sdk.NativeAOT.targets.