Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Fixes: dotnet/android#5432

Two cases currently do not work in .NET 6:

  1. An Android app project includes files such as:

    android-arm/libfoo.so
    android-arm64/libfoo.so
    android-x86/libfoo.so
    android-x64/libfoo.so

It would be nice if users could use $(RuntimeIdentifier) names
here. We can simply check if the directory name is a RID.

  1. A NuGet package includes a native library from a path such as:

    packages/sqlitepclraw.lib.e_sqlite3.android/1.1.11/runtimes/android-arm64/native/libe_sqlite3.so

In this case, there is no %(RuntimeIdentifier) item metadata on this
native library. So we will have to check if the following is a RID:

Directory.GetParent (lib.ItemSpec).Parent.Name

I implemented these two cases as last resort to the existing logic.

I think this will be fine for the behavior to be in "legacy"
Xamarin.Android as well as .NET 6.

I added tests for AndroidRidAbiHelper, since we had none before.

Fixes: dotnet/android#5432

Two cases currently do not work in .NET 6:

1) An Android app project includes files such as:

    android-arm/libfoo.so
    android-arm64/libfoo.so
    android-x86/libfoo.so
    android-x64/libfoo.so

It would be nice if users could use `$(RuntimeIdentifier)` names
here. We can simply check if the directory name is a RID.

2) A NuGet package includes a native library from a path such as:

    packages/sqlitepclraw.lib.e_sqlite3.android/1.1.11/runtimes/android-arm64/native/libe_sqlite3.so

In this case, there is no `%(RuntimeIdentifier)` item metadata on this
native library. So we will have to check if the following is a RID:

    Directory.GetParent (lib.ItemSpec).Parent.Name

I implemented these two cases as last resort to the existing logic.

I think this will be fine for the behavior to be in "legacy"
Xamarin.Android as well as .NET 6.

I added tests for `AndroidRidAbiHelper`, since we had none before.
@jonathanpeppers
Copy link
Member Author

/cc @mattleibow

@jonpryor jonpryor merged commit 90d7621 into dotnet:main Jun 4, 2021
@jonathanpeppers jonathanpeppers deleted the dotnet-native-library-rid-abi branch June 4, 2021 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[One .NET] improve native library ABI detection at build time

3 participants