-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Xamarin.Android.Build.Tasks] <GenerateJavaStubs/> improvements #2956
[Xamarin.Android.Build.Tasks] <GenerateJavaStubs/> improvements #2956
Conversation
It doesn't immediately make sense, but this change seems to have broken ~every on-device
Looks like the |
83ad888
to
cc63e5a
Compare
I went through the `_GenerateJavaStubs` MSBuild target and the `<GenerateJavaStubs/>` MSBuild task. There was an "easy" win to improve incremental build performance. I also made a few other general improvements to `<GenerateJavaStubs/>`. ~~ Inputs & Outputs ~~ `_GenerateJavaStubs` has `Inputs` of: Inputs="$(MSBuildAllProjects);@(_ResolvedAssemblies);$(_AndroidManifestAbs);$(_AndroidBuildPropertiesCache);@(_AndroidResourceDest)" Lets say a NetStandard assembly changes, such as a XAML change in a Xamarin.Forms app. In this case `_GenerateJavaStubs` does not actually need to run again. We can use `@(_ResolvedUserMonoAndroidAssemblies)` as an input instead of `@(_ResolvedAssemblies)`. This is the biggest win--to skip this target completely. ~~ selectedWhitelistAssemblies ~~ `ManifestDocument` had the concept of a "whitelist" assembly, which currently consisted of a single assembly: internal static readonly string [] FrameworkAttributeLookupTargets = {"Mono.Android.GoogleMaps.dll"}; `Mono.Android.GoogleMaps.dll` no longer exists, so I was able to remove a bit of code that still used that dead codepath. ~~ Typemaps ~~ Just a couple minor improvements here: * Fixed the usage of the `[Obsolete]` constructor for `TypeNameMapGenerator`. Using a `(TaskLevel level, string value)` callback instead. * I reused the `MemoryStream` and got rid of the `UpdateWhenChanged` method. ~~ Tests ~~ I updated the `IncrementalBuildTest.ProduceReferenceAssembly` test quite a bit: * The library project using `$(ProduceReferenceAssembly)` is now a NetStandard library. * I check all the targets that should be skipped from now on. I made a few changes in `Xamarin.ProjectTools` to clean things up: * The `DotNetStandard` class should just define `Language=XamarinAndroidProjectLanguage.CSharp` by default. * Added a `ShouldRestorePackageReferences` property for deciding if we pass `/restore` or not. * The `DotNetStandard` class always needs to use `/restore`, even if there are no `PackageReferences`. * I moved a couple methods from `DotNetXamarinProject` to `XamarinProject` so the `DotNetStandard` has them. ~~ Results ~~ Testing the Xamarin.Forms project in this repo. A fresh build I wasn't able to see a noticeable improvement. *However*, an incremental build with XAML-change: Before: 861 ms _GenerateJavaStubs 1 calls After: n/a The target is skipped now: _GenerateJavaStubs: Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files. Overall this seems to be ~800ms better for incremental builds with XAML changes.
cc63e5a
to
afe6f32
Compare
I think the macOS failures are OK:
It seems like the "adb crashed" thing happened. |
I went through the
_GenerateJavaStubs
MSBuild target and the<GenerateJavaStubs/>
MSBuild task. There was an "easy" win toimprove incremental build performance. I also made a few other general
improvements to
<GenerateJavaStubs/>
.Inputs & Outputs
_GenerateJavaStubs
hasInputs
of:Lets say a NetStandard assembly changes, such as a XAML change in a
Xamarin.Forms app. In this case
_GenerateJavaStubs
does not actuallyneed to run again.
We can use
@(_ResolvedUserMonoAndroidAssemblies)
as an input insteadof
@(_ResolvedAssemblies)
.This is the biggest win--to skip this target completely.
selectedWhitelistAssemblies
ManifestDocument
had the concept of a "whitelist" assembly, whichcurrently consisted of a single assembly:
Mono.Android.GoogleMaps.dll
no longer exists, so I was able toremove a bit of code that still used that dead codepath.
Typemaps
Just a couple minor improvements here:
[Obsolete]
constructor forTypeNameMapGenerator
. Using a(TaskLevel level, string value)
callback instead.
MemoryStream
and got rid of theUpdateWhenChanged
method.
Tests
I updated the
IncrementalBuildTest.ProduceReferenceAssembly
testquite a bit:
$(ProduceReferenceAssembly)
is now aNetStandard library.
I made a few changes in
Xamarin.ProjectTools
to clean things up:DotNetStandard
class should just defineLanguage=XamarinAndroidProjectLanguage.CSharp
by default.ShouldRestorePackageReferences
property for deciding if wepass
/restore
or not.DotNetStandard
class always needs to use/restore
, even ifthere are no
PackageReferences
.DotNetXamarinProject
toXamarinProject
so theDotNetStandard
has them.Results
Testing the Xamarin.Forms project in this repo. A fresh build I wasn't
able to see a noticeable improvement.
However, an incremental build with XAML-change:
The target is skipped now:
Overall this seems to be ~800ms better for incremental builds with
XAML changes.