Skip to content

Commit d3613b8

Browse files
committed
[Platform] Support triple.isSimulatorEnvironment()
1 parent 3807b3f commit d3613b8

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

lib/Basic/Platform.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,37 @@ using namespace swift;
1818
bool swift::tripleIsiOSSimulator(const llvm::Triple &triple) {
1919
llvm::Triple::ArchType arch = triple.getArch();
2020
return (triple.isiOS() &&
21-
(arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
21+
// FIXME: transitional, this should eventually stop testing arch, and
22+
// switch to only checking the -environment field.
23+
(triple.isSimulatorEnvironment() ||
24+
arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
2225
}
2326

2427
bool swift::tripleIsAppleTVSimulator(const llvm::Triple &triple) {
2528
llvm::Triple::ArchType arch = triple.getArch();
2629
return (triple.isTvOS() &&
27-
(arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
30+
// FIXME: transitional, this should eventually stop testing arch, and
31+
// switch to only checking the -environment field.
32+
(triple.isSimulatorEnvironment() ||
33+
arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
2834
}
2935

3036
bool swift::tripleIsWatchSimulator(const llvm::Triple &triple) {
3137
llvm::Triple::ArchType arch = triple.getArch();
3238
return (triple.isWatchOS() &&
33-
(arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
39+
// FIXME: transitional, this should eventually stop testing arch, and
40+
// switch to only checking the -environment field.
41+
(triple.isSimulatorEnvironment() ||
42+
arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
3443
}
3544

3645
bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
37-
return tripleIsiOSSimulator(triple) ||
38-
tripleIsWatchSimulator(triple) ||
39-
tripleIsAppleTVSimulator(triple);
46+
// FIXME: transitional, this should eventually just use the -environment
47+
// field.
48+
return triple.isSimulatorEnvironment() ||
49+
tripleIsiOSSimulator(triple) ||
50+
tripleIsWatchSimulator(triple) ||
51+
tripleIsAppleTVSimulator(triple);
4052
}
4153

4254
DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) {

test/Parse/ConditionalCompilation/simulatorTargetEnv.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %swift -typecheck %s -verify -target x86_64-apple-ios7.0 -parse-stdlib
2+
// RUN: %swift -typecheck %s -verify -target x86_64-unknown-linux-simulator -parse-stdlib
23
// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-apple-ios7.0
34

45
#if !targetEnvironment(simulator)

0 commit comments

Comments
 (0)