Skip to content

Commit 3a47e0a

Browse files
authored
Merge pull request #87 from neogeek/hotfix/nuget-binaries
[hotfix] Simplified DLLImport setup.
2 parents beacaa2 + 50d280f commit 3a47e0a

File tree

9 files changed

+30
-171
lines changed

9 files changed

+30
-171
lines changed

RhythmGameUtilities/RhythmGameUtilities.csproj

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,16 @@
2929
<DefineConstants>$(DefineConstants);LINUX_BUILD</DefineConstants>
3030
</PropertyGroup>
3131

32-
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
33-
<None Include="./Libs/Windows/libRhythmGameUtilities.dll">
34-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
35-
</None>
36-
</ItemGroup>
37-
38-
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
39-
<None Include="./Libs/macOS/libRhythmGameUtilities.dylib">
40-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
41-
</None>
42-
</ItemGroup>
43-
44-
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
45-
<None Include="./Libs/Linux/libRhythmGameUtilities.so">
46-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
47-
</None>
32+
<ItemGroup>
33+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
4834
</ItemGroup>
4935

5036
<ItemGroup>
51-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
37+
<Content Include="./Libs/Windows/libRhythmGameUtilities.dll" Pack="true"
38+
PackagePath="runtimes/win-x64/native/" />
39+
<Content Include="./Libs/Linux/libRhythmGameUtilities.so" Pack="true"
40+
PackagePath="runtimes/linux-x64/native/" />
41+
<Content Include="./Libs/macOS/libRhythmGameUtilities.dylib" Pack="true"
42+
PackagePath="runtimes/osx-x64/native/" />
5243
</ItemGroup>
5344
</Project>

RhythmGameUtilities/Scripts/Audio.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,10 @@ namespace RhythmGameUtilities
77
internal static class AudioInternal
88
{
99

10-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
11-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
12-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
13-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
14-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
15-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
16-
#endif
10+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
1711
public static extern IntPtr ConvertSamplesToWaveform(float[] samples, int size, int width, int height);
1812

19-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
20-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
21-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
22-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
23-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
24-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
25-
#endif
13+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
2614
public static extern void FreeWaveform(IntPtr waveform, int width);
2715

2816
}

RhythmGameUtilities/Scripts/Common.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@ namespace RhythmGameUtilities
66
public static class CommonInternal
77
{
88

9-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
10-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
11-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
12-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
13-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
14-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
15-
#endif
9+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
1610
public static extern float Lerp(float a, float b, float t);
1711

18-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
19-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
20-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
21-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
22-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
23-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
24-
#endif
12+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
2513
public static extern float InverseLerp(float a, float b, float v);
2614

2715
}

RhythmGameUtilities/Scripts/Parsers.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ internal struct ChartSectionInternal
3535
internal static class ParsersInternal
3636
{
3737

38-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
39-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
40-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
41-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
42-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
43-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
44-
#endif
38+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
4539
public static extern IntPtr ParseSectionsFromChartInternal(string contents, out int size);
4640

4741
}

