Skip to content

Commit c2556eb

Browse files
graydonjrose-apple
authored andcommitted
<rdar://43616773> Add swift::tripleHasSwiftInTheOS helper.
1 parent 2cfcdf4 commit c2556eb

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

include/swift/Basic/Platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ namespace swift {
4646
/// Return true if the given triple represents any simulator.
4747
bool tripleIsAnySimulator(const llvm::Triple &triple);
4848

49+
/// Returns true if the given triple represents an OS that ships with ABI-stable
50+
/// swift libraries (eg. in /usr/lib/swift).
51+
bool tripleHasSwiftInTheOS(const llvm::Triple &triple);
52+
4953
/// Returns the platform name for a given target triple.
5054
///
5155
/// For example, the iOS simulator has the name "iphonesimulator", while real

lib/Basic/Platform.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
5454
tripleIsAppleTVSimulator(triple);
5555
}
5656

57+
58+
bool swift::tripleHasSwiftInTheOS(const llvm::Triple &triple) {
59+
unsigned major, minor, revision;
60+
if (triple.isMacOSX()) {
61+
triple.getMacOSXVersion(major, minor, revision);
62+
return llvm::VersionTuple(major, minor, revision) >=
63+
llvm::VersionTuple(10, 14, 4);
64+
} else if (triple.isiOS()) {
65+
triple.getiOSVersion(major, minor, revision);
66+
return llvm::VersionTuple(major, minor, revision) >=
67+
llvm::VersionTuple(12, 2);
68+
} else if (triple.isWatchOS()) {
69+
triple.getOSVersion(major, minor, revision);
70+
return llvm::VersionTuple(major, minor, revision) >=
71+
llvm::VersionTuple(5, 2);
72+
}
73+
return false;
74+
}
75+
5776
DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) {
5877
if (triple.isiOS()) {
5978
if (triple.isTvOS()) {

0 commit comments

Comments
 (0)