Skip to content
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

[Mono.Android] Commit api-34.xml instead of generating it on every build. #8679

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Jan 25, 2024

Today, we recalculate the api.xml for Mono.Android API-34 on every build.

This involves:

  • Installing Android SDK platforms 23 - 34 (2.2 GB)
  • Running class-parse on every API level
  • Running api-xml-adjuster on every API level
  • Running api-merge to merge every level into a single api.xml

However, the output ~never changes, as the Android API should not change once it has shipped. Thus, we can save disk space and build time by committing a completed api.xml instead of rebuilding it.

Additionally, xaprepare no longer installs all Android SDK Platforms by default. Instead it defaults to only installing the latest stable version and any unstable preview version(s). New value all has been added to the supported -android-sdk-platforms= command line argument to request all platforms be installed instead.

Updated the HowTo: Add a new Android API Level document to instruct how to generate a new api.xml.

This saves:

  • ~1 minute on the Mac Build (where all platform SDKs are already installed because we reuse CI agents)
  • ~16 minutes on Windows Builds with fresh CI agents (where we previously had to download all the platform SDKs)

@jpobst jpobst force-pushed the store-api-xml branch 2 times, most recently from 703179a to b8fc1c4 Compare January 26, 2024 18:09
@jpobst jpobst marked this pull request as ready for review January 26, 2024 23:21
@grendello
Copy link
Contributor

@jpobst I don't think there's a point in compressing the xml and committing a zip. Git already compresses its payload and so committing a ZIP may actually affect git's own performance. Not to mention that every change to the archive in the future will be awkward , since we will have a diff of a ZIP archive, not of the XML file. Git compression may even give better results than ZIP in shrinking the actual storage of the file in the .git directory. On disk the XML will be bigger, of course, but we will also save time by not having to unzip it on every build.

On my installation, git uses level 9 for its compression algorithm:

$ git config --get core.compression
9

@@ -98,7 +98,6 @@

<!-- Merges various 'api-X.xml.in' files into single 'api.xml' file -->
<Target Name="_GenerateApiDescription"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a naming convention I think we could remove the _ prefix now that this target is "public", and should be called directly from command line rather than running automatically as part of the build.

Copy link
Member

@pjcollins pjcollins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment but otherwise LGTM. I'm also not sure about updating $(AndroidJavaRuntimeApiLevel) though and will defer to @grendello or @jonpryor for that.

@@ -22,7 +22,7 @@
<_StandardLibraryPath Condition=" '$(TargetFrameworkVersion)' == '' ">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries('.NETFramework', 'v4.7.2', ''))</_StandardLibraryPath>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' And '$(_StandardLibraryPath)' != '' ">v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' ">v4.7.1</TargetFrameworkVersion>
<AndroidJavaRuntimeApiLevel Condition="'$(AndroidJavaRuntimeApiLevel)' == ''">26</AndroidJavaRuntimeApiLevel>
<AndroidJavaRuntimeApiLevel Condition="'$(AndroidJavaRuntimeApiLevel)' == ''">34</AndroidJavaRuntimeApiLevel>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use $(AndroidLatestStableApiLevel) here instead, to avoid having to update this every year?

@jonpryor jonpryor merged commit 0c495de into main Feb 6, 2024
47 checks passed
@jonpryor jonpryor deleted the store-api-xml branch February 6, 2024 02:38
grendello added a commit that referenced this pull request Feb 6, 2024
* main:
  [Mono.Android] Cache `Profiles/api-34.xml` contents (#8679)
grendello added a commit that referenced this pull request Feb 6, 2024
* main:
  [Mono.Android] Cache `Profiles/api-34.xml` contents (#8679)
grendello added a commit that referenced this pull request Feb 7, 2024
* main:
  Bump to dotnet/installer@fb7b9a4b9e 9.0.100-preview.2.24106.6 (#8700)
  [Mono.Android] Cache `Profiles/api-34.xml` contents (#8679)
  [monodroid] typemaps may need to load assemblies (#8625)
  Bump $(AndroidNetPreviousVersion) to 34.0.79 (#8693)
  Bump to xamarin/java.interop/main@07c73009 (#8681)
  Bump to dotnet/installer@1c496970b7 9.0.100-preview.2.24078.1 (#8685)
  [GetAndroidDependencies] Add Jdk dependency info (#8651)
  [xaprepare] Add support for newer SparkyLinux (#8684)
grendello added a commit that referenced this pull request Feb 14, 2024
* main: (116 commits)
  [tmt] Update to work with current `libxamarin-app.so` (#8694)
  [Xamarin.Android.Build.Tasks] remove `$(AndroidSupportedAbis)` from `build.props` (#8717)
  [Xamarin.Android.Build.Tasks] BannedApiAnalyzers for Resolve() (#8715)
  Bump to xamarin/Java.Interop/main@dfcbd670 (#8714)
  [monodroid] C++ tweaks and legacy code cleanup (#8638)
  Bump to xamarin/xamarin-android-tools/main@a698a33 (#8710)
  [readme] Add `d17-8` download links. (#8709)
  Bump external/Java.Interop from `07c7300` to `7f08b77` (#8702)
  Bump to xamarin/monodroid@848d1277b7 (#8691)
  [Xamarin.Android.Build.Tasks] `FixAbstractMethodsStep` performance (#8650)
  Bump to dotnet/installer@fb7b9a4b9e 9.0.100-preview.2.24106.6 (#8700)
  [Mono.Android] Cache `Profiles/api-34.xml` contents (#8679)
  [monodroid] typemaps may need to load assemblies (#8625)
  Bump $(AndroidNetPreviousVersion) to 34.0.79 (#8693)
  Bump to xamarin/java.interop/main@07c73009 (#8681)
  Bump to dotnet/installer@1c496970b7 9.0.100-preview.2.24078.1 (#8685)
  [GetAndroidDependencies] Add Jdk dependency info (#8651)
  [xaprepare] Add support for newer SparkyLinux (#8684)
  Bump to dotnet/installer@5680e93cb2 9.0.100-preview.2.24073.12 (#8666)
  $(AndroidPackVersionSuffix)=preview.2; net9 is 34.99.0.preview.2 (#8678)
  ...
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants