[Build] Add Inputs/Outputs to _GenerateCompressedAssembliesNativeSourceFiles#11188
[Build] Add Inputs/Outputs to _GenerateCompressedAssembliesNativeSourceFiles#11188jonathanpeppers wants to merge 4 commits intomainfrom
_GenerateCompressedAssembliesNativeSourceFiles#11188Conversation
…ceFiles Add Inputs/Outputs to the _GenerateCompressedAssembliesNativeSourceFiles target so it is skipped on incremental builds when no assemblies have changed. This saves ~143ms on every no-change rebuild. - Inputs: @(_ResolvedUserAssemblies);@(_ResolvedFrameworkAssemblies) - Outputs: @(_CompressedAssembliesAssemblySource) (the .ll files) Also update BasicApplicationRepetitiveBuild to assert the target is skipped on a no-change rebuild. Co-authored-by: Copilot <[email protected]>
…Files Include $(_AndroidBuildPropertiesCache) (build.props) so that changes to build properties like Debug or EnableCompression also trigger a rebuild. Co-authored-by: Copilot <[email protected]>
The task uses Files.CopyIfStreamChanged which preserves the old timestamp when content is unchanged. Without Touch, MSBuild would always see inputs newer than outputs and re-run the target. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds MSBuild incremental build semantics to _GenerateCompressedAssembliesNativeSourceFiles so it can be skipped on no-change rebuilds, and updates an incremental build test to assert the skip behavior.
Changes:
- Add
Inputs/Outputsto_GenerateCompressedAssembliesNativeSourceFilesinXamarin.Android.Common.targets. - Update
BasicApplicationRepetitiveBuildto assert_GenerateCompressedAssembliesNativeSourceFilesis skipped on a no-change rebuild.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Adds MSBuild incremental inputs/outputs to avoid re-running compressed-assemblies native source generation on unchanged builds. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs | Adds an assertion that the target is skipped on the second build. |
| Assert.IsTrue ( | ||
| b.Output.IsTargetSkipped ("_Sign"), | ||
| "the _Sign target should not run"); | ||
| b.Output.AssertTargetIsSkipped ("_GenerateCompressedAssembliesNativeSourceFiles"); |
There was a problem hiding this comment.
AssertTargetIsSkipped ("_GenerateCompressedAssembliesNativeSourceFiles") is unconditional, but _GenerateCompressedAssembliesNativeSourceFiles is conditioned out when runtime == AndroidRuntime.NativeAOT. If the NativeAOT build path doesn’t invoke the target (and therefore doesn’t emit a “skipped” message), this assertion will fail. Consider guarding the assertion to non-NativeAOT runtimes, or pass defaultIfNotUsed: true for the NativeAOT case.
| b.Output.AssertTargetIsSkipped ("_GenerateCompressedAssembliesNativeSourceFiles"); | |
| if (runtime != AndroidRuntime.NativeAOT) { | |
| b.Output.AssertTargetIsSkipped ("_GenerateCompressedAssembliesNativeSourceFiles"); | |
| } |
The compressed assemblies task uses EnableCompression to change its output, so toggling this property must invalidate build.props to trigger a rebuild. Co-authored-by: Copilot <[email protected]>
|
Ok, this breaks things, due to: I would say we should finish trimmable type map, which removes |
Description
_GenerateCompressedAssembliesNativeSourceFilestook 147ms on anincremental build because it had no
Inputs/Outputs— it ran everytime regardless of whether any assemblies changed.
This PR adds:
@(_ResolvedUserAssemblies);@(_ResolvedFrameworkAssemblies);$(_AndroidBuildPropertiesCache)@(_CompressedAssembliesAssemblySource)(the.llfiles,already populated by
_PrepareNativeAssemblySourceItems)This should prevent the target from running on a build with no changes.
Also updates
BasicApplicationRepetitiveBuildto assert the target isskipped on a no-change rebuild.