Skip to content

[xaprepare] Check in Ndk.projitems, remove generator#11733

Open
jonathanpeppers wants to merge 5 commits into
mainfrom
jonathanpeppers-checkin-ndk-projitems
Open

[xaprepare] Check in Ndk.projitems, remove generator#11733
jonathanpeppers wants to merge 5 commits into
mainfrom
jonathanpeppers-checkin-ndk-projitems

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Jun 24, 2026

Copy link
Copy Markdown
Member

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.inNdk.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.

Mirrors PR #11608 which checked in Mono.Android.Apis.projitems.

Convert `build-tools/scripts/Ndk.projitems.in` into a checked-in
`build-tools/scripts/Ndk.projitems` with the `@NDK_*@` placeholders
resolved from the current constants in BuildAndroidPlatforms.cs, and
remove the `Get_Ndk_projitems` generator from xaprepare.

- Point `Ndk.targets` at the new static, in-tree location.
- Delete `Get_Ndk_projitems` and its dispatch entry in Step_GenerateFiles.cs.
- The NDK constants in BuildAndroidPlatforms.cs are left intact; they are
  still consumed by Get_XABuildConfig_cs and the cmake presets generator.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 18:53
Instead of hardcoding the NDK version (28c), pkg revision (28.2.13676358)
and minimum API level (24) -- which duplicated values already defined in
Configuration.props -- source them from $(_XAAndroidNdkRelease),
$(_XAAndroidNdkPkgRevision) and $(AndroidMinimumDotNetApiLevel). Those are
all set before Configuration.props imports Ndk.targets, so the projitems
file no longer needs to be kept in sync on an NDK/API bump.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the xaprepare cleanup by checking in build-tools/scripts/Ndk.projitems as a static file and removing the Get_Ndk_projitems generator path from Step_GenerateFiles, so builds no longer regenerate a file whose contents only change on NDK bumps.

Changes:

  • Check in a resolved build-tools/scripts/Ndk.projitems (NDK 28c / pkg rev 28.2.13676358 / min API 24) and stop generating it at prepare time.
  • Update build-tools/scripts/Ndk.targets to import the in-tree projitems instead of bin/Build$(Configuration)/....
  • Remove the Get_Ndk_projitems generator method/dispatch and update related documentation references.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs Removes the Ndk.projitems generation step from the xaprepare file-generation list.
build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs Updates doc comment to point at the checked-in projitems file.
build-tools/scripts/Ndk.targets Imports Ndk.projitems from the scripts directory instead of from bin/Build$(Configuration).
build-tools/scripts/Ndk.projitems Adds the resolved, checked-in projitems file that defines NDK version/pkg revision and ABI metadata.
Comments suppressed due to low confidence (2)

build-tools/scripts/Ndk.targets:8

  • Ndk.projitems is now checked in, so the Exists(...) condition on the <Import> can hide a missing/incorrect checkout and lead to confusing downstream MSBuild errors (the items/properties would just not be defined). Consider removing the condition so the build fails fast if the file is missing.
    <ProjitemsFile>$(MSBuildThisFileDirectory)Ndk.projitems</ProjitemsFile>
  </PropertyGroup>
  <Import
      Project="$(ProjitemsFile)"
      Condition="Exists('$(ProjitemsFile)')"/>

build-tools/scripts/Ndk.projitems:6

  • The header comment says to update API-level values when changing NdkMinimumAPI/NdkMinimumAPILegacy32 in BuildAndroidPlatforms.cs, but those values are actually sourced from $(AndroidMinimumDotNetApiLevel) (Configuration.props). To avoid future mismatches, the comment should point at Configuration.props for API-level changes (and at BuildAndroidPlatforms.cs for NDK version/revision).

jonathanpeppers and others added 3 commits June 24, 2026 14:16
The legacy 32-bit minimum API level used to be lower than the .NET minimum
API level, but they are identical now (both $(AndroidMinimumDotNetApiLevel)).

Remove the two redundant per-ABI properties that nothing else references --
AndroidNdkApiLevel_Arm (armeabi-v7a .NET) and AndroidNdkApiLevel_X86_Legacy
(x86 legacy) -- and point each item's ApiLevel/ApiLevelNET metadata at the
single remaining per-ABI property. The arm64-v8a and x86_64 properties are
left in place since shipped targets (Build.Tasks.targets, Common.props.in,
NativeAOT.targets) still consume them by name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ApiLevelNET was the minimum API level for .NET (.NET 6+) Android, as
opposed to the legacy Xamarin.Android (Mono) ApiLevel. Those values used to
differ but are identical now, and the repo is .NET-only.

The only consumer of the ApiLevelNET metadata was libunwind-xamarin.targets;
point it at ApiLevel instead and drop the now-redundant ApiLevelNET metadata
from all four AndroidSupportedTargetJitAbi items in Ndk.projitems. The
resolved value (24) is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants