diff --git a/src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs b/src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs index 8e6cce4..01aef16 100644 --- a/src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs +++ b/src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs @@ -18,6 +18,10 @@ public static class AndroidRidAbiHelper public static string GetNativeLibraryAbi (string lib) { + if (string.IsNullOrEmpty (lib)) + return null; + lib = lib.Replace ('\\', Path.DirectorySeparatorChar); + // The topmost directory the .so file is contained within var dir = Directory.GetParent (lib); var dirName = dir.Name.ToLowerInvariant (); diff --git a/tests/Microsoft.Android.Build.BaseTasks-Tests/AndroidRidAbiHelperTests.cs b/tests/Microsoft.Android.Build.BaseTasks-Tests/AndroidRidAbiHelperTests.cs index bb241cb..f2db030 100644 --- a/tests/Microsoft.Android.Build.BaseTasks-Tests/AndroidRidAbiHelperTests.cs +++ b/tests/Microsoft.Android.Build.BaseTasks-Tests/AndroidRidAbiHelperTests.cs @@ -10,6 +10,14 @@ namespace Microsoft.Android.Build.BaseTasks.Tests public class AndroidRidAbiHelperTests { static object [] StringValueSource = new object [] { + new[] { + /* input */ default (string), + /* expected */ default (string) + }, + new[] { + /* input */ "", + /* expected */ default + }, new[] { /* input */ "armeabi-v7a/libfoo.so", /* expected */ "armeabi-v7a" @@ -65,7 +73,15 @@ public class AndroidRidAbiHelperTests new[] { /* input */ "packages/sqlitepclraw.lib.e_sqlite3.android/1.1.11/runtimes/android-arm64/native/libe_sqlite3.so", /* expected */ "arm64-v8a" - } + }, + new[] { + /* input */ "arm64-v8a\\libfoo.so", + /* expected */ "arm64-v8a" + }, + new[] { + /* input */ "android-arm64\\libfoo.so", + /* expected */ "arm64-v8a" + }, }; [Test] @@ -76,6 +92,12 @@ public void StringValue (string input, string expected) } static object [] ITaskItemValueSource = new object [] { + new object [] { + /* input */ + new TaskItem(""), + /* expected */ + default (string) + }, new object [] { /* input */ new TaskItem("armeabi-v7a/libfoo.so"), @@ -130,6 +152,22 @@ public void StringValue (string input, string expected) /* expected */ "armeabi-v7a" }, + new object [] { + /* input */ + new TaskItem("liblinkwin.so", new Dictionary { + { "Link", "x86_64\\libfoo.so" } + }), + /* expected */ + "x86_64" + }, + new object [] { + /* input */ + new TaskItem("liblinkwin.so", new Dictionary { + { "Link", "android-arm64\\libfoo.so" }, + }), + /* expected */ + "arm64-v8a", + }, }; [Test]