Skip to content

Commit 550f5b0

Browse files
committed
Add suffixes and prefixes to library loader
1 parent 45cfee8 commit 550f5b0

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/FRC-Utilities/FRC-Utilities.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<PropertyGroup>
2828
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2929
<WarningsAsErrors />
30-
<Version>3.0.2</Version>
30+
<Version>3.0.3</Version>
3131
</PropertyGroup>
3232

3333
<ItemGroup>

src/FRC-Utilities/NativeLibraryUtilities/NativeLibraryLoader.cs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,34 @@ public bool TryLoadNativeLibraryPath(string libraryName)
181181
throw new InvalidOperationException(
182182
"OS type is unknown. Must use the overload to manually load the file");
183183

184-
ILibraryLoader loader = osType switch
184+
ILibraryLoader loader;
185+
186+
switch (osType)
185187
{
186-
OsType.Windows32 => new WindowsLibraryLoader(),
187-
OsType.Windows64 => new WindowsLibraryLoader(),
188-
OsType.Linux32 => new LinuxLibraryLoader(),
189-
OsType.Linux64 => new LinuxLibraryLoader(),
190-
OsType.MacOs32 => new MacOsLibraryLoader(),
191-
OsType.MacOs64 => new MacOsLibraryLoader(),
192-
_ => new EmbeddedLibraryLoader()
193-
};
188+
case OsType.Windows32:
189+
case OsType.Windows64:
190+
loader = new WindowsLibraryLoader();
191+
libraryName = $"{libraryName}.dll";
192+
break;
193+
case OsType.Linux32:
194+
case OsType.Linux64:
195+
loader = new LinuxLibraryLoader();
196+
libraryName = $"lib{libraryName}.so";
197+
break;
198+
case OsType.MacOs32:
199+
case OsType.MacOs64:
200+
loader = new MacOsLibraryLoader();
201+
libraryName = $"lib{libraryName}.dylib";
202+
break;
203+
case OsType.LinuxArmhf:
204+
case OsType.LinuxRaspbian:
205+
case OsType.roboRIO:
206+
loader = new EmbeddedLibraryLoader();
207+
libraryName = $"lib{libraryName}.so";
208+
break;
209+
default:
210+
throw new InvalidOperationException("Unknown OS type?");
211+
}
194212

195213
bool wasLoaded = loader.TryLoadLibrary(libraryName);
196214
if (wasLoaded)

0 commit comments

Comments
 (0)