Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧Bug not finding native libs #374

Merged
merged 23 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5075d9c
Start work for issue #373
CalvinWilkinson Jan 22, 2025
b6c6f29
chore: remove unnecessary types.
CalvinWilkinson Jan 22, 2025
c0d2507
fix: change how to get the app dir path
CalvinWilkinson Jan 22, 2025
13f93b2
fix: change how the native lib loader resolves dir path
CalvinWilkinson Jan 22, 2025
b285f84
cleanup: remove unneeded method
CalvinWilkinson Jan 22, 2025
4b7603a
config: update proj to copy native win lib to output dir
CalvinWilkinson Jan 22, 2025
44fdb6b
bug: adjust how the application directory is constructed
CalvinWilkinson Jan 27, 2025
8859601
chore: improve native library loader
CalvinWilkinson Jan 27, 2025
9f7ce7d
refactor: improve platform code
CalvinWilkinson Jan 27, 2025
bd8579b
bug: change how the openal native library is loaded
CalvinWilkinson Jan 27, 2025
d199fbc
test: copy the native windows library to the output directory
CalvinWilkinson Jan 27, 2025
754c1bc
chore: change the location of the native libraries
CalvinWilkinson Jan 27, 2025
566895b
BREAKING CHANGE: Removed 32bit (x86) support
CalvinWilkinson Jan 27, 2025
4299803
chore: fix tests and improve audio class implementation
CalvinWilkinson Jan 27, 2025
efc355d
chore: improve testing app
CalvinWilkinson Jan 27, 2025
03896e9
config: cleanup proj file
CalvinWilkinson Jan 27, 2025
6e6ce0d
ide: add word to dictionary for rider users
CalvinWilkinson Jan 27, 2025
0003efa
refactor: move application class code to assembly code
CalvinWilkinson Jan 27, 2025
47a1344
test: create tests to check for null params
CalvinWilkinson Jan 27, 2025
1392b9c
test: create tests for native library loader class
CalvinWilkinson Jan 27, 2025
5e9b2bc
cicd: remove if logic from job steps
CalvinWilkinson Jan 27, 2025
6af98e2
ide: add words to dictionary for vscode users
CalvinWilkinson Jan 27, 2025
5cf762b
config: revert version back to original value
CalvinWilkinson Jan 27, 2025
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
2 changes: 0 additions & 2 deletions .github/workflows/sync-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set Up Deno
if: startsWith(github.ref_name, 'feature/')
uses: denoland/setup-deno@v1
with:
deno-version: ${{ vars.DENO_VERSION }}

