14#include "llvm/TargetParser/Triple.h"
26 return "iPhoneSimulator";
30 return "AppleTVSimulator";
34 return "WatchSimulator";
44 llvm_unreachable(
"Unhandled sdk type!");
64 if (name.consume_front(
"MacOSX"))
66 if (name.consume_front(
"iPhoneSimulator"))
68 if (name.consume_front(
"iPhoneOS"))
70 if (name.consume_front(
"AppleTVSimulator"))
72 if (name.consume_front(
"AppleTVOS"))
74 if (name.consume_front(
"WatchSimulator"))
76 if (name.consume_front(
"WatchOS"))
78 if (name.consume_front(
"bridgeOS"))
80 if (name.consume_front(
"Linux"))
83 "New SDK type was added, update this list!");
89 while (i < name.size() && name[i] >=
'0' && name[i] <=
'9')
91 if (i == name.size() || name[i++] !=
'.')
93 while (i < name.size() && name[i] >=
'0' && name[i] <=
'9')
95 if (i == name.size() || name[i++] !=
'.')
98 llvm::VersionTuple version;
99 version.tryParse(name.slice(0, i - 1));
100 name = name.drop_front(i);
105 return name.consume_front(
"Internal.") || name.consume_front(
".Internal.");
110 llvm::StringRef input(
m_name);
118 llvm::StringRef input(
m_name);
125 llvm::StringRef input(
m_name);
131 llvm::StringRef input(
m_name);
143 return std::tie(type, version, internal) ==
150 auto r = other.
Parse();
155 if (llvm::StringRef(
m_name).endswith(
".sdk"))
156 if (!
l.internal && r.internal)
158 m_name.substr(0,
m_name.size() - 3) + std::string(
"Internal.sdk");
169 name =
"iphonesimulator";
175 name =
"appletvsimulator";
181 name =
"watchsimulator";
196 name += info.
version.getAsString();
203 llvm::VersionTuple version) {
206 return version >= llvm::VersionTuple(10, 10);
211 return version >= llvm::VersionTuple(8);
214 return version >= llvm::VersionTuple(6);
226 return info.
version.empty() || info.
version >= llvm::VersionTuple(10, 10);
229 return info.
version.empty() || info.
version >= llvm::VersionTuple(8);
232 return info.
version.empty() || info.
version >= llvm::VersionTuple(9);
235 return info.
version.empty() || info.
version >= llvm::VersionTuple(2);
247 if (!last_path_component)
251 if (sdk.
GetType() != desired_type)
257 using namespace llvm;
258 switch (triple.getOS()) {
263 switch (triple.getEnvironment()) {
266 case Triple::Simulator:
272 if (triple.getEnvironment() == Triple::Simulator)
275 case Triple::WatchOS:
276 if (triple.getEnvironment() == Triple::Simulator)
287 auto begin = llvm::sys::path::begin(path);
288 auto end = llvm::sys::path::end(path);
293 for (
auto it = begin; it != end; ++it) {
294 if (it->endswith(
".app")) {
296 if (++next != end && *next ==
"Contents") {
297 llvm::SmallString<128> buffer;
298 llvm::sys::path::append(buffer, begin, ++next,
299 llvm::sys::path::Style::posix);
300 return buffer.str().str();
static llvm::VersionTuple ParseSDKVersion(llvm::StringRef &name)
static llvm::StringRef GetName(XcodeSDK::Type type)
static bool ParseAppleInternalSDK(llvm::StringRef &name)
static XcodeSDK::Type ParseSDKName(llvm::StringRef &name)
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const ConstString & GetFilename() const
Filename string const get accessor.
An abstraction for Xcode-style SDKs that works like ArchSpec.
static constexpr int numSDKTypes
bool SupportsSwift() const
Whether this Xcode SDK supports Swift.
bool operator==(const XcodeSDK &other)
Type
Different types of Xcode SDKs.
static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path)
void Merge(const XcodeSDK &other)
The merge function follows a strict order to maintain monotonicity:
XcodeSDK & operator=(const XcodeSDK &other)
XcodeSDK()=default
Default constructor, constructs an empty string.
llvm::VersionTuple GetVersion() const
llvm::StringRef GetString() const
static std::string GetCanonicalName(Info info)
Return the canonical SDK name, such as "macosx" for the macOS SDK.
static XcodeSDK::Type GetSDKTypeForTriple(const llvm::Triple &triple)
Return the best-matching SDK type for a specific triple.
Info Parse() const
Return parsed SDK type and version number.
bool IsAppleInternalSDK() const
static bool SDKSupportsModules(Type type, llvm::VersionTuple version)
Whether LLDB feels confident importing Clang modules from this SDK.
A class that represents a running process on the host machine.
A parsed SDK directory name.
llvm::VersionTuple version
bool operator<(const Info &other) const
bool operator==(const Info &other) const