From e7df0567e92ff003d56eb959f3c4efed933a571b Mon Sep 17 00:00:00 2001 From: diogob003 Date: Sun, 26 May 2024 18:24:26 -0300 Subject: [PATCH] GLibrary.cs: additional MacPorts fallback lib path Improve #1 MacOS support May fix issues #78 and #249 --- CakeScripts/TargetEnvironment.cake | 11 ++++++++++- Source/Libs/Shared/GLibrary.cs | 12 ++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CakeScripts/TargetEnvironment.cake b/CakeScripts/TargetEnvironment.cake index 811351fae..f355b21ef 100644 --- a/CakeScripts/TargetEnvironment.cake +++ b/CakeScripts/TargetEnvironment.cake @@ -36,7 +36,16 @@ class TargetEnvironment } else if (OperatingSystem.IsMacOS()) { - DotNetInstallPath = "/usr/local/share/dotnet"; + string[] PotentialPath = {"/usr/local/share/dotnet", "/opt/local/share/dotnet", "/opt/homebrew/share/dotnet"}; + + foreach ( var Path in PotentialPath ) + { + if (D.Exists(Path)) + { + DotNetInstallPath = Path; + break; + } + } } } diff --git a/Source/Libs/Shared/GLibrary.cs b/Source/Libs/Shared/GLibrary.cs index bbff16249..580abf046 100644 --- a/Source/Libs/Shared/GLibrary.cs +++ b/Source/Libs/Shared/GLibrary.cs @@ -69,13 +69,13 @@ static bool TryGet(Library library, out IntPtr ret) ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][0]); } } else if (FuncLoader.IsOSX) { - ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][2]); + string[] libPath = {"", "/usr/local/lib/", "/opt/local/lib/", "/opt/homebrew/lib/"}; - if (ret == IntPtr.Zero) { - ret = FuncLoader.LoadLibrary("/usr/local/lib/" + _libraryDefinitions[library][2]); - if (ret == IntPtr.Zero) { - ret = FuncLoader.LoadLibrary("/opt/homebrew/lib/" + _libraryDefinitions[library][2]); - } + foreach ( string path in libPath ) { + ret = FuncLoader.LoadLibrary(path + _libraryDefinitions[library][2]); + + if (ret != IntPtr.Zero) + break; } } else ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][1]);