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

[Untested] Fix Xcode C++ include path #1844

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/Core/Toolchains/XcodeToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,34 @@ public static string GetXcodeToolchainPath()
return toolchainPath;
}

public static string GetXcodeSDKPath() {
return Path.Combine(
GetXcodePath(),
"Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
);
}

public static string GetXcodeCppIncludesFolder()
{
var toolchainPath = GetXcodeToolchainPath();
var sdkPath = GetXcodeSDKPath();

var includePath = Path.Combine(toolchainPath, "usr/include/c++/v1");
var includePathSuffix = "usr/include/c++/v1";
var oldIncludePath = Path.Combine(toolchainPath, includePathSuffix);
var newIncludePath = Path.Combine(sdkPath, includePathSuffix);

if (includePath == null || !Directory.Exists(includePath))
throw new Exception($"Could not find a valid C++ include folder: {includePath}");
if (newIncludePath != null && Directory.Exists(newIncludePath))
{
return newIncludePath;
}

if (oldIncludePath != null && Directory.Exists(oldIncludePath))
{
return oldIncludePath;
}

return includePath;
throw new Exception(
$"Could not find a valid C++ include folder in either {oldIncludePath} or {newIncludePath}");
}

public static string GetXcodeBuiltinIncludesFolder()
Expand Down Expand Up @@ -107,4 +125,4 @@ private static string GetXcodePathFromFileSystem()
return toolchainPath;
}
}
}
}
Loading