[api-xml-adjuster] Don't needlessly rebuild XML #1531
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit e3abe4b broke caching of the
bin/Build$(Configuration)/api/api-*.xml.*files, reintroducing thescenario that commit 5c46ee3 fixed. The result is that minutes may
be spent needlessly re-generating API XML.
The cause of the breakage is that
@(_ApiParameterDescription)(introduced in e3abe4b) will contain entries that we don't care
about, e.g. API-4, for which no longer generate bindings. As such, the
_ClassParsetarget Inputs were looking for files which will neverexist, thus causing the
_ClassParsetarget to always execute.This could be fixed by making
@(_ApiParameterDescription)/etc.entries conditional on on the file
%(_ApiParameterDescription.ParameterDescription)refers to actuallyexisting, a'la:
However, this is suboptimal, as it means everything must still be
rebuilt if only one file changes:
What we really want is MSBuild Target Batching, but our use of
item groups without item metadata prevents target batching!
Which leads to a realization: the rationalization for commit e3abe4b
was incomplete: The problem wasn't using metadata within Target Inputs
and Outputs; the problem was intermixing strings with metadata.
Meaning the pre-e3abe4b8
api-xml-adjuster.targetswas correct(except for the bit about it mentioning files which didn't exist,
causing needless rebuilds):
vs. what e3abe4b was attempting to fix:
Reviewing e3abe4b,
api-xml-adjuster.targetsis the only file thatwas already properly using item medata within Target Inputs & Outputs.
Fix
class-parse.exeandapi-xml-adjuster.exerebuilds by properlyusing MSBuild Target Batching, and by filtering
@(ApiFileDefinition)so that it only contains values for which wehave a
src/Mono.Android/Profiles/api-*.params.txtfile.With these changes in place, single-file rebuilds are much faster: