Repository navigation
[build] Copy NDK redistributables when creating runtime packs - #12494
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cbf40b05-e7fb-454f-a214-feb9a301ae95
There was a problem hiding this comment.
Pull request overview
This PR refactors how Android NDK redistributable assets are sourced for runtime pack creation, removing the configuration-local “redist” staging directory created during make prepare and instead selecting/copying the needed NDK files directly from $(AndroidNdkDirectory) when producing runtime packs and runtime-pack NuGets.
Changes:
- Removes
_CopyNdkRedistributablesfrom Android SDK provisioning and deletes the unused_RuntimeRedistDirNameproperty. - Introduces a reusable
_AndroidGetNdkRedistributablestarget and extendsAndroidSupportedTargetJitAbimetadata to support selecting the right NDK files per RID. - Updates runtime pack directory population and runtime-pack NuGet packing to consume
@(_AndroidNdkRedistributable)directly.
Show a summary per file
| File | Description |
|---|---|
| src/native/native.targets | Uses _AndroidGetNdkRedistributables and copies NDK redistributables directly into local unpacked runtime packs. |
| src/androidsdk/androidsdk.targets | Stops copying NDK redistributables during SDK install/provisioning (make prepare). |
| Configuration.props | Removes the now-unused _RuntimeRedistDirName property and imports NDK build script definitions. |
| build-tools/scripts/Ndk.targets | Adds _AndroidGetNdkRedistributables to compute the per-RID NDK redistributable file list. |
| build-tools/scripts/Ndk.projitems | Adds NDK toolchain metadata (prefix/arch/unwind dir) to AndroidSupportedTargetJitAbi items. |
| build-tools/create-packs/Microsoft.Android.Runtime.proj | Packs NDK system/toolchain assets directly from @(_AndroidNdkRedistributable) when building runtime-pack NuGets. |
Review details
Suppressed comments (1)
src/native/native.targets:379
- 💡 suggestion performance —
_CopyToPackDirsperforms a largeCopyinto the local packs directory but still has noInputs/Outputs, so MSBuild will consider it out-of-date on every build. Since this target is in theBuilddependency chain, it can add noticeable overhead even whenSkipUnchangedFiles="true". Consider making it incremental (e.g., move input item computation to a helper...Inputstarget and use a stamp file output).
<Target Name="_CopyToPackDirs"
DependsOnTargets="_AndroidGetNdkRedistributables">
<PropertyGroup>
<_RuntimePackName Condition=" '$(CMakeRuntimeFlavor)' == 'MonoVM' ">Mono</_RuntimePackName>
<_RuntimePackName Condition=" '$(CMakeRuntimeFlavor)' == 'CoreCLR' ">CoreCLR</_RuntimePackName>
<_RuntimePackName Condition=" '$(CMakeRuntimeFlavor)' == 'NativeAOT' ">NativeAOT</_RuntimePackName>
</PropertyGroup>
<ItemGroup>
<_RuntimePackFiles Include="$(OutputPath)\%(AndroidSupportedTargetJitAbi.AndroidRID)\*"
AndroidRID="%(AndroidSupportedTargetJitAbi.AndroidRID)"
AndroidRuntime="$(CMakeRuntimeFlavor)"
RuntimePackName="$(_RuntimePackName)" />
<_RuntimePackFiles Include="@(_AndroidNdkRedistributable)"
Condition=" '%(_AndroidNdkRedistributable.Kind)' == 'System' "
AndroidRID="%(_AndroidNdkRedistributable.AndroidRID)"
AndroidRuntime="$(CMakeRuntimeFlavor)"
RuntimePackName="$(_RuntimePackName)" />
</ItemGroup>
<ItemGroup Condition=" '$(CMakeRuntimeFlavor)' == 'CoreCLR' Or '$(CMakeRuntimeFlavor)' == 'NativeAOT' ">
<_RuntimePackFiles Include="@(_AndroidNdkRedistributable)"
Condition=" '%(_AndroidNdkRedistributable.Kind)' == 'Toolchain' "
AndroidRID="%(_AndroidNdkRedistributable.AndroidRID)"
AndroidRuntime="$(CMakeRuntimeFlavor)"
RuntimePackName="$(_RuntimePackName)" />
</ItemGroup>
<Copy
SourceFiles="%(_RuntimePackFiles.Identity)"
DestinationFolder="$(MicrosoftAndroidPacksRootDir)Microsoft.Android.Runtime.%(_RuntimePackFiles.RuntimePackName).$(AndroidApiLevel).%(_RuntimePackFiles.AndroidRID)\$(AndroidPackVersion)\runtimes\%(_RuntimePackFiles.AndroidRID)\native"
SkipUnchangedFiles="true" />
</Target>
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
✅ LGTM
The refactoring preserves the previous per-runtime payload while removing the redundant NDK staging copy. ABI-specific metadata and runtime filtering are wired consistently across local unpacked packs and NuGet runtime packs, and CI is green across all 45 checks.
Findings: 0 errors · 0 warnings · 1 suggestion
Generated by Android PR Reviewer for #12494 · gpt56 · 118.6 AIC · ⌖ 21.1 AIC · ⊞ 25.7K
Comment /review to run again
Context
make preparecurrently copies selected Android NDK files intobin/<Configuration>/lib/runtimes/redist, even though those files are only consumed when producing runtime packs. This creates an approximately 58 MB configuration- and checkout-local staging directory in every prepared worktree.The NDK itself is already stored in the shared Android toolchain directory, so the intermediate copy is unnecessary.
Changes
_CopyNdkRedistributablesfrom Android SDK provisioning.AndroidSupportedTargetJitAbi._AndroidGetNdkRedistributablestarget.$(AndroidNdkDirectory)into local unpacked runtime packs.Mono runtime packs receive the five Android system-library stubs. CoreCLR and NativeAOT runtime packs additionally receive the CRT objects, libc++, compiler-rt, and libunwind, preserving the existing payload.
Validation
make preparesucceeds without creatingbin/Debug/lib/runtimes/redist._AndroidGetNdkRedistributablesselects 44 existing files: 11 for each supported RID.make allsucceeds.android-arm64Mono and CoreCLR NuGet runtime packs build successfully and contain the expected files underruntimes/android-arm64/native.