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

Make typemap dump utility work with current libxamarin-app.so #8694

Merged
merged 10 commits into from
Feb 14, 2024

Conversation

grendello
Copy link
Contributor

@grendello grendello commented Feb 1, 2024

Update the tools/tmt utility to support the current format of typemaps in libxamarin-app.so

Also, the utility now generates a nicely formatted Markdown report file instead of the
crude text file output previously.

Doesn't work yet.
* main:
  [monodroid] typemaps may need to load assemblies (#8625)
  Bump $(AndroidNetPreviousVersion) to 34.0.79 (#8693)
  Bump to xamarin/java.interop/main@07c73009 (#8681)
* main:
  [Mono.Android] Cache `Profiles/api-34.xml` contents (#8679)
@grendello grendello marked this pull request as ready for review February 6, 2024 15:36
@grendello grendello requested a review from jonpryor as a code owner February 6, 2024 15:36
@jonpryor
Copy link
Member

jonpryor commented Feb 9, 2024

@grendello: should we also add a unit test/integration test wherein we use tmt to process a .apk built by the repo? As a way to "require" changes to tmt whenever the typemap format changes? (So that we don't break things in the future?)

@grendello
Copy link
Contributor Author

@jonpryor not at this time. I plan to remodel the whole thing, create a single library to handle the tasks of extraction+decompression of assemblies, typemap reader and some sort of libxamarin-app.so correctness/sanity checker. When that library exists, it will be much easier to add all kinds of unit tests.

@jonpryor
Copy link
Member

While trying to write up a "more thorough" commit message, I tested this PR out, and…either it's not working like I'd expect, or something broke, or…?

% ./dotnet-local.sh build tools/tmt/*.csproj
% ./dotnet-local.sh build -c Release samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj
% bin/Debug/bin/tmt samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/*-Signed.apk
samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/com.xamarin.android.helloworld-Signed.apk!lib/arm64-v8a/libxamarin-app.so:
[W] Assembly Mono.Android cannot be found
[W] Assembly HelloWorld.DotNet cannot be found
[W] Assembly HelloLibrary.DotNet cannot be found
# …wat?
  File Type: Xamarin App Release DSO
  Format version: 2
  Map kind: Release
  Map architecture: ARM64
  Managed to Java entries: 56
  Java to Managed entries: 46 (without duplicates)

…

The assemblies can't be found? Which might explain the contents of e.g. typemap-v2-Release-X86_64.md:

Java to Managed

Java type name Managed type name Type token ID Is Generic? MVID
android/app/Activity token id: 33554498, Mono.Android 0x02000042 (33554498) no 295b9b42-2fe4-4f36-af9c-fbc69503ecb6

None of the entries in the "Managed type name" column contain a type name. They're almost all `token id: …`, Mono.Android, with a couple [name unknown], Mono.Android for good measure.

Meanwhile, decompress-assemblies sees them!

% ./dotnet-local.sh build tools/decompress-assemblies/*.csproj
% ./bin/Debug/bin/decompress-assemblies samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/*-Signed.apk
Processing samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/com.xamarin.android.helloworld-Signed.apk!arm64_v8a/System.Private.CoreLib.dll
  uncompressed to: uncompressed-com.xamarin.android.helloworld-Signed/arm64_v8a/System.Private.CoreLib.dll
…
Processing samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/com.xamarin.android.helloworld-Signed.apk!Mono.Android.dll
  uncompressed to: uncompressed-com.xamarin.android.helloworld-Signed/Mono.Android.dll
…

The inability to print the Managed type name means that the output is "useless", in that I still would need to manually read the typemaps.*.ll files to know what the typemaps are.

@jonpryor
Copy link
Member

Draft commit message:

Context: 46f10fe0a5196d1187b704cf945214295c09ccd3
Context? 68368189d67c46ddbfed4e90e622f635c4aff11e

`tools/tmt` (46f10fe0) is a utility to print typemap entries contained
within an application.

`tools/tmt` no longer supports dumping typemap entries; it was
possibly broken in 68368189:

	% ./dotnet-local.sh build tools/tmt/*.csproj
	% ./dotnet-local.sh build -c Release samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj
	% bin/Debug/bin/tmt samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/*-Signed.apk
	No type maps found in 'samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/com.xamarin.android.helloworld-Signed.apk'

Update the `tools/tmt` utility to support the current format of
typemaps within `libxamarin-app.so`:

	% bin/Debug/bin/tmt samples/HelloWorld/HelloWorld/bin/Release/net9.0-android/*-Signed.apk
	TODO: correct output?
	TODO: where is typemap data located?  Looks like it's in *.raw & *.md.

Also, the utility now generates a nicely formatted Markdown report
file instead of the crude text file output previously.

* main:
  [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)
@jonpryor jonpryor merged commit 71b6fcc into main Feb 14, 2024
47 checks passed
@jonpryor jonpryor deleted the dev/grendel/tmt-fix branch February 14, 2024 19:00
grendello added a commit that referenced this pull request Feb 14, 2024
* main:
  [tmt] Update to work with current `libxamarin-app.so` (#8694)
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)
  ...
grendello added a commit that referenced this pull request Feb 15, 2024
* main:
  Bump to xamarin/Java.Interop/main@b8f6f88 (#8718)
  [Microsoft.Android.Sdk.ILLink] remove Java.Interop.Export reference (#8719)
  [tmt] Update to work with current `libxamarin-app.so` (#8694)
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 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.

2 participants