From e853b5048388b98b4d40566978c082264f28f282 Mon Sep 17 00:00:00 2001 From: ndr0n <58706017+ndr0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:25:57 +0000 Subject: [PATCH] Added support for Windows / Linux and OSX server builds --- Runtime/LLMLib.cs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Runtime/LLMLib.cs b/Runtime/LLMLib.cs index 945b3a88..1ccc9eee 100644 --- a/Runtime/LLMLib.cs +++ b/Runtime/LLMLib.cs @@ -133,11 +133,11 @@ public static IntPtr LoadLibrary(string libraryName) throw new ArgumentNullException(nameof(libraryName)); IntPtr handle; - if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) + if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsServer) handle = Win32.LoadLibrary(libraryName); - else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer) + else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer || Application.platform == RuntimePlatform.LinuxServer) handle = Linux.dlopen(libraryName); - else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) + else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXServer) handle = Mac.dlopen(libraryName); else if (Application.platform == RuntimePlatform.Android) handle = Android.dlopen(libraryName); @@ -159,11 +159,11 @@ public static IntPtr GetSymbol(IntPtr library, string symbolName) throw new ArgumentNullException(nameof(symbolName)); IntPtr handle; - if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) + if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsServer) handle = Win32.GetProcAddress(library, symbolName); - else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer) + else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer || Application.platform == RuntimePlatform.LinuxServer) handle = Linux.dlsym(library, symbolName); - else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) + else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXServer) handle = Mac.dlsym(library, symbolName); else if (Application.platform == RuntimePlatform.Android) handle = Android.dlsym(library, symbolName); @@ -182,11 +182,11 @@ public static void FreeLibrary(IntPtr library) if (library == IntPtr.Zero) return; - if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) + if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsServer) Win32.FreeLibrary(library); - else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer) + else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer || Application.platform == RuntimePlatform.LinuxServer) Linux.dlclose(library); - else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) + else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXServer) Mac.dlclose(library); else if (Application.platform == RuntimePlatform.Android) Android.dlclose(library); @@ -416,8 +416,8 @@ public void Destroy() public static List PossibleArchitectures(bool gpu = false) { List architectures = new List(); - if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || - Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer) + if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsServer || + Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer || Application.platform == RuntimePlatform.LinuxServer) { if (gpu) { @@ -475,11 +475,11 @@ public static List PossibleArchitectures(bool gpu = false) public static string GetArchitectureCheckerPath() { string filename; - if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) + if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsServer) { filename = $"windows-archchecker/archchecker.dll"; } - else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer) + else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer || Application.platform == RuntimePlatform.LinuxServer) { filename = $"linux-archchecker/libarchchecker.so"; } @@ -498,15 +498,15 @@ public static string GetArchitectureCheckerPath() public static string GetArchitecturePath(string arch) { string filename; - if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) + if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsServer) { filename = $"windows-{arch}/undreamai_windows-{arch}.dll"; } - else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer) + else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer || Application.platform == RuntimePlatform.LinuxServer) { filename = $"linux-{arch}/libundreamai_linux-{arch}.so"; } - else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) + else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXServer) { filename = $"macos-{arch}/libundreamai_macos-{arch}.dylib"; }