-
Notifications
You must be signed in to change notification settings - Fork 529
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
Properly Detect & Handle Musl Systems #1657
Changes from 1 commit
3037ecc
b0b7596
4364a3f
08810d1
8b6e573
d5ecc56
624fb2a
c6c31ea
ed541a3
164a7f5
9506288
d068e57
c9ccdf1
2df2e5a
6ccc082
c34ba02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ namespace HarfBuzzSharp | |
namespace SkiaSharp | ||
#endif | ||
{ | ||
internal static class PlatformConfiguration | ||
public static class PlatformConfiguration | ||
{ | ||
public static bool IsUnix { get; } | ||
|
||
|
@@ -50,18 +50,20 @@ static PlatformConfiguration () | |
Is64Bit = IntPtr.Size == 8; | ||
} | ||
|
||
public static bool? IsMuslOverride { get; set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically there are other libc implementations, so I'd suggest to have something like enum LibcFlavor
{
Glibc,
Musl
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so I changed the whole way of selecting a variant/flavor. There is now a property If the property is null, then I just do the basic glibc/musl check - or rather I check for glibc and assume musl otherwise. If a specific flavor is set, then I do nothing and just use that. This is just a plain string that allows for extension later on, and also is just the name of the folder to use. Example usage would be on a x64 machine:
Since this is totally customizable, you can even do specific checks for versions and set the flavor to |
||
|
||
#if WINDOWS_UWP | ||
public static bool IsMusl { get; } | ||
#else | ||
private static readonly Lazy<bool> isMuslLazy = new Lazy<bool>(IsMuslImplementation); | ||
private static readonly Lazy<bool> isMuslLazy = new Lazy<bool> (IsMuslImplementation); | ||
|
||
public static bool IsMusl => IsLinux && isMuslLazy.Value; | ||
public static bool IsMusl => IsLinux && (IsMuslOverride ?? isMuslLazy.Value); | ||
|
||
private static bool IsMuslImplementation() | ||
private static bool IsMuslImplementation () | ||
{ | ||
try | ||
{ | ||
gnu_get_libc_version(); | ||
gnu_get_libc_version (); | ||
return false; | ||
} | ||
catch (TypeLoadException) | ||
|
@@ -70,8 +72,8 @@ private static bool IsMuslImplementation() | |
} | ||
} | ||
|
||
[DllImport("libc", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] | ||
private static extern IntPtr gnu_get_libc_version(); | ||
[DllImport ("c", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] | ||
private static extern IntPtr gnu_get_libc_version (); | ||
#endif | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattleibow apparently this throws DllNotFoundException on a somewhat clean Ubuntu 20.04 installation