- name: Run Sync Bot (Issue Change)
if: startsWith(github.ref_name, 'feature/')
run: |
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH}}/sync-bot-status-check.ts";

Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"cobertura",
"Codecov",
"csharpsquid",
"demilestoned",
"editorconfig",
"ethomson",
"gitattributes",
"ibrary",
"Kinson",
"kinsondigital",
"milestoned",
"msbuild",
"nint",
"nsubstitute",
Expand Down
28 changes: 14 additions & 14 deletions CASL.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WorkFlows", "WorkFlows", "{
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Debug|x64 = Debug|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Release|Any CPU.Build.0 = Release|Any CPU
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Release|Any CPU.Build.0 = Release|Any CPU
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Release|Any CPU.Build.0 = Release|Any CPU
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Release|x64.ActiveCfg = Release|x64
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Release|x64.Build.0 = Release|x64
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Debug|x64.ActiveCfg = Debug|x64
{B62B38C5-0DFF-46A0-B95A-D613F366040D}.Debug|x64.Build.0 = Debug|x64
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Release|x64.ActiveCfg = Release|x64
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Release|x64.Build.0 = Release|x64
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Debug|x64.ActiveCfg = Debug|x64
{1DC6781C-60A4-478A-9FCF-AB23A9CF111A}.Debug|x64.Build.0 = Debug|x64
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Release|x64.ActiveCfg = Release|x64
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Release|x64.Build.0 = Release|x64
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Debug|x64.ActiveCfg = Debug|x64
{2F67B7C0-7BA4-4EDD-8B0C-38793A3DE77C}.Debug|x64.Build.0 = Debug|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions CASL.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private $OBJECT_TYPE$ CreateSystemUnderTest()
<s:Boolean x:Key="/Default/UserDictionary/Words/=ative/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bufferi/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=CASL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=cicd/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=csharpsquid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ctor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=directivity/@EntryIndexedValue">True</s:Boolean>
Expand Down
18 changes: 0 additions & 18 deletions CASL/Application.cs

This file was deleted.

15 changes: 1 addition & 14 deletions CASL/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace CASL;
using Devices;
using Exceptions;
using Factories;
using NativeInterop;
using OpenAL;
using ReactableData;

Expand All @@ -33,7 +32,6 @@ public class Audio : IAudio
private readonly IAudioBuffer audioBuffer;
private readonly IPath path;
private readonly IFile file;
private readonly IPlatform platform;
private uint srcId;
private bool isDisposed;
private bool audioDeviceChanging;
Expand Down Expand Up @@ -66,7 +64,6 @@ public Audio(string filePath, BufferType bufferType)

BufferType = bufferType;

this.platform = IoC.Container.GetInstance<IPlatform>();
this.alInvoker = IoC.Container.GetInstance<IOpenALInvoker>();
this.alInvoker.ErrorCallback += ErrorCallback;

Expand Down Expand Up @@ -96,7 +93,6 @@ public Audio(string filePath, BufferType bufferType)
/// Initializes a new instance of the <see cref="Audio"/> class.
/// </summary>
/// <param name="filePath">The path to the audio file.</param>
/// <param name="platform">Provides platform specific information.</param>
/// <param name="bufferType">The type of audio buffer used.</param>
/// <param name="alInvoker">Provides access to OpenAL.</param>
/// <param name="audioManager">Manages audio device related operations.</param>
Expand All @@ -119,7 +115,6 @@ public Audio(string filePath, BufferType bufferType)
[SuppressMessage("csharpsquid", "S107", Justification = "Not part of the public API.")]
internal Audio(
string filePath,
IPlatform platform,
BufferType bufferType,
IOpenALInvoker alInvoker,
IAudioDeviceManager audioManager,
Expand All @@ -129,7 +124,6 @@ internal Audio(
IFile file)
{
ArgumentException.ThrowIfNullOrEmpty(filePath);
ArgumentNullException.ThrowIfNull(platform);
ArgumentNullException.ThrowIfNull(alInvoker);
ArgumentNullException.ThrowIfNull(audioManager);
ArgumentNullException.ThrowIfNull(bufferFactory);
Expand All @@ -139,7 +133,6 @@ internal Audio(

BufferType = bufferType;

this.platform = platform;
this.alInvoker = alInvoker;
this.alInvoker.ErrorCallback += ErrorCallback;

Expand Down Expand Up @@ -481,13 +474,7 @@ private void Init(string filePath)
throw new AudioException(exMsg);
}

FilePath = filePath.TrimAllFromEnd(this.path.DirectorySeparatorChar)
.TrimAllFromEnd(this.path.AltDirectorySeparatorChar);

if (this.platform.IsWinPlatform())
{
FilePath = filePath.Replace(this.path.AltDirectorySeparatorChar, this.path.DirectorySeparatorChar);
}
FilePath = filePath;

if (!this.file.Exists(filePath))
{
Expand Down
20 changes: 6 additions & 14 deletions CASL/CASL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<AssemblyVersion>1.0.0</AssemblyVersion>
<ApplicationIcon>casl-logo.ico</ApplicationIcon>
<StartupObject />
<Configurations>Debug;Release</Configurations>
<Configurations>Release;Debug</Configurations>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Authors>Kinson Digital Team</Authors>
<Description>CASL is a simplistic cross-platform, .NET library for playing and managing audio powered by OpenAL 1.1 using software rendering.</Description>
Expand All @@ -31,6 +31,7 @@
<PackageIcon>casl-logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<NoWarn>CS7035</NoWarn>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand All @@ -40,19 +41,12 @@
</ItemGroup>

<ItemGroup>
<Compile Remove="OpenAL\libs\**" />
<EmbeddedResource Remove="OpenAL\libs\**" />
<None Remove="OpenAL\libs\**" />
<None Include="..\README.md" Pack="true" PackagePath="\" />
<None Include="..\Images\casl-logo.ico" Pack="true" PackagePath="\" />
<None Include="..\Images\casl-logo.png" Pack="true" PackagePath="\" />
<None Include="..\LICENSE.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<None Remove="stylecop.json" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="stylecop.json" />
</ItemGroup>
Expand All @@ -73,16 +67,14 @@
<PackageReference Include="System.IO.Abstractions" Version="21.0.29" />
</ItemGroup>

<!--ADD STUFF TO WINDOWS NUGET PACKAGE-->
<!--TODO: CREATE A WINDOW SPECIFIC SOLUTION AND PROJECT CONFIGS-->
<Target Name="AddNativeWindowLibsToNugetPackage" AfterTargets="Build" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU' Or '$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<!--ADD NATIVE LIBS TO THE NUGET PACKAGE-->
<Target Name="AddNativeWindowLibsToNugetPackage" AfterTargets="Build">
<ItemGroup>
<!--WINDOWS-->
<Content Include="$(ProjectDir)OpenAL\libs\win-x86\*.dll" Pack="true" PackagePath="\runtimes\win-x86\native" />
<Content Include="$(ProjectDir)OpenAL\libs\win-x64\*.dll" Pack="true" PackagePath="\runtimes\win-x64\native" />
<Content Include="$(ProjectDir)NativeLibs/win-x64/*.dll" Pack="true" PackagePath="/runtimes/win-x64/native" />

<!--LINUX-->
<Content Include="$(ProjectDir)OpenAL\libs\linux-x64\*.so*" Pack="true" PackagePath="\runtimes\linux-x64\native" />
<Content Include="$(ProjectDir)NativeLibs/linux-x64/*.so*" Pack="true" PackagePath="/runtimes/linux-x64/native" />
</ItemGroup>
</Target>

Expand Down
5 changes: 5 additions & 0 deletions CASL/DotnetWrappers/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace CASL.DotnetWrappers;

using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.Loader;

/// <inheritdoc cref="IAssembly"/>
Expand All @@ -20,6 +21,7 @@ internal sealed class Assembly : IAssembly, IDisposable
/// </summary>
public Assembly()
{
this.Location = AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar);
var assembly = System.Reflection.Assembly.GetExecutingAssembly();

ArgumentNullException.ThrowIfNull(assembly);
Expand All @@ -32,6 +34,9 @@ public Assembly()
/// <inheritdoc/>
public event Action? Unloading;

/// <inheritdoc/>
public string Location { get; }

/// <inheritdoc cref="IDisposable.Dispose"/>
public void Dispose() => Dispose(true);

Expand Down
5 changes: 5 additions & 0 deletions CASL/DotnetWrappers/IAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ internal interface IAssembly
/// Occurs when the assembly is unloading.
/// </summary>
event Action Unloading;

/// <summary>
/// Gets the file path of the current assembly.
/// </summary>
string Location { get; }
}
17 changes: 0 additions & 17 deletions CASL/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ namespace CASL;
/// </summary>
internal static class ExtensionMethods
{
// TODO: Need to exchange these with the path api versions
private const char WinDirSeparatorChar = '\\';
private const char CrossPlatDirSeparatorChar = '/';

/// <summary>
/// Registers that a new instance of <typeparamref name="TImplementation"/> will be returned every time
/// a <typeparamref name="TService"/> is requested (transient).
Expand Down Expand Up @@ -120,19 +116,6 @@ public static string[] ToStrings(this nint strPtr)
return result.ToArray();
}

// TODO: refactor usages of this method and remove the method
/// <summary>
/// Converts the given <paramref name="path"/> to a cross-platform path.
/// </summary>
/// <param name="path">Manages file paths.</param>
/// <returns>The cross-platform version of the <paramref name="path"/>.</returns>
/// <returns>
/// This changes all '\' characters to '/' characters.
/// The '/' directory separator is valid on Windows and Linux systems.
/// </returns>
public static string ToCrossPlatPath(this string path) => path.Replace(WinDirSeparatorChar, CrossPlatDirSeparatorChar);

// todo: look into all refs of this method
/// <summary>
/// Trims all the consecutive characters that match the given <paramref name="character"/> from the <c>string</c>.
/// </summary>
Expand Down
16 changes: 0 additions & 16 deletions CASL/IApplication.cs

This file was deleted.

3 changes: 0 additions & 3 deletions CASL/IoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@ private static void SetupContainer()
IoCContainer.Register<IAssembly, Assembly>(Lifestyle.Singleton);
IoCContainer.Register<ITaskService, TaskService>(true);
IoCContainer.Register<IThreadService, ThreadService>(Lifestyle.Singleton);
IoCContainer.Register<IApplication, Application>(Lifestyle.Singleton);
IoCContainer.Register<IPlatform, Platform>(Lifestyle.Singleton);
IoCContainer.Register<ILibrary, OpenALLibrary>(Lifestyle.Singleton);
IoCContainer.Register<IDelegateFactory, DelegateFactory>(Lifestyle.Singleton);
IoCContainer.Register<IDependencyManager, OpenALDependencyManager>(Lifestyle.Singleton);
IoCContainer.Register<ILibraryLoader, NativeLibraryLoader>(Lifestyle.Singleton);
IoCContainer.Register<IFilePathResolver, NativeLibPathResolver>(Lifestyle.Singleton);
IoCContainer.Register<IAudioDecoderFactory, AudioDecoderFactory>(Lifestyle.Singleton);
IoCContainer.Register<IAudioBufferFactory, AudioBufferFactory>(Lifestyle.Singleton);

Expand Down
32 changes: 0 additions & 32 deletions CASL/NativeInterop/IDependencyManager.cs

This file was deleted.

24 changes: 0 additions & 24 deletions CASL/NativeInterop/IFilePathResolver.cs

This file was deleted.

Loading
Loading