|
12 | 12 | import platform
|
13 | 13 |
|
14 | 14 |
|
15 |
| -def host_target(): |
16 |
| - """ |
17 |
| - Return the build target for the current host machine, if it is one of the |
18 |
| - recognized targets. Otherwise, return None. |
19 |
| - """ |
20 |
| - system = platform.system() |
21 |
| - machine = platform.machine() |
22 |
| - |
23 |
| - if system == 'Linux': |
24 |
| - if machine == 'x86_64': |
25 |
| - return 'linux-x86_64' |
26 |
| - elif machine.startswith('armv7'): |
27 |
| - # linux-armv7* is canonicalized to 'linux-armv7' |
28 |
| - return 'linux-armv7' |
29 |
| - elif machine.startswith('armv6'): |
30 |
| - # linux-armv6* is canonicalized to 'linux-armv6' |
31 |
| - return 'linux-armv6' |
32 |
| - elif machine == 'aarch64': |
33 |
| - return 'linux-aarch64' |
34 |
| - elif machine == 'ppc64': |
35 |
| - return 'linux-powerpc64' |
36 |
| - elif machine == 'ppc64le': |
37 |
| - return 'linux-powerpc64le' |
38 |
| - elif machine == 's390x': |
39 |
| - return 'linux-s390x' |
40 |
| - |
41 |
| - elif system == 'Darwin': |
42 |
| - if machine == 'x86_64': |
43 |
| - return 'macosx-x86_64' |
44 |
| - |
45 |
| - elif system == 'FreeBSD': |
46 |
| - if machine == 'amd64': |
47 |
| - return 'freebsd-x86_64' |
48 |
| - |
49 |
| - elif system == 'CYGWIN_NT-10.0': |
50 |
| - if machine == 'x86_64': |
51 |
| - return 'cygwin-x86_64' |
52 |
| - |
53 |
| - return None |
54 |
| - |
55 |
| - |
56 |
| -def stdlib_deployment_targets(): |
57 |
| - """ |
58 |
| - Return deployment targets for the Swift stdlib, based on the host machine. |
59 |
| - If the host machine is not one of the recognized ones, return None. |
60 |
| - """ |
61 |
| - system = platform.system() |
62 |
| - machine = platform.machine() |
63 |
| - |
64 |
| - if system == 'Linux': |
65 |
| - if machine == 'x86_64': |
66 |
| - return [ |
67 |
| - 'linux-x86_64', |
68 |
| - 'android-armv7', |
69 |
| - ] |
70 |
| - elif machine.startswith('armv6'): |
71 |
| - # linux-armv6* is canonicalized to 'linux-armv6' |
72 |
| - return ['linux-armv6'] |
73 |
| - elif machine.startswith('armv7'): |
74 |
| - # linux-armv7* is canonicalized to 'linux-armv7' |
75 |
| - return ['linux-armv7'] |
76 |
| - elif machine == 'aarch64': |
77 |
| - return ['linux-aarch64'] |
78 |
| - elif machine == 'ppc64': |
79 |
| - return ['linux-powerpc64'] |
80 |
| - elif machine == 'ppc64le': |
81 |
| - return ['linux-powerpc64le'] |
82 |
| - elif machine == 's390x': |
83 |
| - return ['linux-s390x'] |
84 |
| - elif system == 'Darwin': |
85 |
| - if machine == 'x86_64': |
86 |
| - return [ |
87 |
| - 'macosx-x86_64', |
88 |
| - 'iphonesimulator-i386', |
89 |
| - 'iphonesimulator-x86_64', |
90 |
| - 'appletvsimulator-x86_64', |
91 |
| - 'watchsimulator-i386', |
92 |
| - # Put iOS native targets last so that we test them last |
93 |
| - # (it takes a long time). |
94 |
| - 'iphoneos-arm64', |
95 |
| - 'iphoneos-armv7', |
96 |
| - 'appletvos-arm64', |
97 |
| - 'watchos-armv7k', |
98 |
| - ] |
99 |
| - elif system == 'FreeBSD': |
100 |
| - if machine == 'amd64': |
101 |
| - return ['freebsd-x86_64'] |
102 |
| - elif system == 'CYGWIN_NT-10.0': |
103 |
| - if machine == 'x86_64': |
104 |
| - return ['cygwin-x86_64'] |
105 |
| - |
106 |
| - return None |
| 15 | +class StdlibDeploymentTarget(object): |
| 16 | + |
| 17 | + class OSX(object): |
| 18 | + x86_64 = 'macosx-x86_64' |
| 19 | + allArchs = [x86_64] |
| 20 | + |
| 21 | + class iOS(object): |
| 22 | + armv7 = 'iphoneos-armv7' |
| 23 | + armv7s = 'iphoneos-armv7s' |
| 24 | + arm64 = 'iphoneos-arm64' |
| 25 | + allArchs = [armv7, armv7s, arm64] |
| 26 | + |
| 27 | + class iOSSimulator(object): |
| 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 | + |
| 70 | + @staticmethod |
| 71 | + def host_target(): |
| 72 | + """ |
| 73 | + Return the host target for the build machine, if it is one of |
| 74 | + the recognized targets. Otherwise, return None. |
| 75 | + """ |
| 76 | + system = platform.system() |
| 77 | + machine = platform.machine() |
| 78 | + |
| 79 | + if system == 'Linux': |
| 80 | + if machine == 'x86_64': |
| 81 | + return StdlibDeploymentTarget.Linux.x86_64 |
| 82 | + elif machine.startswith('armv7'): |
| 83 | + # linux-armv7* is canonicalized to 'linux-armv7' |
| 84 | + return StdlibDeploymentTarget.Linux.armv7 |
| 85 | + elif machine.startswith('armv6'): |
| 86 | + # linux-armv6* is canonicalized to 'linux-armv6' |
| 87 | + return StdlibDeploymentTarget.Linux.armv6 |
| 88 | + elif machine == 'aarch64': |
| 89 | + return StdlibDeploymentTarget.Linux.aarch64 |
| 90 | + elif machine == 'ppc64': |
| 91 | + return StdlibDeploymentTarget.Linux.ppc64 |
| 92 | + elif machine == 'ppc64le': |
| 93 | + return StdlibDeploymentTarget.Linux.ppc64le |
| 94 | + elif machine == 's390x': |
| 95 | + return StdlibDeploymentTarget.Linux.s390x |
| 96 | + |
| 97 | + elif system == 'Darwin': |
| 98 | + if machine == 'x86_64': |
| 99 | + return StdlibDeploymentTarget.OSX.x86_64 |
| 100 | + |
| 101 | + elif system == 'FreeBSD': |
| 102 | + if machine == 'amd64': |
| 103 | + return StdlibDeploymentTarget.FreeBSD.amd64 |
| 104 | + |
| 105 | + elif system == 'CYGWIN_NT-10.0': |
| 106 | + if machine == 'x86_64': |
| 107 | + return StdlibDeploymentTarget.Cygwin.x86_64 |
| 108 | + |
| 109 | + return None |
| 110 | + |
| 111 | + @staticmethod |
| 112 | + def default_stdlib_deployment_targets(): |
| 113 | + """ |
| 114 | + Return targets for the Swift stdlib, based on the build machine. |
| 115 | + If the build machine is not one of the recognized ones, return None. |
| 116 | + """ |
| 117 | + |
| 118 | + host_target = StdlibDeploymentTarget.host_target() |
| 119 | + if host_target is None: |
| 120 | + return None |
| 121 | + |
| 122 | + # OSX build machines configure all Darwin platforms by default. |
| 123 | + # Put iOS native targets last so that we test them last |
| 124 | + # (it takes a long time). |
| 125 | + if host_target == StdlibDeploymentTarget.OSX.x86_64: |
| 126 | + 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 |
| 133 | + else: |
| 134 | + # All other machines only configure their host stdlib by default. |
| 135 | + return [host_target] |
107 | 136 |
|
108 | 137 |
|
109 | 138 | def install_prefix():
|
|
0 commit comments