|
12 | 12 | import platform
|
13 | 13 |
|
14 | 14 |
|
| 15 | +class Platform(object): |
| 16 | + """ |
| 17 | + Abstract representation of a platform Swift can run on. |
| 18 | + """ |
| 19 | + |
| 20 | + def __init__(self, name, archs): |
| 21 | + """ |
| 22 | + Create a platform with the given name and list of architectures. |
| 23 | + """ |
| 24 | + self.name = name |
| 25 | + self.targets = [Target(self, arch) for arch in archs] |
| 26 | + |
| 27 | + # Add a property for each arch. |
| 28 | + for target in self.targets: |
| 29 | + setattr(self, target.arch, target) |
| 30 | + |
| 31 | + |
| 32 | +class Target(object): |
| 33 | + """ |
| 34 | + Abstract representation of a target Swift can run on. |
| 35 | + """ |
| 36 | + |
| 37 | + def __init__(self, platform, arch): |
| 38 | + self.platform = platform |
| 39 | + self.arch = arch |
| 40 | + |
| 41 | + @property |
| 42 | + def name(self): |
| 43 | + return "{}-{}".format(self.platform.name, self.arch) |
| 44 | + |
| 45 | + |
15 | 46 | class StdlibDeploymentTarget(object):
|
| 47 | + OSX = Platform("macosx", archs=["x86_64"]) |
| 48 | + |
| 49 | + iOS = Platform("iphoneos", archs=["armv7", "armv7s", "arm64"]) |
| 50 | + iOSSimulator = Platform("iphonesimulator", archs=["i386", "x86_64"]) |
| 51 | + |
| 52 | + AppleTV = Platform("appletvos", archs=["arm64"]) |
| 53 | + AppleTVSimulator = Platform("appletvsimulator", archs=["x86_64"]) |
| 54 | + |
| 55 | + AppleWatch = Platform("watchos", archs=["armv7k"]) |
| 56 | + AppleWatchSimulator = Platform("watchsimulator", archs=["i386"]) |
| 57 | + |
| 58 | + Linux = Platform("linux", archs=[ |
| 59 | + "x86_64", |
| 60 | + "armv6", |
| 61 | + "armv7", |
| 62 | + "aarch64", |
| 63 | + "ppc64", |
| 64 | + "ppc64le", |
| 65 | + "s390x"]) |
| 66 | + |
| 67 | + FreeBSD = Platform("freebsd", archs=["x86_64"]) |
16 | 68 |
|
17 |
| - class OSX(object): |
18 |
| - x86_64 = 'macosx-x86_64' |
19 |
| - allArchs = [x86_64] |
20 |
| - |
21 |
| - class iOS(object): # noqa |
22 |
| - armv7 = 'iphoneos-armv7' |
23 |
| - armv7s = 'iphoneos-armv7s' |
24 |
| - arm64 = 'iphoneos-arm64' |
25 |
| - allArchs = [armv7, armv7s, arm64] |
26 |
| - |
27 |
| - class iOSSimulator(object): # noqa |
28 |
| - i386 = 'iphonesimulator-i386' |
29 |
| - x86_64 = 'iphonesimulator-x86_64' |
30 |
| - allArchs = [i386, x86_64] |
31 |
| - |
32 |
| - class AppleTV(object): |
33 |
| - arm64 = 'appletvos-arm64' |
34 |
| - allArchs = [arm64] |
35 |
| - |
36 |
| - class AppleTVSimulator(object): |
37 |
| - x86_64 = 'appletvsimulator-x86_64' |
38 |
| - allArchs = [x86_64] |
39 |
| - |
40 |
| - class AppleWatch(object): |
41 |
| - armv7k = 'watchos-armv7k' |
42 |
| - allArchs = [armv7k] |
43 |
| - |
44 |
| - class AppleWatchSimulator(object): |
45 |
| - i386 = 'watchsimulator-i386' |
46 |
| - allArchs = [i386] |
47 |
| - |
48 |
| - class Linux(object): |
49 |
| - x86_64 = 'linux-x86_64' |
50 |
| - armv6 = 'linux-armv6' |
51 |
| - armv7 = 'linux-armv7' |
52 |
| - aarch64 = 'linux-aarch64' |
53 |
| - ppc64 = 'linux-ppc64' |
54 |
| - ppc64le = 'linux-ppc64le' |
55 |
| - s390x = 'linux-s390x' |
56 |
| - allArchs = [x86_64, armv6, armv7, aarch64, ppc64, ppc64le, s390x] |
57 |
| - |
58 |
| - class FreeBSD(object): |
59 |
| - amd64 = 'freebsd-x86_64' |
60 |
| - allArchs = [amd64] |
61 |
| - |
62 |
| - class Cygwin(object): |
63 |
| - x86_64 = 'cygwin-x86_64' |
64 |
| - allArchs = [x86_64] |
65 |
| - |
66 |
| - class Android(object): |
67 |
| - armv7 = 'android-armv7' |
68 |
| - allArchs = [armv7] |
| 69 | + Cygwin = Platform("cygwin", archs=["x86_64"]) |
69 | 70 |
|
70 | 71 | @staticmethod
|
71 | 72 | def host_target():
|
@@ -124,12 +125,12 @@ def default_stdlib_deployment_targets():
|
124 | 125 | # (it takes a long time).
|
125 | 126 | if host_target == StdlibDeploymentTarget.OSX.x86_64:
|
126 | 127 | return [host_target] + \
|
127 |
| - StdlibDeploymentTarget.iOSSimulator.allArchs + \ |
128 |
| - StdlibDeploymentTarget.AppleTVSimulator.allArchs + \ |
129 |
| - StdlibDeploymentTarget.AppleWatchSimulator.allArchs + \ |
130 |
| - StdlibDeploymentTarget.iOS.allArchs + \ |
131 |
| - StdlibDeploymentTarget.AppleTV.allArchs + \ |
132 |
| - StdlibDeploymentTarget.AppleWatch.allArchs |
| 128 | + StdlibDeploymentTarget.iOSSimulator.targets + \ |
| 129 | + StdlibDeploymentTarget.AppleTVSimulator.targets + \ |
| 130 | + StdlibDeploymentTarget.AppleWatchSimulator.targets + \ |
| 131 | + StdlibDeploymentTarget.iOS.targets + \ |
| 132 | + StdlibDeploymentTarget.AppleTV.targets + \ |
| 133 | + StdlibDeploymentTarget.AppleWatch.targets |
133 | 134 | else:
|
134 | 135 | # All other machines only configure their host stdlib by default.
|
135 | 136 | return [host_target]
|
|
0 commit comments