|
19 | 19 | using namespace swift; |
20 | 20 |
|
21 | 21 | bool swift::tripleIsiOSSimulator(const llvm::Triple &triple) { |
22 | | - llvm::Triple::ArchType arch = triple.getArch(); |
23 | 22 | return (triple.isiOS() && |
24 | 23 | !tripleIsMacCatalystEnvironment(triple) && |
25 | | - // FIXME: transitional, this should eventually stop testing arch, and |
26 | | - // switch to only checking the -environment field. |
27 | | - (triple.isSimulatorEnvironment() || |
28 | | - arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)); |
| 24 | + triple.isSimulatorEnvironment()); |
29 | 25 | } |
30 | 26 |
|
31 | 27 | bool swift::tripleIsAppleTVSimulator(const llvm::Triple &triple) { |
32 | | - llvm::Triple::ArchType arch = triple.getArch(); |
33 | | - return (triple.isTvOS() && |
34 | | - // FIXME: transitional, this should eventually stop testing arch, and |
35 | | - // switch to only checking the -environment field. |
36 | | - (triple.isSimulatorEnvironment() || |
37 | | - arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)); |
| 28 | + return (triple.isTvOS() && triple.isSimulatorEnvironment()); |
38 | 29 | } |
39 | 30 |
|
40 | 31 | bool swift::tripleIsWatchSimulator(const llvm::Triple &triple) { |
41 | | - llvm::Triple::ArchType arch = triple.getArch(); |
42 | | - return (triple.isWatchOS() && |
43 | | - // FIXME: transitional, this should eventually stop testing arch, and |
44 | | - // switch to only checking the -environment field. |
45 | | - (triple.isSimulatorEnvironment() || |
46 | | - arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)); |
47 | | -} |
48 | | - |
49 | | -bool swift::tripleIsAnySimulator(const llvm::Triple &triple) { |
50 | | - // FIXME: transitional, this should eventually just use the -environment |
51 | | - // field. |
52 | | - return triple.isSimulatorEnvironment() || |
53 | | - tripleIsiOSSimulator(triple) || |
54 | | - tripleIsWatchSimulator(triple) || |
55 | | - tripleIsAppleTVSimulator(triple); |
| 32 | + return (triple.isWatchOS() && triple.isSimulatorEnvironment()); |
56 | 33 | } |
57 | 34 |
|
58 | 35 | bool swift::tripleIsMacCatalystEnvironment(const llvm::Triple &triple) { |
59 | 36 | return triple.isiOS() && !triple.isTvOS() && |
60 | 37 | triple.getEnvironment() == llvm::Triple::MacABI; |
61 | 38 | } |
62 | 39 |
|
| 40 | +bool swift::tripleInfersSimulatorEnvironment(const llvm::Triple &triple) { |
| 41 | + switch (triple.getOS()) { |
| 42 | + case llvm::Triple::IOS: |
| 43 | + case llvm::Triple::TvOS: |
| 44 | + case llvm::Triple::WatchOS: |
| 45 | + return !triple.hasEnvironment() && |
| 46 | + (triple.getArch() == llvm::Triple::x86 || |
| 47 | + triple.getArch() == llvm::Triple::x86_64) && |
| 48 | + !tripleIsMacCatalystEnvironment(triple); |
| 49 | + |
| 50 | + default: |
| 51 | + return false; |
| 52 | + } |
| 53 | +} |
| 54 | + |
63 | 55 | bool swift::triplesAreValidForZippering(const llvm::Triple &target, |
64 | 56 | const llvm::Triple &targetVariant) { |
65 | 57 | // The arch and vendor must match. |
@@ -327,14 +319,6 @@ getOSForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) { |
327 | 319 | static Optional<StringRef> |
328 | 320 | getEnvironmentForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) { |
329 | 321 | auto tripleEnvironment = triple.getEnvironmentName(); |
330 | | - |
331 | | - // If the environment is empty, infer a "simulator" environment based on the |
332 | | - // OS and architecture combination. This feature is deprecated and exists for |
333 | | - // backwards compatibility only; build systems should pass the "simulator" |
334 | | - // environment explicitly if they know they're building for a simulator. |
335 | | - if (tripleEnvironment == "" && swift::tripleIsAnySimulator(triple)) |
336 | | - return StringRef("simulator"); |
337 | | - |
338 | 322 | return llvm::StringSwitch<Optional<StringRef>>(tripleEnvironment) |
339 | 323 | .Cases("unknown", "", None) |
340 | 324 | // These values are also supported, but are handled by the default case below: |
|
0 commit comments