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

[build] runtime "flavors" part 2 #9598

Merged
merged 1 commit into from
Dec 9, 2024
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
8 changes: 4 additions & 4 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
<_MonoAndroidNETOutputRoot>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\</_MonoAndroidNETOutputRoot>
<_MonoAndroidNETDefaultOutDir>$(_MonoAndroidNETOutputRoot)$(AndroidApiLevel)\</_MonoAndroidNETDefaultOutDir>
<MicrosoftAndroidRefPackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\ref\$(DotNetTargetFramework)\</MicrosoftAndroidRefPackDir>
<MicrosoftAndroidArmPackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm\$(AndroidPackVersion)\runtimes\android-arm\</MicrosoftAndroidArmPackDir>
<MicrosoftAndroidArm64PackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm64\$(AndroidPackVersion)\runtimes\android-arm64\</MicrosoftAndroidArm64PackDir>
<MicrosoftAndroidx86PackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x86\$(AndroidPackVersion)\runtimes\android-x86\</MicrosoftAndroidx86PackDir>
<MicrosoftAndroidx64PackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x64\$(AndroidPackVersion)\runtimes\android-x64\</MicrosoftAndroidx64PackDir>
<MicrosoftAndroidSdkPackDir>$(BuildOutputDirectory)lib\packs\$(MicrosoftAndroidSdkPackName)\$(AndroidPackVersion)\</MicrosoftAndroidSdkPackDir>
<MicrosoftAndroidSdkOutDir>$(MicrosoftAndroidSdkPackDir)\tools\</MicrosoftAndroidSdkOutDir>
<MicrosoftAndroidSdkAnalysisOutDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\analyzers\dotnet\cs\</MicrosoftAndroidSdkAnalysisOutDir>
Expand Down Expand Up @@ -219,4 +215,8 @@
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\Ndk.targets" />
<ItemGroup>
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="Mono" />
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="NativeAOT" />
</ItemGroup>
</Project>
19 changes: 11 additions & 8 deletions build-tools/create-packs/ConfigureLocalWorkload.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@
<_FrameworkListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidDefaultTargetDotnetApiLevel)\$(AndroidPackVersion)\data\FrameworkList.xml" />
<_FrameworkListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidLatestStableApiLevel)\$(AndroidPackVersion)\data\FrameworkList.xml" />
<_FrameworkListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidLatestUnstableApiLevel)\$(AndroidPackVersion)\data\FrameworkList.xml" />
<_RuntimeListInputs Include="$(MicrosoftAndroidArmPackDir)**" />
<_RuntimeListInputs Include="$(MicrosoftAndroidArm64PackDir)**" />
<_RuntimeListInputs Include="$(MicrosoftAndroidx86PackDir)**" />
<_RuntimeListInputs Include="$(MicrosoftAndroidx64PackDir)**" />
<_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidDefaultTargetDotnetApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" />
<_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidLatestStableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" />
<_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidLatestUnstableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" />
<_TemplatesInputs Include="$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\**" />
<_TemplatesOutputs Include="$(BuildOutputDirectory)lib\template-packs\microsoft.android.templates.$(AndroidPackVersion).nupkg" />
</ItemGroup>

<Target Name="_CreateLocalRuntimeListsInputs">
<ItemGroup>
<_RuntimeListInputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\runtimes\%(AndroidAbiAndRuntimeFlavor.AndroidRID)\**" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
<_RuntimeListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidDefaultTargetDotnetApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
<_RuntimeListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidLatestStableApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
<_RuntimeListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidLatestUnstableApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
</ItemGroup>
</Target>

<Target Name="CreateLocalRuntimeLists"
DependsOnTargets="_CreateLocalRuntimeListsInputs"
Inputs="$(MSBuildAllProjects);@(_RuntimeListInputs)"
Outputs="@(_RuntimeListOutputs)">
<MSBuild
Projects="$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj"
Properties="FrameworkListFile=%(_RuntimeListOutputs.Identity);AndroidRID=%(_RuntimeListOutputs.AndroidRID)"
Properties="FrameworkListFile=%(_RuntimeListOutputs.Identity);AndroidRID=%(_RuntimeListOutputs.AndroidRID);AndroidRuntime=%(_RuntimeListOutputs.AndroidRuntime)"
Targets="_GetRuntimePackItems;_GenerateFrameworkListFile"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions build-tools/create-packs/Microsoft.Android.Runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ projects that use the Microsoft.Android framework in .NET 6+.
<_AndroidRuntimePackAssemblies Include="$(_MonoAndroidNETDefaultOutDir)Mono.Android.Runtime.dll" />
<!-- Always include stable Mono.Android.Export.dll -->
<_AndroidRuntimePackAssemblies Include="$(_MonoAndroidNETOutputRoot)$(AndroidLatestStableApiLevel)\Mono.Android.Export.dll" />
</ItemGroup>

<ItemGroup Condition=" '$(AndroidRuntime)' == 'Mono' ">
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.debug.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxamarin-debug-app-helper.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxamarin-native-tracing.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libunwind_xamarin.a" />
</ItemGroup>

<ItemGroup>
<FrameworkListFileClass Include="@(_AndroidRuntimePackAssemblies->'%(Filename)%(Extension)')" Profile="Android" />
<FrameworkListFileClass Include="@(_AndroidRuntimePackAssets->'%(Filename)%(Extension)')" Profile="Android" />
</ItemGroup>
Expand Down
25 changes: 7 additions & 18 deletions src/Mono.Android.Export/Mono.Android.Export.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,19 @@
</BuildDependsOn>
</PropertyGroup>

