mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add swift::getNonSimulatorPlatform for DarwinPlatformKind
And use it in getDarwinLibraryNameSuffixForTriple, making the logic there clearer. Suggested by David U!
This commit is contained in:
@@ -58,6 +58,11 @@ namespace swift {
|
||||
/// Returns the platform Kind for Darwin triples.
|
||||
DarwinPlatformKind getDarwinPlatformKind(const llvm::Triple &triple);
|
||||
|
||||
/// Maps an arbitrary platform to its non-simulator equivalent.
|
||||
///
|
||||
/// If \p platform is not a simulator platform, it will be returned as is.
|
||||
DarwinPlatformKind getNonSimulatorPlatform(DarwinPlatformKind platform);
|
||||
|
||||
/// Returns the architecture component of the path for a given target triple.
|
||||
///
|
||||
/// Typically this is used for mapping the architecture component of the
|
||||
|
||||
@@ -76,6 +76,22 @@ DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) {
|
||||
llvm_unreachable("Unsupported Darwin platform");
|
||||
}
|
||||
|
||||
DarwinPlatformKind swift::getNonSimulatorPlatform(DarwinPlatformKind platform) {
|
||||
switch (platform) {
|
||||
case DarwinPlatformKind::MacOS:
|
||||
return DarwinPlatformKind::MacOS;
|
||||
case DarwinPlatformKind::IPhoneOS:
|
||||
case DarwinPlatformKind::IPhoneOSSimulator:
|
||||
return DarwinPlatformKind::IPhoneOS;
|
||||
case DarwinPlatformKind::TvOS:
|
||||
case DarwinPlatformKind::TvOSSimulator:
|
||||
return DarwinPlatformKind::TvOS;
|
||||
case DarwinPlatformKind::WatchOS:
|
||||
case DarwinPlatformKind::WatchOSSimulator:
|
||||
return DarwinPlatformKind::WatchOS;
|
||||
}
|
||||
}
|
||||
|
||||
static StringRef getPlatformNameForDarwin(const DarwinPlatformKind platform) {
|
||||
switch (platform) {
|
||||
case DarwinPlatformKind::MacOS:
|
||||
|
||||
@@ -86,27 +86,24 @@ toolchains::Darwin::constructInvocation(const InterpretJobAction &job,
|
||||
static StringRef
|
||||
getDarwinLibraryNameSuffixForTriple(const llvm::Triple &triple,
|
||||
bool distinguishSimulator = true) {
|
||||
switch (getDarwinPlatformKind(triple)) {
|
||||
const DarwinPlatformKind kind = getDarwinPlatformKind(triple);
|
||||
const DarwinPlatformKind effectiveKind =
|
||||
distinguishSimulator ? kind : getNonSimulatorPlatform(kind);
|
||||
switch (effectiveKind) {
|
||||
case DarwinPlatformKind::MacOS:
|
||||
return "osx";
|
||||
case DarwinPlatformKind::IPhoneOSSimulator:
|
||||
if (distinguishSimulator)
|
||||
return "iossim";
|
||||
LLVM_FALLTHROUGH;
|
||||
case DarwinPlatformKind::IPhoneOS:
|
||||
return "ios";
|
||||
case DarwinPlatformKind::TvOSSimulator:
|
||||
if (distinguishSimulator)
|
||||
return "tvossim";
|
||||
LLVM_FALLTHROUGH;
|
||||
case DarwinPlatformKind::IPhoneOSSimulator:
|
||||
return "iossim";
|
||||
case DarwinPlatformKind::TvOS:
|
||||
return "tvos";
|
||||
case DarwinPlatformKind::WatchOSSimulator:
|
||||
if (distinguishSimulator)
|
||||
return "watchossim";
|
||||
LLVM_FALLTHROUGH;
|
||||
case DarwinPlatformKind::TvOSSimulator:
|
||||
return "tvossim";
|
||||
case DarwinPlatformKind::WatchOS:
|
||||
return "watchos";
|
||||
case DarwinPlatformKind::WatchOSSimulator:
|
||||
return "watchossim";
|
||||
}
|
||||
llvm_unreachable("Unsupported Darwin platform");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user