Browse Source

Improve Xcode toolchain lookup to be more robust.

Fixes https://github.com/mono/CppSharp/issues/1259.

Signed-off-by: Joao Matos <joao@tritao.eu>
pull/1278/head
Joao Matos 6 years ago
parent
commit
fa5dbb9010
  1. 15
      src/Core/Toolchains/XcodeToolchain.cs

15
src/Core/Toolchains/XcodeToolchain.cs

@ -33,8 +33,8 @@ namespace CppSharp
var includePath = Path.Combine(toolchainPath, "usr/include/c++/v1"); var includePath = Path.Combine(toolchainPath, "usr/include/c++/v1");
if (includePath == null) if (includePath == null || !Directory.Exists(includePath))
throw new Exception("Could not find a valid C++ include folder"); throw new Exception($"Could not find a valid C++ include folder: {includePath}");
return includePath; return includePath;
} }
@ -47,8 +47,8 @@ namespace CppSharp
"usr/lib/clang")).ToList(); "usr/lib/clang")).ToList();
var includePath = includePaths.LastOrDefault(); var includePath = includePaths.LastOrDefault();
if (includePath == null) if (includePath == null || !Directory.Exists(includePath))
throw new Exception("Could not find a valid Clang include folder"); throw new Exception($"Could not find a valid Clang builtins folder: {includePath}");
return Path.Combine(includePath, "include"); return Path.Combine(includePath, "include");
} }
@ -58,11 +58,12 @@ namespace CppSharp
var toolchainPath = GetXcodePath(); var toolchainPath = GetXcodePath();
var sdkPaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath, var sdkPaths = Directory.EnumerateDirectories(Path.Combine(toolchainPath,
"Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs")).ToList(); "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"))
.Where(dir => dir.Contains("MacOSX.sdk")).ToList();
var sdkPath = sdkPaths.LastOrDefault(); var sdkPath = sdkPaths.LastOrDefault();
if (sdkPath == null) if (sdkPath == null || !Directory.Exists(sdkPath))
throw new Exception("Could not find a valid Mac SDK"); throw new Exception($"Could not find a valid Mac SDK folder: {sdkPath}");
return Path.Combine(sdkPath, "usr/include"); return Path.Combine(sdkPath, "usr/include");
} }

Loading…
Cancel
Save