From 59cb0158bacca27c6b9dec5e8dca84b2d876ba35 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Sat, 20 Apr 2024 19:11:28 +0900 Subject: [PATCH] Add desktop tests project The primary purpose of this is to split out the handling of the native libs. This is a consequence of using ProjectReference, and resolves the following issues: 1. When compiling for iOS, it really doesn't like multiple files being included in the same output path. Example: all Windows SDL.dll files placed as SDL.dll in the output path. 2. Even if (1) was somehow resolved, the iOS build also doesn't like the linux-specific .so files being included. 3. As a consequence of (1), it's likely that the project already doesn't work on some configurations. For example, because win-x86 is specified as the last item, it will likely take precedence over all other versions. 4. It looks like `RuntimeIdentifier` is not project-transitive, against my expectations. I really want the project to both select the correct single native lib for the current platform, and also support compiling with a RID (`dotnet build -r ...`). So now we only copy the correct lib to the output path, and don't do it while packaging (not required). --- SDL3-CS.Tests.Desktop/Program.cs | 7 ++++ .../SDL3-CS.Tests.Desktop.csproj | 35 ++++++++++++++++ SDL3-CS.Tests/SDL3-CS.Tests.csproj | 2 +- SDL3-CS.sln | 6 +++ SDL3-CS/SDL3-CS.csproj | 40 ++++++++----------- 5 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 SDL3-CS.Tests.Desktop/Program.cs create mode 100644 SDL3-CS.Tests.Desktop/SDL3-CS.Tests.Desktop.csproj diff --git a/SDL3-CS.Tests.Desktop/Program.cs b/SDL3-CS.Tests.Desktop/Program.cs new file mode 100644 index 0000000..96f04a3 --- /dev/null +++ b/SDL3-CS.Tests.Desktop/Program.cs @@ -0,0 +1,7 @@ +internal class Program +{ + public static void Main(string[] args) + { + SDL.Tests.Program.Main(); + } +} diff --git a/SDL3-CS.Tests.Desktop/SDL3-CS.Tests.Desktop.csproj b/SDL3-CS.Tests.Desktop/SDL3-CS.Tests.Desktop.csproj new file mode 100644 index 0000000..e1854f9 --- /dev/null +++ b/SDL3-CS.Tests.Desktop/SDL3-CS.Tests.Desktop.csproj @@ -0,0 +1,35 @@ + + + + Exe + net8.0 + SDL3.Tests.Desktop + enable + enable + + + + + + + + $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) + + + $(RuntimeIdentifier)\SDL3.dll + $(RuntimeIdentifier)\libSDL3.so + $(RuntimeIdentifier)\libSDL3.dylib + + + win-$(SDLArch.ToLower())\SDL3.dll + linux-$(SDLArch.ToLower())\libSDL3.so + osx-$(SDLArch.ToLower())\libSDL3.dylib + + + + + PreserveNewest + + + + diff --git a/SDL3-CS.Tests/SDL3-CS.Tests.csproj b/SDL3-CS.Tests/SDL3-CS.Tests.csproj index 129e3d4..a789eb7 100644 --- a/SDL3-CS.Tests/SDL3-CS.Tests.csproj +++ b/SDL3-CS.Tests/SDL3-CS.Tests.csproj @@ -1,7 +1,7 @@  - Exe + Library net8.0 SDL.Tests enable diff --git a/SDL3-CS.sln b/SDL3-CS.sln index 6d94d0b..c686aa6 100644 --- a/SDL3-CS.sln +++ b/SDL3-CS.sln @@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL3-CS.Android", "SDL3-CS. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL3-CS.Tests.Android", "SDL3-CS.Tests.Android\SDL3-CS.Tests.Android.csproj", "{E8469DA5-E437-4287-9E2A-8B8F4DC21C1A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL3-CS.Tests.Desktop", "SDL3-CS.Tests.Desktop\SDL3-CS.Tests.Desktop.csproj", "{7E8D719A-5B69-43B7-A9D5-385B6FE7F411}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -49,6 +51,10 @@ Global {E8469DA5-E437-4287-9E2A-8B8F4DC21C1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E8469DA5-E437-4287-9E2A-8B8F4DC21C1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {E8469DA5-E437-4287-9E2A-8B8F4DC21C1A}.Release|Any CPU.Build.0 = Release|Any CPU + {7E8D719A-5B69-43B7-A9D5-385B6FE7F411}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E8D719A-5B69-43B7-A9D5-385B6FE7F411}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E8D719A-5B69-43B7-A9D5-385B6FE7F411}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E8D719A-5B69-43B7-A9D5-385B6FE7F411}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SDL3-CS/SDL3-CS.csproj b/SDL3-CS/SDL3-CS.csproj index 99238b6..29c8286 100644 --- a/SDL3-CS/SDL3-CS.csproj +++ b/SDL3-CS/SDL3-CS.csproj @@ -29,46 +29,38 @@ - - PreserveNewest + runtimes/win-x64/native true - - - PreserveNewest + + runtimes/win-arm64/native true - - - PreserveNewest + + runtimes/win-x86/native true - - - PreserveNewest + + runtimes/osx-x64/native true - - - PreserveNewest + + runtimes/osx-arm64/native true - - - PreserveNewest + + runtimes/linux-x64/native true - - - PreserveNewest + + runtimes/linux-x86/native true - - - PreserveNewest + + runtimes/ios/native true - +