Skip to content

Commit dc54c1c

Browse files
[xaprepare] Check in Ndk.projitems, remove generator (#11733)
Mirrors #11608 (which checked in `Mono.Android.Apis.projitems` the same way). See also #11568, #11580, #11613, #11631, #11657, #11658. ## What `build-tools/scripts/Ndk.projitems.in` was a template with `@NDK_*@` placeholders that the `Get_Ndk_projitems` generator in xaprepare filled in from constants in `BuildAndroidPlatforms.cs`. Those substitution values only change on rare NDK bumps, so generating the file on every build adds no value. This PR checks in the resolved file as a static `build-tools/scripts/Ndk.projitems` and removes the generator. ## Changes - **Add** `build-tools/scripts/Ndk.projitems` — the static, checked-in file. Rather than hardcoding values, it sources them from the existing properties in `Configuration.props` (which is imported before `Ndk.targets`): - `AndroidNdkVersion` → `$(_XAAndroidNdkRelease)` - `AndroidNdkPkgRevision` → `$(_XAAndroidNdkPkgRevision)` - the per-ABI `AndroidNdkApiLevel_*` → `$(AndroidMinimumDotNetApiLevel)` So there is nothing to keep in sync on an NDK/API bump. - **`build-tools/scripts/Ndk.targets`** — point `ProjitemsFile` at the new in-tree location (`$(MSBuildThisFileDirectory)Ndk.projitems`) instead of `bin/Build$(Configuration)/Ndk.projitems`. - **Delete** `build-tools/scripts/Ndk.projitems.in`. - **`Step_GenerateFiles.cs`** — remove the `Get_Ndk_projitems` method and its dispatch entry. - **`Configurables.cs`** — update a doc comment reference from `Ndk.projitems.in` → `Ndk.projitems`. ### Simplifications (from review) - **Collapsed the dead legacy/NET API-level split.** The legacy 32-bit minimum API level used to be lower than the .NET minimum, but they are identical now. Removed the two per-ABI properties that nothing references (`AndroidNdkApiLevel_Arm`, `AndroidNdkApiLevel_X86_Legacy`). The `arm64-v8a`/`x86_64` properties are kept because shipped targets (`Build.Tasks.targets`, `Common.props.in`, `NativeAOT.targets`) still consume them by name. - **Removed the `ApiLevelNET` item metadata.** `ApiLevelNET` was the .NET (.NET 6+) Android minimum API level vs. the legacy Xamarin.Android/Mono `ApiLevel`; the two are identical now and this repo is .NET-only. Its only consumer was `src/native/common/libunwind/libunwind-xamarin.targets`, which now reads `ApiLevel`. Dropped `ApiLevelNET` from all four `AndroidSupportedTargetJitAbi` items. The NDK constants in `BuildAndroidPlatforms.cs` are intentionally left untouched — they're still consumed by `Get_XABuildConfig_cs` and the cmake presets generator. ## Verification - `dotnet build build-tools/xaprepare/xaprepare/xaprepare.csproj -c Debug` → 0 errors / 0 warnings. - Evaluated the import chain via a standalone MSBuild harness (importing the real `Configuration.props`); it produces all four `AndroidSupportedTargetJitAbi` items with `ApiLevel`=24 and the expected `AndroidRID` metadata, matching prior generator output (NDK `28c` / pkg `28.2.13676358`). - Audits clean: `git grep Ndk.projitems.in`, `git grep Ndk_projitems`, `git grep ApiLevelNET`, and the old `bin/Build$(Configuration)/Ndk.projitems` path all return 0 hits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c1ff467 commit dc54c1c

5 files changed

Lines changed: 63 additions & 89 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,61 +1,60 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup>
4-
<AndroidNdkVersion Condition=" '$(AndroidNdkVersion)' == '' ">@NDK_RELEASE@</AndroidNdkVersion>
5-
<AndroidNdkPkgRevision Condition=" '$(AndroidNdkPkgRevision)' == '' ">@NDK_PKG_REVISION@</AndroidNdkPkgRevision>
6-
<AndroidNdkApiLevel_ArmV7a Condition=" '$(AndroidNdkApiLevel_ArmV7a)' == '' ">@NDK_ARMEABI_V7_API@</AndroidNdkApiLevel_ArmV7a>
7-
<AndroidNdkApiLevel_Arm Condition=" '$(AndroidNdkApiLevel_Arm)' == '' ">@NDK_ARMEABI_V7_API_NET@</AndroidNdkApiLevel_Arm>
8-
<AndroidNdkApiLevel_ArmV8a Condition=" '$(AndroidNdkApiLevel_ArmV8a)' == '' ">@NDK_ARM64_V8A_API@</AndroidNdkApiLevel_ArmV8a>
9-
<AndroidNdkApiLevel_Arm64 Condition=" '$(AndroidNdkApiLevel_Arm64)' == '' ">@NDK_ARM64_V8A_API_NET@</AndroidNdkApiLevel_Arm64>
10-
<AndroidNdkApiLevel_X86_Legacy Condition=" '$(AndroidNdkApiLevel_X86_Legacy)' == '' ">@NDK_X86_API@</AndroidNdkApiLevel_X86_Legacy>
11-
<AndroidNdkApiLevel_X86 Condition=" '$(AndroidNdkApiLevel_X86)' == '' ">@NDK_X86_API_NET@</AndroidNdkApiLevel_X86>
12-
<AndroidNdkApiLevel_X86_64 Condition=" '$(AndroidNdkApiLevel_X86_64)' == '' ">@NDK_X86_64_API@</AndroidNdkApiLevel_X86_64>
13-
<AndroidNdkApiLevel_X64 Condition=" '$(AndroidNdkApiLevel_X64)' == '' ">@NDK_X86_64_API_NET@</AndroidNdkApiLevel_X64>
14-
</PropertyGroup>
15-
16-
<ItemGroup>
17-
<AndroidSupportedTargetJitAbi
18-
Include="armeabi-v7a"
19-
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi-v7a:')) ">
20-
<ApiLevel>$(AndroidNdkApiLevel_ArmV7a)</ApiLevel>
21-
<ApiLevelNET>$(AndroidNdkApiLevel_Arm)</ApiLevelNET>
22-
<AndroidRID>android-arm</AndroidRID>
23-
<SupportMonoVM>True</SupportMonoVM>
24-
<SupportCoreCLR>False</SupportCoreCLR>
25-
<SupportNativeAOT>False</SupportNativeAOT>
26-
</AndroidSupportedTargetJitAbi>
27-
28-
<AndroidSupportedTargetJitAbi
29-
Include="arm64-v8a"
30-
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':arm64-v8a:')) ">
31-
<ApiLevel>$(AndroidNdkApiLevel_ArmV8a)</ApiLevel>
32-
<ApiLevelNET>$(AndroidNdkApiLevel_Arm64)</ApiLevelNET>
33-
<AndroidRID>android-arm64</AndroidRID>
34-
<SupportMonoVM>True</SupportMonoVM>
35-
<SupportCoreCLR>True</SupportCoreCLR>
36-
<SupportNativeAOT>True</SupportNativeAOT>
37-
</AndroidSupportedTargetJitAbi>
38-
39-
<AndroidSupportedTargetJitAbi
40-
Include="x86"
41-
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86:')) ">
42-
<ApiLevel>$(AndroidNdkApiLevel_X86_Legacy)</ApiLevel>
43-
<ApiLevelNET>$(AndroidNdkApiLevel_X86)</ApiLevelNET>
44-
<AndroidRID>android-x86</AndroidRID>
45-
<SupportMonoVM>True</SupportMonoVM>
46-
<SupportCoreCLR>False</SupportCoreCLR>
47-
<SupportNativeAOT>False</SupportNativeAOT>
48-
</AndroidSupportedTargetJitAbi>
49-
50-
<AndroidSupportedTargetJitAbi
51-
Include="x86_64"
52-
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86_64:')) ">
53-
<ApiLevel>$(AndroidNdkApiLevel_X86_64)</ApiLevel>
54-
<ApiLevelNET>$(AndroidNdkApiLevel_X64)</ApiLevelNET>
55-
<AndroidRID>android-x64</AndroidRID>
56-
<SupportMonoVM>True</SupportMonoVM>
57-
<SupportCoreCLR>True</SupportCoreCLR>
58-
<SupportNativeAOT>True</SupportNativeAOT>
59-
</AndroidSupportedTargetJitAbi>
60-
</ItemGroup>
61-
</Project>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Checked-in. NDK version/revision and API level come from Configuration.props
4+
($(_XAAndroidNdkRelease), $(_XAAndroidNdkPkgRevision),
5+
$(AndroidMinimumDotNetApiLevel)), so there is nothing to keep in sync here.
6+
-->
7+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
8+
<PropertyGroup>
9+
<AndroidNdkVersion Condition=" '$(AndroidNdkVersion)' == '' ">$(_XAAndroidNdkRelease)</AndroidNdkVersion>
10+
<AndroidNdkPkgRevision Condition=" '$(AndroidNdkPkgRevision)' == '' ">$(_XAAndroidNdkPkgRevision)</AndroidNdkPkgRevision>
11+
<AndroidNdkApiLevel_ArmV7a Condition=" '$(AndroidNdkApiLevel_ArmV7a)' == '' ">$(AndroidMinimumDotNetApiLevel)</AndroidNdkApiLevel_ArmV7a>
12+
<AndroidNdkApiLevel_ArmV8a Condition=" '$(AndroidNdkApiLevel_ArmV8a)' == '' ">$(AndroidMinimumDotNetApiLevel)</AndroidNdkApiLevel_ArmV8a>
13+
<AndroidNdkApiLevel_Arm64 Condition=" '$(AndroidNdkApiLevel_Arm64)' == '' ">$(AndroidMinimumDotNetApiLevel)</AndroidNdkApiLevel_Arm64>
14+
<AndroidNdkApiLevel_X86 Condition=" '$(AndroidNdkApiLevel_X86)' == '' ">$(AndroidMinimumDotNetApiLevel)</AndroidNdkApiLevel_X86>
15+
<AndroidNdkApiLevel_X86_64 Condition=" '$(AndroidNdkApiLevel_X86_64)' == '' ">$(AndroidMinimumDotNetApiLevel)</AndroidNdkApiLevel_X86_64>
16+
<AndroidNdkApiLevel_X64 Condition=" '$(AndroidNdkApiLevel_X64)' == '' ">$(AndroidMinimumDotNetApiLevel)</AndroidNdkApiLevel_X64>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<AndroidSupportedTargetJitAbi
21+
Include="armeabi-v7a"
22+
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi-v7a:')) ">
23+
<ApiLevel>$(AndroidNdkApiLevel_ArmV7a)</ApiLevel>
24+
<AndroidRID>android-arm</AndroidRID>
25+
<SupportMonoVM>True</SupportMonoVM>
26+
<SupportCoreCLR>False</SupportCoreCLR>
27+
<SupportNativeAOT>False</SupportNativeAOT>
28+
</AndroidSupportedTargetJitAbi>
29+
30+
<AndroidSupportedTargetJitAbi
31+
Include="arm64-v8a"
32+
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':arm64-v8a:')) ">
33+
<ApiLevel>$(AndroidNdkApiLevel_ArmV8a)</ApiLevel>
34+
<AndroidRID>android-arm64</AndroidRID>
35+
<SupportMonoVM>True</SupportMonoVM>
36+
<SupportCoreCLR>True</SupportCoreCLR>
37+
<SupportNativeAOT>True</SupportNativeAOT>
38+
</AndroidSupportedTargetJitAbi>
39+
40+
<AndroidSupportedTargetJitAbi
41+
Include="x86"
42+
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86:')) ">
43+
<ApiLevel>$(AndroidNdkApiLevel_X86)</ApiLevel>
44+
<AndroidRID>android-x86</AndroidRID>
45+
<SupportMonoVM>True</SupportMonoVM>
46+
<SupportCoreCLR>False</SupportCoreCLR>
47+
<SupportNativeAOT>False</SupportNativeAOT>
48+
</AndroidSupportedTargetJitAbi>
49+
50+
<AndroidSupportedTargetJitAbi
51+
Include="x86_64"
52+
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':x86_64:')) ">
53+
<ApiLevel>$(AndroidNdkApiLevel_X86_64)</ApiLevel>
54+
<AndroidRID>android-x64</AndroidRID>
55+
<SupportMonoVM>True</SupportMonoVM>
56+
<SupportCoreCLR>True</SupportCoreCLR>
57+
<SupportNativeAOT>True</SupportNativeAOT>
58+
</AndroidSupportedTargetJitAbi>
59+
</ItemGroup>
60+
</Project>

build-tools/scripts/Ndk.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<ProjitemsFile>$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\Ndk.projitems</ProjitemsFile>
4+
<ProjitemsFile>$(MSBuildThisFileDirectory)Ndk.projitems</ProjitemsFile>
55
</PropertyGroup>
66
<Import
77
Project="$(ProjitemsFile)"

build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static partial class Defaults
122122
/// ABIs that support the NativeAOT runtime. Used to determine which ABIs
123123
/// need the higher API-level CRT/sysroot files in the NativeAOT runtime pack.
124124
/// When adding a new ABI here, also update <c>SupportNativeAOT</c> in
125-
/// <c>build-tools/scripts/Ndk.projitems.in</c>.
125+
/// <c>build-tools/scripts/Ndk.projitems</c>.
126126
/// </summary>
127127
public static readonly HashSet<string> NativeAotSupportedAbis = new (StringComparer.Ordinal) {
128128
"arm64-v8a",

build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ protected override async Task<bool> Execute (Context context)
6666
Get_Configuration_Generated_Props (context),
6767
Get_Cmake_XA_Build_Configuration (context),
6868
Get_Cmake_Presets (context),
69-
Get_Ndk_projitems (context),
7069
Get_XABuildConfig_cs (context),
7170
};
7271
}
@@ -230,30 +229,6 @@ static string GetMinor (string value)
230229
}
231230
}
232231

