-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tmt] Update to work with current
libxamarin-app.so
(#8694)
Context: 46f10fe Context? 6836818 `tools/tmt` (46f10fe) is a utility to print typemap entries contained within an application. `tools/tmt` no longer supports dumping typemap entries; it was possibly broken in 6836818: % ./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`, and update it to generate nicely formatted Markdown report files instead of the text file output: % 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: 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) … `typemap-v2-Release-ARM64.md` will be created (among other files) which contains the actual typemap data, in Markdown tabular form: > # Java to Managed > | Java type name | Managed type name | Type token ID | Is Generic? | MVID | > | -------------------------------------------------- | ---------------------------------------------------------------- | --------------------- | ---------------- | ------------------------------------ | > | android/app/Activity | Android.App.Activity, Mono.Android | 0x02000042 (33554498) | no | 33da2efb-61bb-4fd5-b529-2dee309a3d65 | > … > | java/lang/Object | Java.Lang.Object, Mono.Android | 0x0200008B (33554571) | no | 33da2efb-61bb-4fd5-b529-2dee309a3d65 | > … > # Managed to Java > | Managed type name | Java type name | Type token ID | Is Generic? | Is Duplicate? | MVID | > | ----------------------------------------------------------------------- | -------------------------------------------------- | --------------------- | ----------- | ------------- | ------------------------------------ | > | HelloLibrary.LibraryActivity, HelloLibrary.DotNet | mono/samples/hello/LibraryActivity | 0x02000002 (33554434) | no | false | ca140934-068f-47d0-a861-6179233e49aa | > …
- Loading branch information
Showing
25 changed files
with
2,470 additions
and
722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Xamarin.Android.Build.Tasks/Utilities/TypeMapHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.IO.Hashing; | ||
using System.Text; | ||
|
||
namespace Xamarin.Android.Tasks; | ||
|
||
static class TypeMapHelper | ||
{ | ||
/// <summary> | ||
/// Hash the given Java type name for use in java-to-managed typemap array. | ||
/// </summary> | ||
public static ulong HashJavaName (string name, bool is64Bit) | ||
{ | ||
if (name.Length == 0) { | ||
return UInt64.MaxValue; | ||
} | ||
|
||
// Native code (EmbeddedAssemblies::typemap_java_to_managed in embedded-assemblies.cc) will operate on wchar_t cast to a byte array, we need to do | ||
// the same | ||
return HashBytes (Encoding.Unicode.GetBytes (name), is64Bit); | ||
} | ||
|
||
static ulong HashBytes (byte[] bytes, bool is64Bit) | ||
{ | ||
if (is64Bit) { | ||
return XxHash64.HashToUInt64 (bytes); | ||
} | ||
|
||
return (ulong)XxHash32.HashToUInt32 (bytes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.