Skip to content

Commit 81ba841

Browse files
committed
Attempt to find and add Clang include directory in UnixStdIncludeResolver
1 parent cf87296 commit 81ba841

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

eng/silktouch/vulkan/settings.rsp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ TODO_DEFINE_MACROS=HERE
55
../header.txt
66
--include-directory
77
../../../submodules/vulkan-headers/include
8-
# TODO: Remove this
9-
/usr/lib/clang/20/include
108
--with-callconv
119
*=Winapi
1210
--with-librarypath
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System.Collections.Generic;
22
using System.Linq;
3+
using System.Text.RegularExpressions;
34

45
namespace Silk.NET.SilkTouch.Clang;
56

67
/// <summary>
7-
/// Resolver for the C standard include paths on UNIX-like systems. On UNIX this is remarkably simple, it's just
8-
/// /usr/include and /usr/include/local.
8+
/// Resolver for the C standard include paths on UNIX-like systems.
99
/// </summary>
10-
public class UnixStdIncludeResolver : IStdIncludeResolver
10+
public partial class UnixStdIncludeResolver : IStdIncludeResolver
1111
{
1212
private string[]? _ret = null;
1313

@@ -18,7 +18,29 @@ public IEnumerable<string> GetStandardIncludes() =>
1818
/// <inheritdoc cref="GetStandardIncludes" />
1919
protected virtual IEnumerable<string> CoreGetStandardIncludes()
2020
{
21+
// Add standard include directories
2122
yield return "-I/usr/include";
2223
yield return "-I/usr/local/include";
24+
25+
// Attempt to find and add clang include folder
26+
if (Directory.Exists("/usr/lib/clang/"))
27+
{
28+
var clangIncludeFolder = Directory.GetDirectories("/usr/lib/clang/", "*", SearchOption.AllDirectories)
29+
.Select(path => ClangIncludeFolderRegex().Match(path))
30+
.Where(match => match.Success)
31+
// Select the latest version
32+
.OrderByDescending(match => int.Parse(match.Groups["Version"].Value))
33+
.FirstOrDefault()
34+
?.Value;
35+
36+
if (clangIncludeFolder != null)
37+
{
38+
yield return $"-I{clangIncludeFolder}";
39+
}
40+
}
41+
2342
}
43+
44+
[GeneratedRegex("^/usr/lib/clang/(?<Version>\\d+)/include$")]
45+
private static partial Regex ClangIncludeFolderRegex();
2446
}

0 commit comments

Comments
 (0)