14#include "llvm/TargetParser/Triple.h"
26 return "iPhoneSimulator";
30 return "AppleTVSimulator";
34 return "WatchSimulator";
48 llvm_unreachable(
"Unhandled sdk type!");
68 if (name.consume_front(
"MacOSX"))
70 if (name.consume_front(
"iPhoneSimulator"))
72 if (name.consume_front(
"iPhoneOS"))
74 if (name.consume_front(
"AppleTVSimulator"))
76 if (name.consume_front(
"AppleTVOS"))
78 if (name.consume_front(
"WatchSimulator"))
80 if (name.consume_front(
"WatchOS"))
82 if (name.consume_front(
"XRSimulator"))
84 if (name.consume_front(
"XROS"))
86 if (name.consume_front(
"bridgeOS"))
88 if (name.consume_front(
"Linux"))
91 "New SDK type was added, update this list!");
97 while (i < name.size() && name[i] >=
'0' && name[i] <=
'9')
99 if (i == name.size() || name[i++] !=
'.')
101 while (i < name.size() && name[i] >=
'0' && name[i] <=
'9')
103 if (i == name.size() || name[i++] !=
'.')
106 llvm::VersionTuple version;
107 version.tryParse(name.slice(0, i - 1));
108 name = name.drop_front(i);
113 return name.consume_front(
"Internal.") || name.consume_front(
".Internal.");
118 llvm::StringRef input(
m_name);
126 llvm::StringRef input(
m_name);
133 llvm::StringRef input(
m_name);
139 llvm::StringRef input(
m_name);
151 return std::tie(type, version, internal) ==
158 auto r = other.
Parse();
163 if (llvm::StringRef(
m_name).ends_with(
".sdk"))
164 if (!
l.internal && r.internal)
166 m_name.substr(0,
m_name.size() - 3) + std::string(
"Internal.sdk");
177 name =
"iphonesimulator";
183 name =
"appletvsimulator";
189 name =
"watchsimulator";
195 name =
"xrsimulator";
210 name += info.
version.getAsString();
217 llvm::VersionTuple version) {
220 return version >= llvm::VersionTuple(10, 10);
225 return version >= llvm::VersionTuple(8);
228 return version >= llvm::VersionTuple(6);
243 return info.
version.empty() || info.
version >= llvm::VersionTuple(10, 10);
246 return info.
version.empty() || info.
version >= llvm::VersionTuple(8);
249 return info.
version.empty() || info.
version >= llvm::VersionTuple(9);
252 return info.
version.empty() || info.
version >= llvm::VersionTuple(2);
263 llvm::VersionTuple sdk_version) {
264 using namespace llvm;
266 switch (target_triple.getOS()) {
267 case Triple::OSType::MacOSX:
268 return sdk_version >= VersionTuple(15U);
269 case Triple::OSType::IOS:
270 return sdk_version >= VersionTuple(18U);
271 case Triple::OSType::TvOS:
272 return sdk_version >= VersionTuple(18U);
273 case Triple::OSType::WatchOS:
274 return sdk_version >= VersionTuple(11U);
275 case Triple::OSType::XROS:
276 return sdk_version >= VersionTuple(2U);
287 if (!last_path_component)
291 if (sdk.
GetType() != desired_type)
297 using namespace llvm;
298 switch (triple.getOS()) {
303 switch (triple.getEnvironment()) {
306 case Triple::Simulator:
312 if (triple.getEnvironment() == Triple::Simulator)
315 case Triple::WatchOS:
316 if (triple.getEnvironment() == Triple::Simulator)
320 if (triple.getEnvironment() == Triple::Simulator)
331 auto begin = llvm::sys::path::begin(path);
332 auto end = llvm::sys::path::end(path);
337 for (
auto it = begin; it != end; ++it) {
338 if (it->ends_with(
".app")) {
340 if (++next != end && *next ==
"Contents") {
341 llvm::SmallString<128> buffer;
342 llvm::sys::path::append(buffer, begin, ++next,
343 llvm::sys::path::Style::posix);
344 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.
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.
static bool SDKSupportsBuiltinModules(const llvm::Triple &target_triple, llvm::VersionTuple sdk_version)
Returns true if the SDK for the specified triple supports builtin modules in system headers.
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 operator==(const XcodeSDK &other) const
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