-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXcodeToolchain.cs
77 lines (58 loc) · 2.4 KB
/
XcodeToolchain.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.IO;
using System.Linq;
namespace CppSharp
{
public static class XcodeToolchain
{
public static string GetXcodePath()
{
var toolchains = Directory.EnumerateDirectories("/Applications", "Xcode*")
.ToList();
toolchains.Sort();
var toolchainPath = toolchains.LastOrDefault();
if (toolchainPath == null)
throw new Exception("Could not find a valid Xcode SDK");
return toolchainPath;
}
public static string GetXcodeToolchainPath()
{
var toolchainPath = GetXcodePath();
var toolchains = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
"Contents/Developer/Toolchains")).ToList();
toolchains.Sort();
toolchainPath = toolchains.LastOrDefault();
if (toolchainPath == null)
throw new Exception("Could not find a valid Xcode toolchain");
return toolchainPath;
}
public static string GetXcodeCppIncludesFolder()
{
var toolchainPath = GetXcodeToolchainPath();
var includePath = Path.Combine(toolchainPath, "usr/include/c++/v1");
if (includePath == null)
throw new Exception("Could not find a valid C++ include folder");
return includePath;
}
public static string GetXcodeBuiltinIncludesFolder()
{
var toolchainPath = GetXcodeToolchainPath();
var includePaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
"usr/lib/clang")).ToList();
var includePath = includePaths.LastOrDefault();
if (includePath == null)
throw new Exception("Could not find a valid Clang include folder");
return Path.Combine(includePath, "include");
}
public static string GetXcodeIncludesFolder()
{
var toolchainPath = GetXcodePath();
var sdkPaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
"Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs")).ToList();
var sdkPath = sdkPaths.LastOrDefault();
if (sdkPath == null)
throw new Exception("Could not find a valid Mac SDK");
return Path.Combine(sdkPath, "usr/include");
}
}
}