Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Prowl.Editor/Build/DesktopBuildPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,20 @@ public static void Initialize()
? new[] { ".dylib", "" }
: new[] { ".so", ".so.1", "" };

string[] nameVariants = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? new[] { libraryName }
: new[] { libraryName, "lib" + libraryName };

foreach (var r in rids)
{
string nativeSubDir = string.IsNullOrEmpty(r)
? Path.Combine("runtimes", "native")
: Path.Combine("runtimes", r, "native");

foreach (var name in nameVariants)
foreach (var ext in exts)
{
string fullPath = Path.Combine(baseDir, nativeSubDir, libraryName + ext);
string fullPath = Path.Combine(baseDir, nativeSubDir, name + ext);
Log($"[Native] Probing: {fullPath}");

if (File.Exists(fullPath))
Expand All @@ -371,9 +376,10 @@ public static void Initialize()
}

// Fallback to root directory
foreach (var name in nameVariants)
foreach (var ext in exts)
{
string rootPath = Path.Combine(baseDir, libraryName + ext);
string rootPath = Path.Combine(baseDir, name + ext);
Log($"[Native] Root probe: {rootPath}");
if (File.Exists(rootPath) && NativeLibrary.TryLoad(rootPath, out IntPtr handle))
{
Expand Down Expand Up @@ -416,15 +422,20 @@ public static IntPtr ResolveNativeLibrary(string libraryName, Assembly assembly,
? new[] { ".dylib", "" }
: new[] { ".so", ".so.1", "" };

string[] nameVariants = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? new[] { libraryName }
: new[] { libraryName, "lib" + libraryName };

foreach (var r in rids)
{
string nativeSubDir = string.IsNullOrEmpty(r)
? Path.Combine("runtimes", "native")
: Path.Combine("runtimes", r, "native");

foreach (var name in nameVariants)
foreach (var ext in exts)
{
string fullPath = Path.Combine(baseDir, nativeSubDir, libraryName + ext);
string fullPath = Path.Combine(baseDir, nativeSubDir, name + ext);
Log($"[Native] Probing: {fullPath}");

if (File.Exists(fullPath))
Expand All @@ -443,9 +454,10 @@ public static IntPtr ResolveNativeLibrary(string libraryName, Assembly assembly,
}

// Last chance: root directory
foreach (var name in nameVariants)
foreach (var ext in exts)
{
string rootPath = Path.Combine(baseDir, libraryName + ext);
string rootPath = Path.Combine(baseDir, name + ext);
if (File.Exists(rootPath) && NativeLibrary.TryLoad(rootPath, out IntPtr handle))
{
Log($"[Native] SUCCESS from root: {rootPath}");
Expand Down
Loading