@@ -245,227 +245,14 @@ class BuildScriptInvocation(object):
245
245
246
246
@staticmethod
247
247
def apply_default_arguments (toolchain , args ):
248
- """Preprocess an argument set to apply default behaviors."""
249
-
250
- # Build cmark if any cmark-related options were specified.
251
- if (args .cmark_build_variant is not None ):
252
- args .build_cmark = True
253
-
254
- # Build LLDB if any LLDB-related options were specified.
255
- if args .lldb_build_variant is not None or \
256
- args .lldb_assertions is not None :
257
- args .build_lldb = True
258
-
259
- # Set the default build variant.
260
- if args .build_variant is None :
261
- args .build_variant = "Debug"
262
-
263
- # Set the default stdlib-deployment-targets, if none were provided.
264
- if args .stdlib_deployment_targets is None :
265
- stdlib_targets = \
266
- StdlibDeploymentTarget .default_stdlib_deployment_targets ()
267
- args .stdlib_deployment_targets = [
268
- target .name for target in stdlib_targets ]
269
-
270
- if args .llvm_build_variant is None :
271
- args .llvm_build_variant = args .build_variant
272
-
273
- if args .swift_build_variant is None :
274
- args .swift_build_variant = args .build_variant
275
-
276
- if args .swift_stdlib_build_variant is None :
277
- args .swift_stdlib_build_variant = args .build_variant
278
-
279
- if args .cmark_build_variant is None :
280
- args .cmark_build_variant = args .swift_build_variant
281
-
282
- if args .lldb_build_variant is None :
283
- args .lldb_build_variant = args .build_variant
284
-
285
- if args .foundation_build_variant is None :
286
- args .foundation_build_variant = args .build_variant
287
-
288
- if args .libdispatch_build_variant is None :
289
- args .libdispatch_build_variant = args .build_variant
290
-
291
- if args .libicu_build_variant is None :
292
- args .libicu_build_variant = args .build_variant
293
-
294
- # Assertions are enabled by default.
295
- if args .assertions is None :
296
- args .assertions = True
297
-
298
- # Propagate the default assertions setting.
299
- if args .cmark_assertions is None :
300
- args .cmark_assertions = args .assertions
301
-
302
- if args .llvm_assertions is None :
303
- args .llvm_assertions = args .assertions
304
-
305
- if args .swift_assertions is None :
306
- args .swift_assertions = args .assertions
307
-
308
- if args .swift_stdlib_assertions is None :
309
- args .swift_stdlib_assertions = args .assertions
310
-
311
- # Set the default CMake generator.
312
- if args .cmake_generator is None :
313
- args .cmake_generator = "Ninja"
314
-
315
- # --ios-all etc are not supported by open-source Swift.
316
- if args .ios_all :
317
- exit_rejecting_arguments ("error: --ios-all is unavailable in " +
318
- "open-source Swift.\n Use --ios to " +
319
- "skip iOS device tests." )
320
-
321
- if args .tvos_all :
322
- exit_rejecting_arguments ("error: --tvos-all is unavailable in " +
323
- "open-source Swift.\n Use --tvos to " +
324
- "skip tvOS device tests." )
325
-
326
- if args .watchos_all :
327
- exit_rejecting_arguments ("error: --watchos-all is unavailable " +
328
- "in open-source Swift.\n Use --watchos " +
329
- "to skip watchOS device tests." )
248
+ driver_arguments .apply_default_arguments (args )
330
249
250
+ # infer if ninja is required
331
251
ninja_required = (
332
252
args .cmake_generator == 'Ninja' or args .build_foundation )
333
253
if ninja_required and toolchain .ninja is None :
334
254
args .build_ninja = True
335
255
336
- # SwiftPM and XCTest have a dependency on Foundation.
337
- # On OS X, Foundation is built automatically using xcodebuild.
338
- # On Linux, we must ensure that it is built manually.
339
- if ((args .build_swiftpm or args .build_xctest ) and
340
- platform .system () != "Darwin" ):
341
- args .build_foundation = True
342
-
343
- # Foundation has a dependency on libdispatch.
344
- # On OS X, libdispatch is provided by the OS.
345
- # On Linux, we must ensure that it is built manually.
346
- if (args .build_foundation and
347
- platform .system () != "Darwin" ):
348
- args .build_libdispatch = True
349
-
350
- # Propagate global --skip-build
351
- if args .skip_build :
352
- args .skip_build_linux = True
353
- args .skip_build_freebsd = True
354
- args .skip_build_cygwin = True
355
- args .skip_build_osx = True
356
- args .skip_build_ios = True
357
- args .skip_build_tvos = True
358
- args .skip_build_watchos = True
359
- args .skip_build_android = True
360
- args .skip_build_benchmarks = True
361
- args .build_lldb = False
362
- args .build_llbuild = False
363
- args .build_swiftpm = False
364
- args .build_xctest = False
365
- args .build_foundation = False
366
- args .build_libdispatch = False
367
- args .build_libicu = False
368
- args .build_playgroundlogger = False
369
- args .build_playgroundsupport = False
370
-
371
- # --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are
372
- # merely shorthands for --skip-build-{**os}-{device,simulator}
373
- if not args .ios or args .skip_build_ios :
374
- args .skip_build_ios_device = True
375
- args .skip_build_ios_simulator = True
376
-
377
- if not args .tvos or args .skip_build_tvos :
378
- args .skip_build_tvos_device = True
379
- args .skip_build_tvos_simulator = True
380
-
381
- if not args .watchos or args .skip_build_watchos :
382
- args .skip_build_watchos_device = True
383
- args .skip_build_watchos_simulator = True
384
-
385
- if not args .android or args .skip_build_android :
386
- args .skip_build_android = True
387
-
388
- # --validation-test implies --test.
389
- if args .validation_test :
390
- args .test = True
391
-
392
- # --test-optimized implies --test.
393
- if args .test_optimized :
394
- args .test = True
395
-
396
- # --test-optimize-size implies --test.
397
- if args .test_optimize_for_size :
398
- args .test = True
399
-
400
- # If none of tests specified skip swift stdlib test on all platforms
401
- if not args .test and not args .validation_test and not args .long_test :
402
- args .skip_test_linux = True
403
- args .skip_test_freebsd = True
404
- args .skip_test_cygwin = True
405
- args .skip_test_osx = True
406
- args .skip_test_ios = True
407
- args .skip_test_tvos = True
408
- args .skip_test_watchos = True
409
-
410
- # --skip-test-ios is merely a shorthand for host and simulator tests.
411
- if args .skip_test_ios :
412
- args .skip_test_ios_host = True
413
- args .skip_test_ios_simulator = True
414
- # --skip-test-tvos is merely a shorthand for host and simulator tests.
415
- if args .skip_test_tvos :
416
- args .skip_test_tvos_host = True
417
- args .skip_test_tvos_simulator = True
418
- # --skip-test-watchos is merely a shorthand for host and simulator
419
- # --tests.
420
- if args .skip_test_watchos :
421
- args .skip_test_watchos_host = True
422
- args .skip_test_watchos_simulator = True
423
-
424
- # --skip-build-{ios,tvos,watchos}-{device,simulator} implies
425
- # --skip-test-{ios,tvos,watchos}-{host,simulator}
426
- if args .skip_build_ios_device :
427
- args .skip_test_ios_host = True
428
- if args .skip_build_ios_simulator :
429
- args .skip_test_ios_simulator = True
430
-
431
- if args .skip_build_tvos_device :
432
- args .skip_test_tvos_host = True
433
- if args .skip_build_tvos_simulator :
434
- args .skip_test_tvos_simulator = True
435
-
436
- if args .skip_build_watchos_device :
437
- args .skip_test_watchos_host = True
438
- if args .skip_build_watchos_simulator :
439
- args .skip_test_watchos_simulator = True
440
-
441
- if args .skip_build_android :
442
- args .skip_test_android_host = True
443
-
444
- if not args .host_test :
445
- args .skip_test_ios_host = True
446
- args .skip_test_tvos_host = True
447
- args .skip_test_watchos_host = True
448
- args .skip_test_android_host = True
449
-
450
- if args .build_subdir is None :
451
- args .build_subdir = \
452
- workspace .compute_build_subdir (args )
453
-
454
- # Add optional stdlib-deployment-targets
455
- if args .android :
456
- args .stdlib_deployment_targets .append (
457
- StdlibDeploymentTarget .Android .armv7 .name )
458
-
459
- # Infer platform flags from manually-specified configure targets.
460
- # This doesn't apply to Darwin platforms, as they are
461
- # already configured. No building without the platform flag, though.
462
-
463
- android_tgts = [tgt for tgt in args .stdlib_deployment_targets
464
- if StdlibDeploymentTarget .Android .contains (tgt )]
465
- if not args .android and len (android_tgts ) > 0 :
466
- args .android = True
467
- args .skip_build_android = True
468
-
469
256
# ---
470
257
471
258
def __init__ (self , toolchain , args ):
0 commit comments