Skip to content

Commit e3d708c

Browse files
[BaseTasks] fix \-delimited paths on macOS (#122)
Tests in xamarin-android have started failing with: libfoo.so : error XA4301: Cannot determine ABI of native library 'libfoo.so'. Move this file to a directory with a valid Android ABI name such as 'libs/armeabi-v7a/'. Where the test in question sets `Link=x86\libfoo.so`: https://github.com/xamarin/xamarin-android/blob/bf63c3d116b38459678cb3aefd2f5826e78c385e/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs#L115 This only fails on macOS and works fine on Windows. I didn't consider this case in 90d7621. I've added test cases for `\`, and added a `string.Replace()` that should solve the problem on macOS. I added test cases for `null` input as well. Co-authored-by: Jonathan Pryor <[email protected]>
1 parent bdcf899 commit e3d708c

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public static class AndroidRidAbiHelper
1818

1919
public static string GetNativeLibraryAbi (string lib)
2020
{
21+
if (string.IsNullOrEmpty (lib))
22+
return null;
23+
lib = lib.Replace ('\\', Path.DirectorySeparatorChar);
24+
2125
// The topmost directory the .so file is contained within
2226
var dir = Directory.GetParent (lib);
2327
var dirName = dir.Name.ToLowerInvariant ();

tests/Microsoft.Android.Build.BaseTasks-Tests/AndroidRidAbiHelperTests.cs

+39-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ namespace Microsoft.Android.Build.BaseTasks.Tests
1010
public class AndroidRidAbiHelperTests
1111
{
1212
static object [] StringValueSource = new object [] {
13+
new[] {
14+
/* input */ default (string),
15+
/* expected */ default (string)
16+
},
17+
new[] {
18+
/* input */ "",
19+
/* expected */ default
20+
},
1321
new[] {
1422
/* input */ "armeabi-v7a/libfoo.so",
1523
/* expected */ "armeabi-v7a"
@@ -65,7 +73,15 @@ public class AndroidRidAbiHelperTests
6573
new[] {
6674
/* input */ "packages/sqlitepclraw.lib.e_sqlite3.android/1.1.11/runtimes/android-arm64/native/libe_sqlite3.so",
6775
/* expected */ "arm64-v8a"
68-
}
76+
},
77+
new[] {
78+
/* input */ "arm64-v8a\\libfoo.so",
79+
/* expected */ "arm64-v8a"
80+
},
81+
new[] {
82+
/* input */ "android-arm64\\libfoo.so",
83+
/* expected */ "arm64-v8a"
84+
},
6985
};
7086

7187
[Test]
@@ -76,6 +92,12 @@ public void StringValue (string input, string expected)
7692
}
7793

7894
static object [] ITaskItemValueSource = new object [] {
95+
new object [] {
96+
/* input */
97+
new TaskItem(""),
98+
/* expected */
99+
default (string)
100+
},
79101
new object [] {
80102
/* input */
81103
new TaskItem("armeabi-v7a/libfoo.so"),
@@ -130,6 +152,22 @@ public void StringValue (string input, string expected)
130152
/* expected */
131153
"armeabi-v7a"
132154
},
155+
new object [] {
156+
/* input */
157+
new TaskItem("liblinkwin.so", new Dictionary<string,string> {
158+
{ "Link", "x86_64\\libfoo.so" }
159+
}),
160+
/* expected */
161+
"x86_64"
162+
},
163+
new object [] {
164+
/* input */
165+
new TaskItem("liblinkwin.so", new Dictionary<string,string> {
166+
{ "Link", "android-arm64\\libfoo.so" },
167+
}),
168+
/* expected */
169+
"arm64-v8a",
170+
},
133171
};
134172

135173
[Test]

0 commit comments

Comments
 (0)