@@ -68,6 +68,176 @@ def call_without_sleeping(command, dry_run=False):
68
68
class BuildScriptInvocation (object ):
69
69
"""Represent a single build script invocation."""
70
70
71
+ @staticmethod
72
+ def apply_default_arguments (toolchain , args ):
73
+ """Preprocess an argument set to apply default behaviors."""
74
+
75
+ # Build cmark if any cmark-related options were specified.
76
+ if (args .cmark_build_variant is not None ):
77
+ args .build_cmark = True
78
+
79
+ # Build LLDB if any LLDB-related options were specified.
80
+ if args .lldb_build_variant is not None or \
81
+ args .lldb_assertions is not None :
82
+ args .build_lldb = True
83
+
84
+ # Set the default build variant.
85
+ if args .build_variant is None :
86
+ args .build_variant = "Debug"
87
+
88
+ # Propagate the default build variant.
89
+ if args .cmark_build_variant is None :
90
+ args .cmark_build_variant = args .build_variant
91
+
92
+ if args .llvm_build_variant is None :
93
+ args .llvm_build_variant = args .build_variant
94
+
95
+ if args .swift_build_variant is None :
96
+ args .swift_build_variant = args .build_variant
97
+
98
+ if args .swift_stdlib_build_variant is None :
99
+ args .swift_stdlib_build_variant = args .build_variant
100
+
101
+ if args .lldb_build_variant is None :
102
+ args .lldb_build_variant = args .build_variant
103
+
104
+ if args .foundation_build_variant is None :
105
+ args .foundation_build_variant = args .build_variant
106
+
107
+ if args .libdispatch_build_variant is None :
108
+ args .libdispatch_build_variant = args .build_variant
109
+
110
+ # Assertions are enabled by default.
111
+ if args .assertions is None :
112
+ args .assertions = True
113
+
114
+ # Propagate the default assertions setting.
115
+ if args .cmark_assertions is None :
116
+ args .cmark_assertions = args .assertions
117
+
118
+ if args .llvm_assertions is None :
119
+ args .llvm_assertions = args .assertions
120
+
121
+ if args .swift_assertions is None :
122
+ args .swift_assertions = args .assertions
123
+
124
+ if args .swift_stdlib_assertions is None :
125
+ args .swift_stdlib_assertions = args .assertions
126
+
127
+ # Set the default CMake generator.
128
+ if args .cmake_generator is None :
129
+ args .cmake_generator = "Ninja"
130
+
131
+ ninja_required = (
132
+ args .cmake_generator == 'Ninja' or args .build_foundation )
133
+ if ninja_required and toolchain .ninja is None :
134
+ args .build_ninja = True
135
+
136
+ # SwiftPM and XCTest have a dependency on Foundation.
137
+ # On OS X, Foundation is built automatically using xcodebuild.
138
+ # On Linux, we must ensure that it is built manually.
139
+ if ((args .build_swiftpm or args .build_xctest ) and
140
+ platform .system () != "Darwin" ):
141
+ args .build_foundation = True
142
+
143
+ # Propagate global --skip-build
144
+ if args .skip_build :
145
+ args .skip_build_linux = True
146
+ args .skip_build_freebsd = True
147
+ args .skip_build_cygwin = True
148
+ args .skip_build_osx = True
149
+ args .skip_build_ios = True
150
+ args .skip_build_tvos = True
151
+ args .skip_build_watchos = True
152
+ args .skip_build_android = True
153
+ args .skip_build_benchmarks = True
154
+ args .build_lldb = False
155
+ args .build_llbuild = False
156
+ args .build_swiftpm = False
157
+ args .build_xctest = False
158
+ args .build_foundation = False
159
+ args .build_libdispatch = False
160
+
161
+ # --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are
162
+ # merely shorthands for --skip-build-{**os}-{device,simulator}
163
+ if not args .ios or args .skip_build_ios :
164
+ args .skip_build_ios_device = True
165
+ args .skip_build_ios_simulator = True
166
+
167
+ if not args .tvos or args .skip_build_tvos :
168
+ args .skip_build_tvos_device = True
169
+ args .skip_build_tvos_simulator = True
170
+
171
+ if not args .watchos or args .skip_build_watchos :
172
+ args .skip_build_watchos_device = True
173
+ args .skip_build_watchos_simulator = True
174
+
175
+ if not args .android or args .skip_build_android :
176
+ args .skip_build_android = True
177
+
178
+ # --validation-test implies --test.
179
+ if args .validation_test :
180
+ args .test = True
181
+
182
+ # --test-optimized implies --test.
183
+ if args .test_optimized :
184
+ args .test = True
185
+
186
+ # If none of tests specified skip swift stdlib test on all platforms
187
+ if not args .test and not args .validation_test and not args .long_test :
188
+ args .skip_test_linux = True
189
+ args .skip_test_freebsd = True
190
+ args .skip_test_cygwin = True
191
+ args .skip_test_osx = True
192
+ args .skip_test_ios = True
193
+ args .skip_test_tvos = True
194
+ args .skip_test_watchos = True
195
+
196
+ # --skip-test-ios is merely a shorthand for host and simulator tests.
197
+ if args .skip_test_ios :
198
+ args .skip_test_ios_host = True
199
+ args .skip_test_ios_simulator = True
200
+ # --skip-test-tvos is merely a shorthand for host and simulator tests.
201
+ if args .skip_test_tvos :
202
+ args .skip_test_tvos_host = True
203
+ args .skip_test_tvos_simulator = True
204
+ # --skip-test-watchos is merely a shorthand for host and simulator
205
+ # --tests.
206
+ if args .skip_test_watchos :
207
+ args .skip_test_watchos_host = True
208
+ args .skip_test_watchos_simulator = True
209
+
210
+ # --skip-build-{ios,tvos,watchos}-{device,simulator} implies
211
+ # --skip-test-{ios,tvos,watchos}-{host,simulator}
212
+ if args .skip_build_ios_device :
213
+ args .skip_test_ios_host = True
214
+ if args .skip_build_ios_simulator :
215
+ args .skip_test_ios_simulator = True
216
+
217
+ if args .skip_build_tvos_device :
218
+ args .skip_test_tvos_host = True
219
+ if args .skip_build_tvos_simulator :
220
+ args .skip_test_tvos_simulator = True
221
+
222
+ if args .skip_build_watchos_device :
223
+ args .skip_test_watchos_host = True
224
+ if args .skip_build_watchos_simulator :
225
+ args .skip_test_watchos_simulator = True
226
+
227
+ if not args .host_test :
228
+ args .skip_test_ios_host = True
229
+ args .skip_test_tvos_host = True
230
+ args .skip_test_watchos_host = True
231
+
232
+ if args .build_subdir is None :
233
+ args .build_subdir = \
234
+ swift_build_support .workspace .compute_build_subdir (args )
235
+
236
+ # Add optional stdlib-deployment-targets
237
+ if args .android :
238
+ args .stdlib_deployment_targets .append (
239
+ StdlibDeploymentTarget .Android .armv7 )
240
+
71
241
def __init__ (self , toolchain , args ):
72
242
self .toolchain = toolchain
73
243
self .args = args
@@ -1123,171 +1293,9 @@ details of the setups of other systems or automated environments.""")
1123
1293
"and --android-icu-i18n-include must be "
1124
1294
"specified" )
1125
1295
1126
- # Build cmark if any cmark-related options were specified.
1127
- if (args .cmark_build_variant is not None ):
1128
- args .build_cmark = True
1129
-
1130
- # Build LLDB if any LLDB-related options were specified.
1131
- if args .lldb_build_variant is not None or \
1132
- args .lldb_assertions is not None :
1133
- args .build_lldb = True
1134
-
1135
- # Set the default build variant.
1136
- if args .build_variant is None :
1137
- args .build_variant = "Debug"
1138
-
1139
- # Propagate the default build variant.
1140
- if args .cmark_build_variant is None :
1141
- args .cmark_build_variant = args .build_variant
1142
-
1143
- if args .llvm_build_variant is None :
1144
- args .llvm_build_variant = args .build_variant
1145
-
1146
- if args .swift_build_variant is None :
1147
- args .swift_build_variant = args .build_variant
1148
-
1149
- if args .swift_stdlib_build_variant is None :
1150
- args .swift_stdlib_build_variant = args .build_variant
1151
-
1152
- if args .lldb_build_variant is None :
1153
- args .lldb_build_variant = args .build_variant
1154
-
1155
- if args .foundation_build_variant is None :
1156
- args .foundation_build_variant = args .build_variant
1157
-
1158
- if args .libdispatch_build_variant is None :
1159
- args .libdispatch_build_variant = args .build_variant
1160
-
1161
- # Assertions are enabled by default.
1162
- if args .assertions is None :
1163
- args .assertions = True
1164
-
1165
- # Propagate the default assertions setting.
1166
- if args .cmark_assertions is None :
1167
- args .cmark_assertions = args .assertions
1168
-
1169
- if args .llvm_assertions is None :
1170
- args .llvm_assertions = args .assertions
1171
-
1172
- if args .swift_assertions is None :
1173
- args .swift_assertions = args .assertions
1174
-
1175
- if args .swift_stdlib_assertions is None :
1176
- args .swift_stdlib_assertions = args .assertions
1177
-
1178
- # Set the default CMake generator.
1179
- if args .cmake_generator is None :
1180
- args .cmake_generator = "Ninja"
1181
-
1182
- ninja_required = (
1183
- args .cmake_generator == 'Ninja' or args .build_foundation )
1184
- if ninja_required and toolchain .ninja is None :
1185
- args .build_ninja = True
1186
-
1187
- # SwiftPM and XCTest have a dependency on Foundation.
1188
- # On OS X, Foundation is built automatically using xcodebuild.
1189
- # On Linux, we must ensure that it is built manually.
1190
- if ((args .build_swiftpm or args .build_xctest ) and
1191
- platform .system () != "Darwin" ):
1192
- args .build_foundation = True
1193
-
1194
- # Propagate global --skip-build
1195
- if args .skip_build :
1196
- args .skip_build_linux = True
1197
- args .skip_build_freebsd = True
1198
- args .skip_build_cygwin = True
1199
- args .skip_build_osx = True
1200
- args .skip_build_ios = True
1201
- args .skip_build_tvos = True
1202
- args .skip_build_watchos = True
1203
- args .skip_build_android = True
1204
- args .skip_build_benchmarks = True
1205
- args .build_lldb = False
1206
- args .build_llbuild = False
1207
- args .build_swiftpm = False
1208
- args .build_xctest = False
1209
- args .build_foundation = False
1210
- args .build_libdispatch = False
1211
-
1212
- # --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are
1213
- # merely shorthands for --skip-build-{**os}-{device,simulator}
1214
- if not args .ios or args .skip_build_ios :
1215
- args .skip_build_ios_device = True
1216
- args .skip_build_ios_simulator = True
1217
-
1218
- if not args .tvos or args .skip_build_tvos :
1219
- args .skip_build_tvos_device = True
1220
- args .skip_build_tvos_simulator = True
1221
-
1222
- if not args .watchos or args .skip_build_watchos :
1223
- args .skip_build_watchos_device = True
1224
- args .skip_build_watchos_simulator = True
1225
-
1226
- if not args .android or args .skip_build_android :
1227
- args .skip_build_android = True
1228
-
1229
- # --validation-test implies --test.
1230
- if args .validation_test :
1231
- args .test = True
1232
-
1233
- # --test-optimized implies --test.
1234
- if args .test_optimized :
1235
- args .test = True
1236
-
1237
- # If none of tests specified skip swift stdlib test on all platforms
1238
- if not args .test and not args .validation_test and not args .long_test :
1239
- args .skip_test_linux = True
1240
- args .skip_test_freebsd = True
1241
- args .skip_test_cygwin = True
1242
- args .skip_test_osx = True
1243
- args .skip_test_ios = True
1244
- args .skip_test_tvos = True
1245
- args .skip_test_watchos = True
1246
-
1247
- # --skip-test-ios is merely a shorthand for host and simulator tests.
1248
- if args .skip_test_ios :
1249
- args .skip_test_ios_host = True
1250
- args .skip_test_ios_simulator = True
1251
- # --skip-test-tvos is merely a shorthand for host and simulator tests.
1252
- if args .skip_test_tvos :
1253
- args .skip_test_tvos_host = True
1254
- args .skip_test_tvos_simulator = True
1255
- # --skip-test-watchos is merely a shorthand for host and simulator tests.
1256
- if args .skip_test_watchos :
1257
- args .skip_test_watchos_host = True
1258
- args .skip_test_watchos_simulator = True
1259
-
1260
- # --skip-build-{ios,tvos,watchos}-{device,simulator} implies
1261
- # --skip-test-{ios,tvos,watchos}-{host,simulator}
1262
- if args .skip_build_ios_device :
1263
- args .skip_test_ios_host = True
1264
- if args .skip_build_ios_simulator :
1265
- args .skip_test_ios_simulator = True
1266
-
1267
- if args .skip_build_tvos_device :
1268
- args .skip_test_tvos_host = True
1269
- if args .skip_build_tvos_simulator :
1270
- args .skip_test_tvos_simulator = True
1271
-
1272
- if args .skip_build_watchos_device :
1273
- args .skip_test_watchos_host = True
1274
- if args .skip_build_watchos_simulator :
1275
- args .skip_test_watchos_simulator = True
1276
-
1277
- if not args .host_test :
1278
- args .skip_test_ios_host = True
1279
- args .skip_test_tvos_host = True
1280
- args .skip_test_watchos_host = True
1281
-
1282
- if args .build_subdir is None :
1283
- args .build_subdir = swift_build_support .workspace .compute_build_subdir (
1284
- args )
1285
-
1286
- # Add optional stdlib-deployment-targets
1287
- if args .android :
1288
- args .stdlib_deployment_targets .append (
1289
- StdlibDeploymentTarget .Android .armv7 )
1290
-
1296
+ # Preprocess the arguments to apply defaults.
1297
+ BuildScriptInvocation .apply_default_arguments (toolchain , args )
1298
+
1291
1299
# Create the build script invocation.
1292
1300
invocation = BuildScriptInvocation (toolchain , args )
1293
1301
0 commit comments