[Mono.Android] Support API-O Rebuilds #579
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.
Rebuilding API-O (571546a) results in a build failure:
The cause of the build error is that
Android.Content.IComponentCallbacks.cs-- among many other files --is specified twice (!):
This in turn is related to 98880bd: There are two "environments" in
which
Mono.Android.csprojis built:In the clean environment,
Mono.Android.projitems-- created bygenerator.exein the_GenerateBindingtarget -- does not exist.Consequently, after
generator.exeis run, all of the generated$(IntermediateOutputPath)\**\*.csfiles are added to@(Compile)sothat the compiler will "see" all of the generated files and things
will build.
In the previously built environment,
Mono.Android.projitemsdoesexist, and is
<Import/>ed. The_GenerateBindingtarget isskipped, "preventing" the
@(Compile)group from being updated tocontain the generated files -- which is desirable, because those files
are already listed in
Mono.Android.projitems, and including themwould result in "duplicating" the files provided to the compiler.
Note that the
_GenerateBindingtarget depends on the_GenerateApiDescriptiontarget, so that when_GenerateApiDescriptioncreates anapi.xmlfile, then_GenerateBindingwill re-execute.This is where API-O rebuilds go wrong:
Mono.Android.projitems(1) exists, and (2) is<Import/>ed._GenerateApiDescriptionalways executes (!)._GenerateBindingalways executing, causing the@(Compile)group to be updated, resulting filenames beingprovided to the compiler twice.
(2) is where things go bad:
Specifically,
_GenerateApiDescriptionlisted as anInputthe fileProfiles\api-$(AndroidApiLevel).xml.in. However, commit 571546anamed the API-O binding
Profiles\api-O.xml.in, meaningProfiles\api-26.xml.indoes not exist, and won't exist (untilAPI-26 is actually released as "stable" by Google, at some unknown
point in the future).
Which is why API-O rebuilds fail. :-)
The fix? Don't use
$(AndroidApiLevel), use$(AndroidPlatformId).For API-O,
$(AndroidPlatformId)will have the value "O", allowingProfiles\api-O.xml.into be found, preventing_GenerateApiDescriptionfrom unnecessarily executing.This scenario does raise a potential (unresolved) workflow problem:
when:
Mono.Android.csprojis built, andProfiles\api-*.xml.inis modified, andMono.Android.csprojis built again,then everything will break in the same manner as described here:
Mono.Android.projitemswill exist, thus adding generated files to@(Compile), then the_GenerateApiDescription&_GenerateBindingtargets will execute, re-adding files to
@(Compile), and things willbreak.
A subsequent rebuild will "fix" the error, so long as a
Profiles\api-*.xml.infile isn't modified, but this will be annoyingto anyone who encounters it.