RhythmGameUtilities/Scripts/Utilities.cs

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,23 @@ namespace RhythmGameUtilities
99
internal static class UtilitiesInternal
1010
{
1111

12-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
13-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
14-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
15-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
16-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
17-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
18-
#endif
12+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
1913
public static extern float ConvertTickToPosition(int tick, int resolution);
2014

21-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
22-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
23-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
24-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
25-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
26-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
27-
#endif
15+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
2816
public static extern int ConvertSecondsToTicksInternal(float seconds, int resolution, int[] bpmChangesKeys,
2917
int[] bpmChangesValues, int bpmChangesSize);
3018

31-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
32-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
33-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
34-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
35-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
36-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
37-
#endif
19+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
3820
public static extern bool IsOnTheBeat(int bpm, float currentTime, float delta);
3921

40-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
41-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
42-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
43-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
44-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
45-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
46-
#endif
22+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
4723
public static extern int RoundUpToTheNearestMultiplier(int value, int multiplier);
4824

49-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
50-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
51-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
52-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
53-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
54-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
55-
#endif
25+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
5626
public static extern float CalculateAccuracyRatio(int position, int currentPosition, int delta);
5727

58-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
59-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
60-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
61-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
62-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
63-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
64-
#endif
28+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
6529
public static extern IntPtr CalculateBeatBarsInternal(int[] bpmChangesKeys,
6630
int[] bpmChangesValues, int bpmChangesSize, int resolution, int ts,
6731
bool includeHalfNotes, out int size);

UnityPackage/Scripts/Audio.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,10 @@ namespace RhythmGameUtilities
77
internal static class AudioInternal
88
{
99

10-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
11-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
12-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
13-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
14-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
15-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
16-
#endif
10+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
1711
public static extern IntPtr ConvertSamplesToWaveform(float[] samples, int size, int width, int height);
1812

19-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
20-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
21-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
22-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
23-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
24-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
25-
#endif
13+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
2614
public static extern void FreeWaveform(IntPtr waveform, int width);
2715

2816
}

UnityPackage/Scripts/Common.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@ namespace RhythmGameUtilities
66
public static class CommonInternal
77
{
88

9-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
10-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
11-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
12-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
13-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
14-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
15-
#endif
9+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
1610
public static extern float Lerp(float a, float b, float t);
1711

18-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
19-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
20-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
21-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
22-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
23-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
24-
#endif
12+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
2513
public static extern float InverseLerp(float a, float b, float v);
2614

2715
}

UnityPackage/Scripts/Parsers.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ internal struct ChartSectionInternal
3535
internal static class ParsersInternal
3636
{
3737

38-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
39-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
40-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
41-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
42-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
43-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
44-
#endif
38+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
4539
public static extern IntPtr ParseSectionsFromChartInternal(string contents, out int size);
4640

4741
}

UnityPackage/Scripts/Utilities.cs

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,23 @@ namespace RhythmGameUtilities
99
internal static class UtilitiesInternal
1010
{
1111

12-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
13-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
14-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
15-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
16-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
17-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
18-
#endif
12+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
1913
public static extern float ConvertTickToPosition(int tick, int resolution);
2014

21-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
22-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
23-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
24-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
25-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
26-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
27-
#endif
15+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
2816
public static extern int ConvertSecondsToTicksInternal(float seconds, int resolution, int[] bpmChangesKeys,
2917
int[] bpmChangesValues, int bpmChangesSize);
3018

31-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
32-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
33-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
34-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
35-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
36-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
37-
#endif
19+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
3820
public static extern bool IsOnTheBeat(int bpm, float currentTime, float delta);
3921

40-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
41-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
42-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
43-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
44-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
45-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
46-
#endif
22+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
4723
public static extern int RoundUpToTheNearestMultiplier(int value, int multiplier);
4824

49-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
50-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
51-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
52-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
53-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
54-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
55-
#endif
25+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
5626
public static extern float CalculateAccuracyRatio(int position, int currentPosition, int delta);
5727

58-
#if WINDOWS_BUILD || UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
59-
[DllImport("libRhythmGameUtilities.dll", CallingConvention = CallingConvention.Cdecl)]
60-
#elif MACOS_BUILD || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
61-
[DllImport("libRhythmGameUtilities.dylib", CallingConvention = CallingConvention.Cdecl)]
62-
#elif LINUX_BUILD || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
63-
[DllImport("libRhythmGameUtilities.so", CallingConvention = CallingConvention.Cdecl)]
64-
#endif
28+
[DllImport("libRhythmGameUtilities", CallingConvention = CallingConvention.Cdecl)]
6529
public static extern IntPtr CalculateBeatBarsInternal(int[] bpmChangesKeys,
6630
int[] bpmChangesValues, int bpmChangesSize, int resolution, int ts,
6731
bool includeHalfNotes, out int size);

0 commit comments

Comments
 (0)