233-
GeneratedFile Get_Ndk_projitems (Context context)
234-
{
235-
const string OutputFileName = "Ndk.projitems";
236-
237-
var replacements = new Dictionary<string, string> (StringComparer.Ordinal) {
238-
{ "@NDK_RELEASE@", BuildAndroidPlatforms.AndroidNdkVersion },
239-
{ "@NDK_PKG_REVISION@", BuildAndroidPlatforms.AndroidNdkPkgRevision },
240-
{ "@NDK_ARMEABI_V7_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString () },
241-
{ "@NDK_ARMEABI_V7_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
242-
{ "@NDK_ARM64_V8A_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
243-
{ "@NDK_ARM64_V8A_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
244-
{ "@NDK_X86_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString () },
245-
{ "@NDK_X86_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
246-
{ "@NDK_X86_64_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
247-
{ "@NDK_X86_64_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
248-
};
249-
250-
return new GeneratedPlaceholdersFile (
251-
replacements,
252-
Path.Combine (Configurables.Paths.BuildToolsScriptsDir, $"{OutputFileName}.in"),
253-
Path.Combine (Configurables.Paths.BuildBinDir, OutputFileName)
254-
);
255-
}
256-
257232
public GeneratedFile Get_SourceLink_Json (Context context)
258233
{
259234
if (gitSubmodules == null || xaCommit == null) {

src/native/common/libunwind/libunwind-xamarin.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<_ConfigureLibUnwindCommands
1818
Include="@(AndroidSupportedTargetJitAbi)">
1919
<Command>$(CmakePath)</Command>
20-
<Arguments>$(_CmakeAndroidFlags) -DANDROID_NATIVE_API_LEVEL=%(AndroidSupportedTargetJitAbi.ApiLevelNET) -DANDROID_PLATFORM=android-%(AndroidSupportedTargetJitAbi.ApiLevelNET) -DANDROID_ABI=%(AndroidSupportedTargetJitAbi.Identity) -DANDROID_RID=%(AndroidSupportedTargetJitAbi.AndroidRID) -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.AndroidRID)" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.AndroidRID)" -DCMAKE_BUILD_TYPE=$(Configuration) -DLIBUNWIND_SOURCE_DIR="$(LibUnwindSourceFullPath)" -DLIBUNWIND_LIBRARY_NAME="$(_LibUnwindBaseLibName)" -DLIBUNWIND_OUTPUT_DIR="@(AndroidSupportedTargetJitAbi->'$(OutputPath)/%(AndroidRID)')" -DLIBUNWIND_HEADERS_OUTPUT_DIR="$(_LibUnwindHeadersOutputDir)" $(MSBuildThisFileDirectory)</Arguments>
20+
<Arguments>$(_CmakeAndroidFlags) -DANDROID_NATIVE_API_LEVEL=%(AndroidSupportedTargetJitAbi.ApiLevel) -DANDROID_PLATFORM=android-%(AndroidSupportedTargetJitAbi.ApiLevel) -DANDROID_ABI=%(AndroidSupportedTargetJitAbi.Identity) -DANDROID_RID=%(AndroidSupportedTargetJitAbi.AndroidRID) -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.AndroidRID)" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$(OutputPath)%(AndroidSupportedTargetJitAbi.AndroidRID)" -DCMAKE_BUILD_TYPE=$(Configuration) -DLIBUNWIND_SOURCE_DIR="$(LibUnwindSourceFullPath)" -DLIBUNWIND_LIBRARY_NAME="$(_LibUnwindBaseLibName)" -DLIBUNWIND_OUTPUT_DIR="@(AndroidSupportedTargetJitAbi->'$(OutputPath)/%(AndroidRID)')" -DLIBUNWIND_HEADERS_OUTPUT_DIR="$(_LibUnwindHeadersOutputDir)" $(MSBuildThisFileDirectory)</Arguments>
2121
<WorkingDirectory>$(IntermediateOutputPath)%(AndroidSupportedTargetJitAbi.Identity)-$(Configuration)</WorkingDirectory>
2222
</_ConfigureLibUnwindCommands>
2323
</ItemGroup>

0 commit comments

Comments
 (0)