Skip to content

Commit c04fdde

Browse files
[build] runtime "flavors" part 2
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.
1 parent 0434024 commit c04fdde

File tree

8 files changed

+61
-85
lines changed

8 files changed

+61
-85
lines changed

Configuration.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@
6363
<_MonoAndroidNETOutputRoot>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\</_MonoAndroidNETOutputRoot>
6464
<_MonoAndroidNETDefaultOutDir>$(_MonoAndroidNETOutputRoot)$(AndroidApiLevel)\</_MonoAndroidNETDefaultOutDir>
6565
<MicrosoftAndroidRefPackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\ref\$(DotNetTargetFramework)\</MicrosoftAndroidRefPackDir>
66-
<MicrosoftAndroidArmPackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm\$(AndroidPackVersion)\runtimes\android-arm\</MicrosoftAndroidArmPackDir>
67-
<MicrosoftAndroidArm64PackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm64\$(AndroidPackVersion)\runtimes\android-arm64\</MicrosoftAndroidArm64PackDir>
68-
<MicrosoftAndroidx86PackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x86\$(AndroidPackVersion)\runtimes\android-x86\</MicrosoftAndroidx86PackDir>
69-
<MicrosoftAndroidx64PackDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x64\$(AndroidPackVersion)\runtimes\android-x64\</MicrosoftAndroidx64PackDir>
7066
<MicrosoftAndroidSdkPackDir>$(BuildOutputDirectory)lib\packs\$(MicrosoftAndroidSdkPackName)\$(AndroidPackVersion)\</MicrosoftAndroidSdkPackDir>
7167
<MicrosoftAndroidSdkOutDir>$(MicrosoftAndroidSdkPackDir)\tools\</MicrosoftAndroidSdkOutDir>
7268
<MicrosoftAndroidSdkAnalysisOutDir>$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\analyzers\dotnet\cs\</MicrosoftAndroidSdkAnalysisOutDir>
@@ -219,4 +215,8 @@
219215
</PropertyGroup>
220216

221217
<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\Ndk.targets" />
218+
<ItemGroup>
219+
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="Mono" />
220+
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="NativeAOT" />
221+
</ItemGroup>
222222
</Project>

build-tools/create-packs/ConfigureLocalWorkload.targets

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,26 @@
66
<_FrameworkListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidDefaultTargetDotnetApiLevel)\$(AndroidPackVersion)\data\FrameworkList.xml" />
77
<_FrameworkListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidLatestStableApiLevel)\$(AndroidPackVersion)\data\FrameworkList.xml" />
88
<_FrameworkListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidLatestUnstableApiLevel)\$(AndroidPackVersion)\data\FrameworkList.xml" />
9-
<_RuntimeListInputs Include="$(MicrosoftAndroidArmPackDir)**" />
10-
<_RuntimeListInputs Include="$(MicrosoftAndroidArm64PackDir)**" />
11-
<_RuntimeListInputs Include="$(MicrosoftAndroidx86PackDir)**" />
12-
<_RuntimeListInputs Include="$(MicrosoftAndroidx64PackDir)**" />
13-
<_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidDefaultTargetDotnetApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" />
14-
<_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidLatestStableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" />
15-
<_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidLatestUnstableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" />
169
<_TemplatesInputs Include="$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\**" />
1710
<_TemplatesOutputs Include="$(BuildOutputDirectory)lib\template-packs\microsoft.android.templates.$(AndroidPackVersion).nupkg" />
1811
</ItemGroup>
1912

13+
<Target Name="_CreateLocalRuntimeListsInputs">
14+
<ItemGroup>
15+
<_RuntimeListInputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\runtimes\%(AndroidAbiAndRuntimeFlavor.AndroidRID)\**" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
16+
<_RuntimeListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidDefaultTargetDotnetApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
17+
<_RuntimeListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidLatestStableApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
18+
<_RuntimeListOutputs Include="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).$(AndroidLatestUnstableApiLevel).%(AndroidAbiAndRuntimeFlavor.AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
19+
</ItemGroup>
20+
</Target>
21+
2022
<Target Name="CreateLocalRuntimeLists"
23+
DependsOnTargets="_CreateLocalRuntimeListsInputs"
2124
Inputs="$(MSBuildAllProjects);@(_RuntimeListInputs)"
2225
Outputs="@(_RuntimeListOutputs)">
2326
<MSBuild
2427
Projects="$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj"
25-
Properties="FrameworkListFile=%(_RuntimeListOutputs.Identity);AndroidRID=%(_RuntimeListOutputs.AndroidRID)"
28+
Properties="FrameworkListFile=%(_RuntimeListOutputs.Identity);AndroidRID=%(_RuntimeListOutputs.AndroidRID);AndroidRuntime=%(_RuntimeListOutputs.AndroidRuntime)"
2629
Targets="_GetRuntimePackItems;_GenerateFrameworkListFile"
2730
/>
2831
</Target>

build-tools/create-packs/Microsoft.Android.Runtime.proj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ projects that use the Microsoft.Android framework in .NET 6+.
3939
<_AndroidRuntimePackAssemblies Include="$(_MonoAndroidNETDefaultOutDir)Mono.Android.Runtime.dll" />
4040
<!-- Always include stable Mono.Android.Export.dll -->
4141
<_AndroidRuntimePackAssemblies Include="$(_MonoAndroidNETOutputRoot)$(AndroidLatestStableApiLevel)\Mono.Android.Export.dll" />
42+
</ItemGroup>
43+
44+
<ItemGroup Condition=" '$(AndroidRuntime)' == 'Mono' ">
4245
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.debug.so" />
4346
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release.so" />
4447
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxamarin-debug-app-helper.so" />
4548
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libxamarin-native-tracing.so" />
4649
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libunwind_xamarin.a" />
50+
</ItemGroup>
51+
52+
<ItemGroup>
4753
<FrameworkListFileClass Include="@(_AndroidRuntimePackAssemblies->'%(Filename)%(Extension)')" Profile="Android" />
4854
<FrameworkListFileClass Include="@(_AndroidRuntimePackAssets->'%(Filename)%(Extension)')" Profile="Android" />
4955
</ItemGroup>

src/Mono.Android.Export/Mono.Android.Export.csproj

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,19 @@
3737
</BuildDependsOn>
3838
</PropertyGroup>
3939

40-
<Target Name="_CopyToPackDirs" >
40+
<Target Name="_CopyToPackDirs">
41+
<ItemGroup>
42+
<_RuntimePackFiles Include="$(OutputPath)Mono.Android.Export.dll" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
43+
</ItemGroup>
44+
4145
<Copy
4246
SourceFiles="$(OutputPath)ref\Mono.Android.Export.dll"
4347
DestinationFolder="$(MicrosoftAndroidRefPackDir)"
4448
SkipUnchangedFiles="true"
4549
/>
4650
<Copy
47-
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
48-
DestinationFolder="$(MicrosoftAndroidArmPackDir)lib\$(DotNetTargetFramework)"
49-
SkipUnchangedFiles="true"
50-
/>
51-
<Copy
52-
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
53-
DestinationFolder="$(MicrosoftAndroidArm64PackDir)lib\$(DotNetTargetFramework)"
54-
SkipUnchangedFiles="true"
55-
/>
56-
<Copy
57-
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
58-
DestinationFolder="$(MicrosoftAndroidx86PackDir)lib\$(DotNetTargetFramework)"
59-
SkipUnchangedFiles="true"
60-
/>
61-
<Copy
62-
SourceFiles="$(OutputPath)Mono.Android.Export.dll"
63-
DestinationFolder="$(MicrosoftAndroidx64PackDir)lib\$(DotNetTargetFramework)"
51+
SourceFiles="%(_RuntimePackFiles.Identity)"
52+
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\lib\$(DotNetTargetFramework)"
6453
SkipUnchangedFiles="true"
6554
/>
6655
</Target>

src/Mono.Android.Runtime/Mono.Android.Runtime.targets

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,19 @@
2222
</ReplaceFileContents>
2323
</Target>
2424

25-
<Target Name="_CopyToPackDirs" >
25+
<Target Name="_CopyToPackDirs">
26+
<ItemGroup>
27+
<_RuntimePackFiles Include="$(OutputPath)Mono.Android.Runtime.dll" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
28+
</ItemGroup>
29+
2630
<Copy
2731
SourceFiles="$(OutputPath)ref\Mono.Android.Runtime.dll"
2832
DestinationFolder="$(MicrosoftAndroidRefPackDir)"
2933
SkipUnchangedFiles="true"
3034
/>
3135
<Copy
32-
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
33-
DestinationFolder="$(MicrosoftAndroidArmPackDir)lib\$(DotNetTargetFramework)"
34-
SkipUnchangedFiles="true"
35-
/>
36-
<Copy
37-
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
38-
DestinationFolder="$(MicrosoftAndroidArm64PackDir)lib\$(DotNetTargetFramework)"
39-
SkipUnchangedFiles="true"
40-
/>
41-
<Copy
42-
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
43-
DestinationFolder="$(MicrosoftAndroidx86PackDir)lib\$(DotNetTargetFramework)"
44-
SkipUnchangedFiles="true"
45-
/>
46-
<Copy
47-
SourceFiles="$(OutputPath)Mono.Android.Runtime.dll"
48-
DestinationFolder="$(MicrosoftAndroidx64PackDir)lib\$(DotNetTargetFramework)"
36+
SourceFiles="%(_RuntimePackFiles.Identity)"
37+
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\lib\$(DotNetTargetFramework)"
4938
SkipUnchangedFiles="true"
5039
/>
5140
</Target>

src/Mono.Android/Mono.Android.csproj

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,12 @@
405405
</BuildDependsOn>
406406
</PropertyGroup>
407407

408-
<Target Name="_CopyToPackDirs" >
408+
<Target Name="_CopyToPackDirs">
409409
<ItemGroup>
410410
<_RefExtras Include="$(OutputPath)*.*" Exclude="$(OutputPath)*.dll" />
411-
<_SourceFiles Include="$(OutputPath)Mono.Android.*;$(OutputPath)Java.Interop.*" />
411+
<_SourceFiles Include="$(OutputPath)Mono.Android.*" />
412+
<_SourceFiles Include="$(OutputPath)Java.Interop.*" />
413+
<_RuntimePackFiles Include="@(_SourceFiles)" AndroidRID="%(AndroidAbiAndRuntimeFlavor.AndroidRID)" AndroidRuntime="%(AndroidAbiAndRuntimeFlavor.AndroidRuntime)" />
412414
</ItemGroup>
413415
<Copy
414416
SourceFiles="@(_RefExtras)"
@@ -421,23 +423,8 @@
421423
SkipUnchangedFiles="true"
422424
/>
423425
<Copy
424-
SourceFiles="@(_SourceFiles)"
425-
DestinationFolder="$(MicrosoftAndroidArmPackDir)lib\$(DotNetTargetFramework)"
426-
SkipUnchangedFiles="true"
427-
/>
428-
<Copy
429-
SourceFiles="@(_SourceFiles)"
430-
DestinationFolder="$(MicrosoftAndroidArm64PackDir)lib\$(DotNetTargetFramework)"
431-
SkipUnchangedFiles="true"
432-
/>
433-
<Copy
434-
SourceFiles="@(_SourceFiles)"
435-
DestinationFolder="$(MicrosoftAndroidx86PackDir)lib\$(DotNetTargetFramework)"
436-
SkipUnchangedFiles="true"
437-
/>
438-
<Copy
439-
SourceFiles="@(_SourceFiles)"
440-
DestinationFolder="$(MicrosoftAndroidx64PackDir)lib\$(DotNetTargetFramework)"
426+
SourceFiles="%(_RuntimePackFiles.Identity)"
427+
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\lib\$(DotNetTargetFramework)"
441428
SkipUnchangedFiles="true"
442429
/>
443430
<Copy

src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@
6969
"kind": "framework",
7070
"version": "@WORKLOAD_VERSION@"
7171
},
72+
"Microsoft.Android.Runtime.NativeAOT.35.android-arm": {
73+
"kind": "framework",
74+
"version": "@WORKLOAD_VERSION@"
75+
},
76+
"Microsoft.Android.Runtime.NativeAOT.35.android-arm64": {
77+
"kind": "framework",
78+
"version": "@WORKLOAD_VERSION@"
79+
},
80+
"Microsoft.Android.Runtime.NativeAOT.35.android-x86": {
81+
"kind": "framework",
82+
"version": "@WORKLOAD_VERSION@"
83+
},
84+
"Microsoft.Android.Runtime.NativeAOT.35.android-x64": {
85+
"kind": "framework",
86+
"version": "@WORKLOAD_VERSION@"
87+
},
7288
"Microsoft.Android.Templates": {
7389
"kind": "template",
7490
"version": "@WORKLOAD_VERSION@"

src/native/native.targets

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -243,27 +243,13 @@
243243

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

252250
<Copy
253-
SourceFiles="@(_ArmRuntimePackFiles)"
254-
DestinationFolder="$(MicrosoftAndroidArmPackDir)native"
255-
SkipUnchangedFiles="true" />
256-
<Copy
257-
SourceFiles="@(_Arm64RuntimePackFiles)"
258-
DestinationFolder="$(MicrosoftAndroidArm64PackDir)native"
259-
SkipUnchangedFiles="true" />
260-
<Copy
261-
SourceFiles="@(_x86RuntimePackFiles)"
262-
DestinationFolder="$(MicrosoftAndroidx86PackDir)native"
263-
SkipUnchangedFiles="true" />
264-
<Copy
265-
SourceFiles="@(_x64RuntimePackFiles)"
266-
DestinationFolder="$(MicrosoftAndroidx64PackDir)native"
251+
SourceFiles="%(_RuntimePackFiles.Identity)"
252+
DestinationFolder="$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.%(_RuntimePackFiles.AndroidRuntime).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\native"
267253
SkipUnchangedFiles="true" />
268254
</Target>
269255
</Project>

0 commit comments

Comments
 (0)