diff --git a/Osu.Patcher.Hook/Hook.cs b/Osu.Patcher.Hook/Hook.cs index 37cfc11..0e0922d 100644 --- a/Osu.Patcher.Hook/Hook.cs +++ b/Osu.Patcher.Hook/Hook.cs @@ -1,7 +1,9 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; using HarmonyLib; using JetBrains.Annotations; +using Osu.Performance; using Osu.Utils; namespace Osu.Patcher.Hook; @@ -20,6 +22,19 @@ public static int Initialize(string _) { ConsoleHook.Initialize(); +#if DEBUG + try + { + // MSBuild is flimsy with building rosu-ffi on up-to-date builds, try linking early + Marshal.PrelinkAll(typeof(Native)); + } + catch (Exception e) + { + Console.WriteLine($"MSBuild broke again; clean & rebuild: {e}"); + return 0; + } +#endif + try { _harmony = new Harmony("osu!patcher"); diff --git a/Osu.Patcher.Hook/Patches/LivePerformance/PatchUpdatePerformanceCalculator.cs b/Osu.Patcher.Hook/Patches/LivePerformance/PatchUpdatePerformanceCalculator.cs index a718c96..0b2dccf 100644 --- a/Osu.Patcher.Hook/Patches/LivePerformance/PatchUpdatePerformanceCalculator.cs +++ b/Osu.Patcher.Hook/Patches/LivePerformance/PatchUpdatePerformanceCalculator.cs @@ -5,7 +5,7 @@ using System.Threading; using HarmonyLib; using JetBrains.Annotations; -using Osu.Performance.ROsu; +using Osu.Performance; using Osu.Stubs; namespace Osu.Patcher.Hook.Patches.LivePerformance; diff --git a/Osu.Performance.ROsu/Osu.Performance.ROsu.csproj b/Osu.Performance.ROsu/Osu.Performance.ROsu.csproj deleted file mode 100644 index bf7d4e8..0000000 --- a/Osu.Performance.ROsu/Osu.Performance.ROsu.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - Library - net452 - 12 - enable - - - none - - - - - - - - i686-pc-windows-msvc - cargo build --color=never --message-format=human --target $(NativeTarget) - .\rosu-ffi\target\$(NativeTarget)\$(Configuration.ToLower()) - - - - - - - - - - rosu.ffi%(Extension) - Always - - - - diff --git a/Osu.Performance.ROsu/Native.cs b/Osu.Performance/Native.cs similarity index 94% rename from Osu.Performance.ROsu/Native.cs rename to Osu.Performance/Native.cs index 17d5236..de57466 100644 --- a/Osu.Performance.ROsu/Native.cs +++ b/Osu.Performance/Native.cs @@ -1,9 +1,9 @@ using System; using System.Runtime.InteropServices; -namespace Osu.Performance.ROsu; +namespace Osu.Performance; -internal static class Native +public static class Native { [DllImport("rosu.ffi.dll", EntryPoint = "calculate_osu_performance")] internal static extern OsuPerformanceInfo CalculateOsuPerformance( diff --git a/Osu.Performance/Osu.Performance.csproj b/Osu.Performance/Osu.Performance.csproj index be330c9..bfa91d1 100644 --- a/Osu.Performance/Osu.Performance.csproj +++ b/Osu.Performance/Osu.Performance.csproj @@ -26,9 +26,33 @@ - - Build;BuildNative - TargetFramework=net452 - + + + + i686-pc-windows-msvc + cargo build --color=never --message-format=human --target $(NativeTarget) + .\rosu-ffi\target\$(NativeTarget)\$(Configuration.ToLower()) + + + + + + + + + + + + + + + rosu.ffi%(Extension) + PreserveNewest + + + + + + diff --git a/Osu.Performance.ROsu/OsuPerformance.cs b/Osu.Performance/OsuPerformance.cs similarity index 99% rename from Osu.Performance.ROsu/OsuPerformance.cs rename to Osu.Performance/OsuPerformance.cs index d9d16fc..d45ff42 100644 --- a/Osu.Performance.ROsu/OsuPerformance.cs +++ b/Osu.Performance/OsuPerformance.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using JetBrains.Annotations; -namespace Osu.Performance.ROsu; +namespace Osu.Performance; [UsedImplicitly] public class OsuPerformance : IDisposable diff --git a/Osu.Performance.ROsu/OsuPerformanceStructs.cs b/Osu.Performance/OsuPerformanceStructs.cs similarity index 97% rename from Osu.Performance.ROsu/OsuPerformanceStructs.cs rename to Osu.Performance/OsuPerformanceStructs.cs index 7a5956d..75e474e 100644 --- a/Osu.Performance.ROsu/OsuPerformanceStructs.cs +++ b/Osu.Performance/OsuPerformanceStructs.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Osu.Performance.ROsu; +namespace Osu.Performance; [StructLayout(LayoutKind.Sequential)] public struct OsuDifficultyAttributes diff --git a/Osu.Performance.ROsu/rosu-ffi/.cargo/config.toml b/Osu.Performance/rosu-ffi/.cargo/config.toml similarity index 100% rename from Osu.Performance.ROsu/rosu-ffi/.cargo/config.toml rename to Osu.Performance/rosu-ffi/.cargo/config.toml diff --git a/Osu.Performance.ROsu/rosu-ffi/Cargo.lock b/Osu.Performance/rosu-ffi/Cargo.lock similarity index 100% rename from Osu.Performance.ROsu/rosu-ffi/Cargo.lock rename to Osu.Performance/rosu-ffi/Cargo.lock diff --git a/Osu.Performance.ROsu/rosu-ffi/Cargo.toml b/Osu.Performance/rosu-ffi/Cargo.toml similarity index 100% rename from Osu.Performance.ROsu/rosu-ffi/Cargo.toml rename to Osu.Performance/rosu-ffi/Cargo.toml diff --git a/Osu.Performance.ROsu/rosu-ffi/src/lib.rs b/Osu.Performance/rosu-ffi/src/lib.rs similarity index 100% rename from Osu.Performance.ROsu/rosu-ffi/src/lib.rs rename to Osu.Performance/rosu-ffi/src/lib.rs diff --git a/Osu.Performance.ROsu/rosu-ffi/src/structs.rs b/Osu.Performance/rosu-ffi/src/structs.rs similarity index 100% rename from Osu.Performance.ROsu/rosu-ffi/src/structs.rs rename to Osu.Performance/rosu-ffi/src/structs.rs diff --git a/osu-patcher.sln b/osu-patcher.sln index e5aaade..8a23a54 100644 --- a/osu-patcher.sln +++ b/osu-patcher.sln @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Osu.Utils", "Osu.Utils\Osu. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Osu.Performance", "Osu.Performance\Osu.Performance.csproj", "{79B81600-142A-4DF7-B1B1-09D18ABE4537}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Osu.Performance.ROsu", "Osu.Performance.ROsu\Osu.Performance.ROsu.csproj", "{E97D5D8F-81D5-4E37-8BE8-5B1DCEDE9A14}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -37,9 +35,5 @@ Global {79B81600-142A-4DF7-B1B1-09D18ABE4537}.Debug|x86.Build.0 = Debug|Any CPU {79B81600-142A-4DF7-B1B1-09D18ABE4537}.Release|x86.ActiveCfg = Release|Any CPU {79B81600-142A-4DF7-B1B1-09D18ABE4537}.Release|x86.Build.0 = Release|Any CPU - {E97D5D8F-81D5-4E37-8BE8-5B1DCEDE9A14}.Debug|x86.ActiveCfg = Debug|Any CPU - {E97D5D8F-81D5-4E37-8BE8-5B1DCEDE9A14}.Debug|x86.Build.0 = Debug|Any CPU - {E97D5D8F-81D5-4E37-8BE8-5B1DCEDE9A14}.Release|x86.ActiveCfg = Release|Any CPU - {E97D5D8F-81D5-4E37-8BE8-5B1DCEDE9A14}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal