Skip to content

Commit

Permalink
reorganize native
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Mar 26, 2024
1 parent dfafe06 commit e7008d1
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 50 deletions.
15 changes: 15 additions & 0 deletions Osu.Patcher.Hook/Hook.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 0 additions & 35 deletions Osu.Performance.ROsu/Osu.Performance.ROsu.csproj

This file was deleted.

4 changes: 2 additions & 2 deletions Osu.Performance.ROsu/Native.cs → Osu.Performance/Native.cs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
32 changes: 28 additions & 4 deletions Osu.Performance/Osu.Performance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,33 @@

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" PrivateAssets="all"/>
<ProjectReference Include="../Osu.Performance.ROsu/Osu.Performance.ROsu.csproj">
<Targets>Build;BuildNative</Targets>
<SetTargetFramework>TargetFramework=net452</SetTargetFramework>
</ProjectReference>
<Reference Include="System.Collections.Concurrent"/>
</ItemGroup>

<PropertyGroup>
<NativeTarget>i686-pc-windows-msvc</NativeTarget>
<CargoBuild>cargo build --color=never --message-format=human --target $(NativeTarget)</CargoBuild>
<CargoOutput>.\rosu-ffi\target\$(NativeTarget)\$(Configuration.ToLower())</CargoOutput>
</PropertyGroup>
<ItemGroup>
<CompileNative Include=".\rosu-ffi\src\**\*.rs"/>
<CompileNative Include=".\rosu-ffi\src\Cargo.toml"/>
<CompileNative Include=".\rosu-ffi\src\Cargo.lock"/>
</ItemGroup>
<Target Name="BuildNative" BeforeTargets="BeforeBuild" Inputs="@(CompileNative)" Outputs="$(CargoOutput)\rosu.dll;$(CargoOutput)\rosu.pdb">
<Exec WorkingDirectory="rosu-ffi" Condition="'$(Configuration)' == 'Debug'" Command="$(CargoBuild)"/>
<Exec WorkingDirectory="rosu-ffi" Condition="'$(Configuration)' == 'Release'" Command="$(CargoBuild) --release"/>

<ItemGroup>
<ROsuOutput Include="$(CargoOutput)\rosu.dll"/>
<ROsuOutput Include="$(CargoOutput)\rosu.pdb" Condition="'$(Configuration)' == 'Debug'"/>
<Content Include="@(ROsuOutput)">
<TargetPath>rosu.ffi%(Extension)</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>
<Target Name="CleanNative" AfterTargets="Clean">
<Exec WorkingDirectory="rosu-ffi" Command="cargo clean"/>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading.Tasks;
using JetBrains.Annotations;

namespace Osu.Performance.ROsu;
namespace Osu.Performance;

[UsedImplicitly]
public class OsuPerformance : IDisposable
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions osu-patcher.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit e7008d1

Please sign in to comment.