mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-22 19:45:34 +00:00
Improve OS detection (fixes #14)
This commit is contained in:
parent
eec217a5c5
commit
441ed4b897
|
@ -30,12 +30,37 @@ class FuncLoader
|
|||
public static extern IntPtr dlsym(IntPtr handle, string symbol);
|
||||
}
|
||||
|
||||
private static bool IsWindows, IsOSX;
|
||||
[DllImport("libc")]
|
||||
private static extern int uname(IntPtr buf);
|
||||
|
||||
public static bool IsWindows, IsOSX;
|
||||
|
||||
static FuncLoader()
|
||||
{
|
||||
IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
IsOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
switch (Environment.OSVersion.Platform)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.Win32S:
|
||||
case PlatformID.Win32Windows:
|
||||
case PlatformID.WinCE:
|
||||
IsWindows = true;
|
||||
break;
|
||||
case PlatformID.MacOSX:
|
||||
IsOSX = true;
|
||||
break;
|
||||
case PlatformID.Unix:
|
||||
try
|
||||
{
|
||||
var buf = Marshal.AllocHGlobal(8192);
|
||||
if (uname(buf) == 0 && Marshal.PtrToStringAnsi(buf) == "Darwin")
|
||||
IsOSX = true;
|
||||
|
||||
Marshal.FreeHGlobal(buf);
|
||||
}
|
||||
catch { }
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static IntPtr LoadLibrary(string libname)
|
||||
|
|
|
@ -47,9 +47,9 @@ class GLibrary
|
|||
var i = _libdict.Find((e) => e.Library == library);
|
||||
var s = i.LinuxLib;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (FuncLoader.IsWindows)
|
||||
s = i.WindowsLib;
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
else if (FuncLoader.IsOSX)
|
||||
s = i.OSXLib;
|
||||
|
||||
_libraries[library] = ret = FuncLoader.LoadLibrary(s);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// VARS
|
||||
|
||||
Settings.Cake = Context;
|
||||
Settings.Version = "3.22.24.28";
|
||||
Settings.Version = "3.22.24.29";
|
||||
Settings.BuildTarget = Argument("BuildTarget", "Default");
|
||||
Settings.Assembly = Argument("Assembly", "");
|
||||
|
||||
|
|
Loading…
Reference in a new issue