9#ifndef LLVM_CLANG_BASIC_DARWINSDKINFO_H
10#define LLVM_CLANG_BASIC_DARWINSDKINFO_H
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/STLExtras.h"
15#include "llvm/ADT/SmallVector.h"
16#include "llvm/ADT/StringRef.h"
17#include "llvm/Support/Error.h"
18#include "llvm/Support/VersionTuple.h"
19#include "llvm/Support/VirtualFileSystem.h"
20#include "llvm/TargetParser/Triple.h"
43 : Triples(
std::move(Triples)), PlatformPrefix(PlatformPrefix) {
44 assert(!this->Triples.empty() &&
"Triples cannot be empty");
52 std::string PlatformPrefix;
62 llvm::Triple::EnvironmentType FromEnv,
63 llvm::Triple::OSType ToOS,
64 llvm::Triple::EnvironmentType ToEnv)
74 return OSEnvPair(llvm::Triple::MacOSX, llvm::Triple::UnknownEnvironment,
75 llvm::Triple::IOS, llvm::Triple::MacABI);
81 return OSEnvPair(llvm::Triple::IOS, llvm::Triple::MacABI,
82 llvm::Triple::MacOSX, llvm::Triple::UnknownEnvironment);
88 return OSEnvPair(llvm::Triple::IOS, llvm::Triple::UnknownEnvironment,
89 llvm::Triple::WatchOS, llvm::Triple::UnknownEnvironment);
95 return OSEnvPair(llvm::Triple::IOS, llvm::Triple::UnknownEnvironment,
96 llvm::Triple::TvOS, llvm::Triple::UnknownEnvironment);
113 VersionTuple MinimumKeyVersion, VersionTuple MaximumKeyVersion,
114 VersionTuple MinimumValue, VersionTuple MaximumValue,
115 llvm::DenseMap<VersionTuple, VersionTuple> Mapping)
116 : MinimumKeyVersion(MinimumKeyVersion),
117 MaximumKeyVersion(MaximumKeyVersion), MinimumValue(MinimumValue),
118 MaximumValue(MaximumValue), Mapping(Mapping) {
119 assert(!this->Mapping.empty() &&
"unexpected empty mapping");
128 std::optional<VersionTuple>
129 map(
const VersionTuple &Key,
const VersionTuple &MinimumValue,
130 std::optional<VersionTuple> MaximumValue)
const;
135 std::optional<VersionTuple>
138 if (Key.getMajor() == 100000)
139 return VersionTuple(100000);
141 return map(Key, MinimumValue, std::nullopt);
148 std::optional<VersionTuple>
151 if (Key.getMajor() == 100000)
152 return VersionTuple(100000);
153 return map(Key, MinimumValue, MaximumValue);
156 static std::optional<RelatedTargetVersionMapping>
158 VersionTuple MaximumDeploymentTarget);
161 VersionTuple MinimumKeyVersion;
162 VersionTuple MaximumKeyVersion;
163 VersionTuple MinimumValue;
164 VersionTuple MaximumValue;
165 llvm::DenseMap<VersionTuple, VersionTuple> Mapping;
171 std::string FilePath, llvm::Triple::OSType OS,
172 llvm::Triple::EnvironmentType Environment, VersionTuple Version,
173 StringRef DisplayName, VersionTuple MaximumDeploymentTarget,
176 std::optional<RelatedTargetVersionMapping>>
179 std::optional<RelatedTargetVersionMapping>>())
180 : FilePath(
std::move(FilePath)), OS(OS), Environment(Environment),
181 Version(Version), DisplayName(DisplayName),
182 MaximumDeploymentTarget(MaximumDeploymentTarget),
183 PlatformInfos(
std::move(PlatformInfos)),
184 VersionMappings(
std::move(VersionMappings)) {
185 assert(!this->PlatformInfos.empty() &&
"PlatformInfos cannot be empty");
195 llvm::Triple::EnvironmentType Environment, VersionTuple Version,
196 StringRef DisplayName, VersionTuple MaximumDeploymentTarget);
200 llvm::Triple::OSType
getOS()
const {
return OS; }
204 const llvm::VersionTuple &
getVersion()
const {
return Version; }
209 return PlatformInfos[0].getTriples()[0];
228 auto Mapping = VersionMappings.find(Kind.Value);
229 if (Mapping == VersionMappings.end())
231 return Mapping->getSecond() ? &*Mapping->getSecond() :
nullptr;
234 static std::optional<DarwinSDKInfo>
236 const llvm::json::Object *Obj);
239 std::string FilePath;
240 llvm::Triple::OSType OS;
241 llvm::Triple::EnvironmentType Environment;
242 VersionTuple Version;
243 std::string DisplayName;
244 VersionTuple MaximumDeploymentTarget;
250 std::optional<RelatedTargetVersionMapping>>
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static std::optional< DarwinSDKInfo > parseDarwinSDKSettingsJSON(std::string FilePath, const llvm::json::Object *Obj)
SmallVector< SDKPlatformInfo, 2 > PlatformInfoStorageType
DarwinSDKInfo(std::string FilePath, llvm::Triple::OSType OS, llvm::Triple::EnvironmentType Environment, VersionTuple Version, StringRef DisplayName, VersionTuple MaximumDeploymentTarget, PlatformInfoStorageType PlatformInfos, llvm::DenseMap< OSEnvPair::StorageType, std::optional< RelatedTargetVersionMapping > > VersionMappings=llvm::DenseMap< OSEnvPair::StorageType, std::optional< RelatedTargetVersionMapping > >())
const RelatedTargetVersionMapping * getVersionMapping(OSEnvPair Kind) const
StringRef getFilePath() const
llvm::Triple::EnvironmentType getEnvironment() const
const StringRef getDisplayName() const
const llvm::VersionTuple & getVersion() const
llvm::Triple::OSType getOS() const
StringRef getPlatformPrefix(const llvm::Triple &Triple) const
bool supportsTriple(const llvm::Triple &Triple) const
const llvm::Triple & getCanonicalPlatformTriple() const
The JSON file list parser is used to communicate input to InstallAPI.
Expected< std::optional< DarwinSDKInfo > > parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath)
Parse the SDK information from the SDKSettings.json file.
Diagnostic wrappers for TextAPI types for error reporting.
A value that describes two os-environment pairs that can be used as a key to the version map in the S...
static constexpr OSEnvPair macCatalystToMacOSPair()
Returns the os-environment mapping pair that's used to represent the Mac Catalyst -> macOS version ma...
static constexpr OSEnvPair macOStoMacCatalystPair()
Returns the os-environment mapping pair that's used to represent the macOS -> Mac Catalyst version ma...
static constexpr OSEnvPair iOStoWatchOSPair()
Returns the os-environment mapping pair that's used to represent the iOS -> watchOS version mapping.
static constexpr OSEnvPair iOStoTvOSPair()
Returns the os-environment mapping pair that's used to represent the iOS -> tvOS version mapping.
constexpr OSEnvPair(llvm::Triple::OSType FromOS, llvm::Triple::EnvironmentType FromEnv, llvm::Triple::OSType ToOS, llvm::Triple::EnvironmentType ToEnv)
friend class DarwinSDKInfo