From 0f0de536f410a2c58bff7d6b56cd5a3445772493 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 6 Dec 2024 10:12:44 -0600 Subject: [PATCH] [build] runtime "flavors" part 2 Context: https://github.com/dotnet/android/pull/9538 Context: https://github.com/dotnet/android/pull/9583 Expanding upon #9538, there are more changes required to support multiple runtime flavors in our build. * Remove `$(MicrosoftAndroidArmPackDir)` and related properties, to rely on a new `@(AndroidAbiAndRuntimeFlavor)` item group instead. * Exclude our Mono-related native libraries from NativeAOT runtime packs. * Ensure that our runtime packs copy assemblies (`Mono.Android.dll`, etc.) to the appropriate NativeAOT-related directories. * List our `Microsoft.Android.Runtime.NativeAOT.*` packs in the `WorkloadManifest.json`, so that `**FromWorkload**` can resolve the version number for them. They can still restore via NuGet. --- Configuration.props | 8 +++--- .../ConfigureLocalWorkload.targets | 19 ++++++++------ .../Microsoft.Android.Runtime.proj | 6 +++++ .../Mono.Android.Export.csproj | 25 ++++++------------- .../Mono.Android.Runtime.targets | 25 ++++++------------- src/Mono.Android/Mono.Android.csproj | 25 +++++-------------- 6 files changed, 41 insertions(+), 67 deletions(-) diff --git a/Configuration.props b/Configuration.props index cb84e702081..29fd92a437d 100644 --- a/Configuration.props +++ b/Configuration.props @@ -63,10 +63,6 @@ <_MonoAndroidNETOutputRoot>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\ <_MonoAndroidNETDefaultOutDir>$(_MonoAndroidNETOutputRoot)$(AndroidApiLevel)\ $(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\ref\$(DotNetTargetFramework)\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm\$(AndroidPackVersion)\runtimes\android-arm\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm64\$(AndroidPackVersion)\runtimes\android-arm64\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x86\$(AndroidPackVersion)\runtimes\android-x86\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x64\$(AndroidPackVersion)\runtimes\android-x64\ $(BuildOutputDirectory)lib\packs\$(MicrosoftAndroidSdkPackName)\$(AndroidPackVersion)\ $(MicrosoftAndroidSdkPackDir)\tools\ $(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\analyzers\dotnet\cs\ @@ -219,4 +215,8 @@ + + + + diff --git a/build-tools/create-packs/ConfigureLocalWorkload.targets b/build-tools/create-packs/ConfigureLocalWorkload.targets index 00a37a8a9cc..b94bf153286 100644 --- a/build-tools/create-packs/ConfigureLocalWorkload.targets +++ b/build-tools/create-packs/ConfigureLocalWorkload.targets @@ -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" /> + + + <_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)" /> + + + diff --git a/build-tools/create-packs/Microsoft.Android.Runtime.proj b/build-tools/create-packs/Microsoft.Android.Runtime.proj index 99969ba29f6..9c3c22c1390 100644 --- a/build-tools/create-packs/Microsoft.Android.Runtime.proj +++ b/build-tools/create-packs/Microsoft.Android.Runtime.proj @@ -39,11 +39,17 @@ projects that use the Microsoft.Android framework in .NET 6+. <_AndroidRuntimePackAssemblies Include="$(_MonoAndroidNETDefaultOutDir)Mono.Android.Runtime.dll" /> <_AndroidRuntimePackAssemblies Include="$(_MonoAndroidNETOutputRoot)$(AndroidLatestStableApiLevel)\Mono.Android.Export.dll" /> + + + <_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" /> + + + diff --git a/src/Mono.Android.Export/Mono.Android.Export.csproj b/src/Mono.Android.Export/Mono.Android.Export.csproj index 760d8202691..5c0934a3b99 100644 --- a/src/Mono.Android.Export/Mono.Android.Export.csproj +++ b/src/Mono.Android.Export/Mono.Android.Export.csproj @@ -37,30 +37,19 @@ - + + + <_RuntimePackFiles Include="$(OutputPath)Mono.Android.Export.dll" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" /> + + - - - diff --git a/src/Mono.Android.Runtime/Mono.Android.Runtime.targets b/src/Mono.Android.Runtime/Mono.Android.Runtime.targets index 0b00eed9b47..9ab9e293f02 100644 --- a/src/Mono.Android.Runtime/Mono.Android.Runtime.targets +++ b/src/Mono.Android.Runtime/Mono.Android.Runtime.targets @@ -22,30 +22,19 @@ - + + + <_RuntimePackFiles Include="$(OutputPath)Mono.Android.Runtime.dll" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" /> + + - - - diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj index c9a8e47ede5..5b062533b27 100644 --- a/src/Mono.Android/Mono.Android.csproj +++ b/src/Mono.Android/Mono.Android.csproj @@ -405,10 +405,12 @@ - + <_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)" /> - - -