<Target Name="_CopyToPackDirs" >
<Target Name="_CopyToPackDirs">
<ItemGroup>
<_RuntimePackFiles Include="$(OutputPath)Mono.Android.Export.dll" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
</ItemGroup>

<Copy
SourceFiles="$(OutputPath)ref\Mono.Android.Export.dll"
DestinationFolder="$(MicrosoftAndroidRefPackDir)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
DestinationFolder="$(MicrosoftAndroidArmPackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
DestinationFolder="$(MicrosoftAndroidArm64PackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
DestinationFolder="$(MicrosoftAndroidx86PackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
DestinationFolder="$(MicrosoftAndroidx64PackDir)lib\$(DotNetTargetFramework)"
SourceFiles="%(_RuntimePackFiles.Identity)"
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
</Target>
Expand Down
25 changes: 7 additions & 18 deletions src/Mono.Android.Runtime/Mono.Android.Runtime.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,19 @@
</ReplaceFileContents>
</Target>

<Target Name="_CopyToPackDirs" >
<Target Name="_CopyToPackDirs">
<ItemGroup>
<_RuntimePackFiles Include="$(OutputPath)Mono.Android.Runtime.dll" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
</ItemGroup>

<Copy
SourceFiles="$(OutputPath)ref\Mono.Android.Runtime.dll"
DestinationFolder="$(MicrosoftAndroidRefPackDir)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
DestinationFolder="$(MicrosoftAndroidArmPackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
DestinationFolder="$(MicrosoftAndroidArm64PackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
DestinationFolder="$(MicrosoftAndroidx86PackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
DestinationFolder="$(MicrosoftAndroidx64PackDir)lib\$(DotNetTargetFramework)"
SourceFiles="%(_RuntimePackFiles.Identity)"
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
</Target>
Expand Down
25 changes: 6 additions & 19 deletions src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,12 @@
</BuildDependsOn>
</PropertyGroup>

<Target Name="_CopyToPackDirs" >
<Target Name="_CopyToPackDirs">
<ItemGroup>
<_RefExtras Include="$(OutputPath)*.*" Exclude="$(OutputPath)*.dll" />
<_SourceFiles Include="$(OutputPath)Mono.Android.*;$(OutputPath)Java.Interop.*" />
<_SourceFiles Include="$(OutputPath)Mono.Android.*" />
<_SourceFiles Include="$(OutputPath)Java.Interop.*" />
<_RuntimePackFiles Include="@(_SourceFiles)" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
</ItemGroup>
<Copy
SourceFiles="@(_RefExtras)"
Expand All @@ -421,23 +423,8 @@
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="@(_SourceFiles)"
DestinationFolder="$(MicrosoftAndroidArmPackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="@(_SourceFiles)"
DestinationFolder="$(MicrosoftAndroidArm64PackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="@(_SourceFiles)"
DestinationFolder="$(MicrosoftAndroidx86PackDir)lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
SourceFiles="@(_SourceFiles)"
DestinationFolder="$(MicrosoftAndroidx64PackDir)lib\$(DotNetTargetFramework)"
SourceFiles="%(_RuntimePackFiles.Identity)"
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\lib\$(DotNetTargetFramework)"
SkipUnchangedFiles="true"
/>
<Copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.NativeAOT.35.android-arm": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.NativeAOT.35.android-arm64": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.NativeAOT.35.android-x86": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.NativeAOT.35.android-x64": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we continue to expand this list, we probably will want to revisit dotnet/sdk#24077 / dotnet/sdk#24873. For .NET 10, we're very much going to want to come up with a way to cut down on the (now 8, ~soon to be 12?) duplicate versions of Mono.Android.dll (~35 MB each) and friends that we will be shipping.

"Microsoft.Android.Templates": {
"kind": "template",
"version": "@WORKLOAD_VERSION@"
Expand Down
22 changes: 4 additions & 18 deletions src/native/native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -243,27 +243,13 @@

<Target Name="_CopyToPackDirs">
<ItemGroup>
<_ArmRuntimePackFiles Include="$(OutputPath)\android-arm\*.*" />
<_Arm64RuntimePackFiles Include="$(OutputPath)\android-arm64\*.*" />
<_x86RuntimePackFiles Include="$(OutputPath)\android-x86\*.*" />
<_x64RuntimePackFiles Include="$(OutputPath)\android-x64\*.*" />
<_RuntimePackFiles Include="$(OutputPath)\%(AndroidSupportedTargetJitAbi.AndroidRID)\*" AndroidRID="%(AndroidSupportedTargetJitAbi.AndroidRID)" AndroidRuntime="Mono" />
<!-- NOTE: not building native libraries for NativeAOT yet -->
</ItemGroup>

<Copy
SourceFiles="@(_ArmRuntimePackFiles)"
DestinationFolder="$(MicrosoftAndroidArmPackDir)native"
SkipUnchangedFiles="true" />
<Copy
SourceFiles="@(_Arm64RuntimePackFiles)"
DestinationFolder="$(MicrosoftAndroidArm64PackDir)native"
SkipUnchangedFiles="true" />
<Copy
SourceFiles="@(_x86RuntimePackFiles)"
DestinationFolder="$(MicrosoftAndroidx86PackDir)native"
SkipUnchangedFiles="true" />
<Copy
SourceFiles="@(_x64RuntimePackFiles)"
DestinationFolder="$(MicrosoftAndroidx64PackDir)native"
SourceFiles="%(_RuntimePackFiles.Identity)"
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\native"
SkipUnchangedFiles="true" />
</Target>
</Project>
Loading