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

[3.0] Cache ClangSharp outputs & use cache if we shouldn't run ClangSharp #1868

Merged
merged 20 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.26.7",
"commands": [
"dotnet-csharpier"
]
}
}
}
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,20 @@
# treat as binary
###############################################################################
*.snk binary

*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.stout binary
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,8 @@ src/Website/Silk.NET.Statiq/cache

# SilkTouch configs
!eng/silktouch/**/*.rsp

# SilkTouch caches
**/*.stdownload

**/.DS_Store
File renamed without changes.
3 changes: 3 additions & 0 deletions eng/silktouch/glfw/settings.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ TODO_DEFINE_MACROS=HERE
header.txt
--include-directory
../../../submodules/glfw/include
../../../include/glcompat
../../../submodules/opengl/api
../../../submodules/egl/api
--with-callconv
*=Winapi
--with-librarypath
Expand Down
2 changes: 1 addition & 1 deletion eng/silktouch/opengl/glcompat/generate.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Silk.NET.OpenGL
--test-output
../../../../tests/OpenGL/glcompat/gl
--traverse
../../../include/glcompat/gl.h
../../../include/glcompat/OpenGL/gl.h
2 changes: 1 addition & 1 deletion eng/silktouch/opengl/glcompat/opengl-gl.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include <glcompat/gl.h>
#include <glcompat/OpenGL/gl.h>
151 changes: 113 additions & 38 deletions sources/Core/Pointers/Ptr.generic.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion sources/Core/Pointers/Ref2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,6 @@ public static implicit operator Ref2D(byte*[] array)
/// </summary>
/// <param name="array">The string array.</param>
/// <returns>The <see cref="Ref2D"/></returns>
public static implicit operator Ref2D(string[] array) => new(ref SilkMarshal.StringArrayToNative(array));
public static implicit operator Ref2D(string[] array) =>
new(ref SilkMarshal.StringArrayToNative(array));
}
44 changes: 31 additions & 13 deletions sources/Core/SilkMarshal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,11 @@ public static ref byte StringArrayToNative(ReadOnlySpan<string[][]> strs, nint c
/// <param name="lengths">length of the first-level arrays</param>
/// <returns>The read string array.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string?[]?[]? NativeToStringArray(ReadOnlySpan<nint> native, int[] lengths, nint charSize = 1)
public static string?[]?[]? NativeToStringArray(
ReadOnlySpan<nint> native,
int[] lengths,
nint charSize = 1
)
{
if (native == null || native.Length != lengths.Length)
{
Expand All @@ -385,10 +389,13 @@ public static ref byte StringArrayToNative(ReadOnlySpan<string[][]> strs, nint c
string?[]?[]? strings = new string[native.Length][];
for (int i = 0; i < native.Length; i++)
{
strings[i] = NativeToStringArray(MemoryMarshal.CreateReadOnlySpan(
ref Unsafe.As<byte, nint>(ref Unsafe.AsRef<byte>((byte*)native[i])),
lengths[i]
), charSize);
strings[i] = NativeToStringArray(
MemoryMarshal.CreateReadOnlySpan(
ref Unsafe.As<byte, nint>(ref Unsafe.AsRef<byte>((byte*)native[i])),
lengths[i]
),
charSize
);
}

return strings;
Expand All @@ -403,7 +410,12 @@ ref Unsafe.As<byte, nint>(ref Unsafe.AsRef<byte>((byte*)native[i])),
/// <param name="lengths1">length of the second-level arrays</param>
/// <returns>The read string array.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string?[]?[]?[]? NativeToStringArray(ReadOnlySpan<nint> native, int[] lengths0, int[] lengths1, nint charSize = 1)
public static string?[]?[]?[]? NativeToStringArray(
ReadOnlySpan<nint> native,
int[] lengths0,
int[] lengths1,
nint charSize = 1
)
{
if (native == null || native.Length != lengths0.Length)
{
Expand All @@ -413,10 +425,14 @@ ref Unsafe.As<byte, nint>(ref Unsafe.AsRef<byte>((byte*)native[i])),
string?[]?[]?[]? strings = new string[native.Length][][];
for (int i = 0; i < native.Length; i++)
{
strings[i] = NativeToStringArray(MemoryMarshal.CreateReadOnlySpan(
ref Unsafe.As<byte, nint>(ref Unsafe.AsRef<byte>((byte*)native[i])),
lengths0[i]
), lengths1, charSize);
strings[i] = NativeToStringArray(
MemoryMarshal.CreateReadOnlySpan(
ref Unsafe.As<byte, nint>(ref Unsafe.AsRef<byte>((byte*)native[i])),
lengths0[i]
),
lengths1,
charSize
);
}

return strings;
Expand Down Expand Up @@ -528,10 +544,11 @@ public static Ref2D<T> AsRef2D<T>(ref this Span<T> @ref)
/// <param name="span"></param>
/// <param name="lengths">length of each array in the span</param>
/// <returns></returns>
public static T[][] NativeToArray<T>(Span<nint> span, int[] lengths) where T : unmanaged
public static T[][] NativeToArray<T>(Span<nint> span, int[] lengths)
where T : unmanaged
{
T[][] ret = new T[span.Length][];
for (int i = 0; i < span.Length; i++)
for (int i = 0; i < span.Length; i++)
{
T* ptr = (T*)span[0];

Expand All @@ -551,7 +568,8 @@ public static T[][] NativeToArray<T>(Span<nint> span, int[] lengths) where T : u
/// <param name="lengths0">length of each array in the span</param>
/// <param name="lengths1">length of each array in the arrays in the span</param>
/// <returns></returns>
public static T[][][] NativeToArray<T>(Span<nint> span, int[] lengths0, int[][] lengths1) where T : unmanaged
public static T[][][] NativeToArray<T>(Span<nint> span, int[] lengths0, int[][] lengths1)
where T : unmanaged
{
T[][][] ret = new T[span.Length][][];
for (int i = 0; i < span.Length; i++)
Expand Down
7 changes: 7 additions & 0 deletions sources/GLFW/Cursor.gen.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Silk.NET.GLFW;

public readonly struct Cursor { }
2 changes: 1 addition & 1 deletion sources/GLFW/Glfw.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Silk.NET.Core.Loader;
using System.Reflection;

Expand Down
2 changes: 1 addition & 1 deletion sources/GLFW/IGlfw.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Silk.NET.GLFW;

Expand Down
7 changes: 7 additions & 0 deletions sources/GLFW/Monitor.gen.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Silk.NET.GLFW;

public readonly struct Monitor { }
7 changes: 7 additions & 0 deletions sources/GLFW/Window.gen.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Silk.NET.GLFW;

public readonly struct Window { }
20 changes: 17 additions & 3 deletions sources/GLFW/glfw3/Gamepadstate.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.CompilerServices;

namespace Silk.NET.GLFW;

public unsafe partial struct Gamepadstate
public partial struct Gamepadstate
{
[NativeTypeName("unsigned char[15]")]
public fixed byte Buttons[15];
public _buttons_e__FixedBuffer Buttons;

[NativeTypeName("float[6]")]
public fixed float Axes[6];
public _axes_e__FixedBuffer Axes;

[InlineArray(15)]
public partial struct _buttons_e__FixedBuffer
{
public byte e0;
}

[InlineArray(6)]
public partial struct _axes_e__FixedBuffer
{
public float e0;
}
}
2 changes: 1 addition & 1 deletion sources/GLFW/glfw3/Glfw.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Silk.NET.GLFW;

Expand Down
2 changes: 2 additions & 0 deletions sources/GLFW/glfw3/Image.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.CompilerServices;

namespace Silk.NET.GLFW;

public unsafe partial struct Image
Expand Down
2 changes: 2 additions & 0 deletions sources/GLFW/glfw3/Vidmode.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from glfw3.h and corresponding dependencies of GLFW3
// Original source is Copyright © 2002-2006 Marcus Geelnard, 2006-2019 Camilla Löwy. Licensed under the zlib license.
using System.Runtime.CompilerServices;

namespace Silk.NET.GLFW;

public partial struct Vidmode
Expand Down
1 change: 1 addition & 0 deletions sources/OpenGL/GL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Silk.NET.OpenGL;
public partial class GL
{
private INativeContext Context => nativeContext;

public partial class ThisThread
{
public static partial void MakeCurrent(IGL ctx)
Expand Down
7 changes: 6 additions & 1 deletion sources/OpenGL/GL.gen.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Ported from the OpenGL Core Profile headers and corresponding dependencies.
// Original source is Copyright 2013-2020 The Khronos Group Inc. Licensed under the MIT license.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Silk.NET.Core.Loader;
using System.Reflection;

namespace Silk.NET.OpenGL;

Expand Down
Loading
Loading