Skip to content

Commit

Permalink
[build] runtime "flavors" part 2
Browse files Browse the repository at this point in the history
Context: #9538
Context: #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.
  • Loading branch information
jonathanpeppers committed Dec 6, 2024
1 parent 4b158ce commit 3729f16
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 67 deletions.
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@"
},
"Microsoft.Android.Templates": {
"kind": "template",
"version": "@WORKLOAD_VERSION@"
Expand Down

0 comments on commit 3729f16

Please sign in to comment.