@@ -65,6 +65,118 @@ def call_without_sleeping(command, env=None, dry_run=False):
65
65
shell .call (command , env = env , dry_run = dry_run )
66
66
67
67
68
+ class HostSpecificConfiguration (object ):
69
+ """Configuration information for an individual host."""
70
+
71
+ def __init__ (self , host_target , invocation ):
72
+ """Initialize for the given `host_target`."""
73
+
74
+ # Compute the set of deployment targets to configure/build.
75
+ args = invocation .args
76
+ if host_target == args .host_target :
77
+ # This host is the user's desired product, so honor the requested
78
+ # set of targets to configure/build.
79
+ stdlib_targets_to_configure = args .stdlib_deployment_targets
80
+ if "all" in args .build_stdlib_deployment_targets :
81
+ stdlib_targets_to_build = set (stdlib_targets_to_configure )
82
+ else :
83
+ stdlib_targets_to_build = set (
84
+ args .build_stdlib_deployment_targets ).intersect (
85
+ set (args .stdlib_deployment_targets ))
86
+ else :
87
+ # Otherwise, this is a host we are building as part of
88
+ # cross-compiling, so we only need the target itself.
89
+ stdlib_targets_to_configure = [host_target ]
90
+ stdlib_targets_to_build = set (stdlib_targets_to_configure )
91
+
92
+ # Compute the lists of **CMake** targets for each use case (configure
93
+ # vs. build vs. run) and the SDKs to configure with.
94
+ self .sdks_to_configure = set ()
95
+ self .swift_stdlib_build_targets = []
96
+ self .swift_test_run_targets = []
97
+ self .swift_benchmark_build_targets = []
98
+ self .swift_benchmark_run_targets = []
99
+ for deployment_target_name in stdlib_targets_to_configure :
100
+ # Get the target object.
101
+ deployment_target = StdlibDeploymentTarget .get_target_for_name (
102
+ deployment_target_name )
103
+ if deployment_target is None :
104
+ diagnostics .fatal ("unknown target: %r" % (
105
+ deployment_target_name ,))
106
+
107
+ # Add the SDK to use.
108
+ deployment_platform = deployment_target .platform
109
+ self .sdks_to_configure .add (deployment_platform .sdk_name )
110
+
111
+ # If we aren't actually building this target (only configuring
112
+ # it), do nothing else.
113
+ if deployment_target_name not in stdlib_targets_to_build :
114
+ continue
115
+
116
+ # Compute which actions are desired.
117
+ build = deployment_platform not in \
118
+ invocation .platforms_to_skip_build
119
+ test = deployment_platform not in \
120
+ invocation .platforms_to_skip_test
121
+ test_host_only = None
122
+ build_benchmark = build and deployment_target .supports_benchmark
123
+ # FIXME: Note, `build-script-impl` computed a property here
124
+ # w.r.t. testing, but it was actually unused.
125
+
126
+ # For platforms which normally require a connected device to
127
+ # test, the default behavior is to run tests that only require
128
+ # the host (i.e., they do not attempt to execute).
129
+ if deployment_platform .is_darwin and \
130
+ deployment_platform .is_embedded and \
131
+ not deployment_platform .is_simulator :
132
+ if deployment_platform not in \
133
+ invocation .platforms_to_skip_test_host :
134
+ test_host_only = True
135
+ test = True
136
+ else :
137
+ test = False
138
+
139
+ name = deployment_target .name
140
+ if build :
141
+ # Validation and long tests require building the full standard
142
+ # library, whereas the other targets can build a slightly
143
+ # smaller subset which is faster to build.
144
+ if args .build_swift_stdlib_unittest_extra or \
145
+ args .validation_test or args .long_test :
146
+ self .swift_stdlib_build_targets .append (
147
+ "swift-stdlib-" + name )
148
+ else :
149
+ self .swift_stdlib_build_targets .append (
150
+ "swift-test-stdlib-" + name )
151
+ if build_benchmark :
152
+ self .swift_benchmark_build_targets .append (
153
+ "swift-benchmark-" + name )
154
+ # FIXME: This probably should respect `args.benchmark`, but
155
+ # a typo in build-script-impl meant we always would do this.
156
+ self .swift_benchmark_run_targets .append (
157
+ "check-swift-benchmark-" + name )
158
+ if test :
159
+ if test_host_only :
160
+ suffix = "-non-executable"
161
+ else :
162
+ suffix = ""
163
+ subset_suffix = ""
164
+ if args .validation_test and args .long_test :
165
+ subset_suffix = "-all"
166
+ elif args .validation_test :
167
+ subset_suffix = "-validation"
168
+ elif args .long_test :
169
+ subset_suffix = "-only_long"
170
+ else :
171
+ subset_suffix = ""
172
+ self .swift_test_run_targets .append ("check-swift{}{}-{}" .format (
173
+ subset_suffix , suffix , name ))
174
+ if args .test_optimized and not test_host_only :
175
+ self .swift_test_run_targets .append (
176
+ "check-swift{}-optimize-{}" .format (
177
+ subset_suffix , name ))
178
+
179
+
68
180
class BuildScriptInvocation (object ):
69
181
"""Represent a single build script invocation."""
70
182
@@ -291,6 +403,77 @@ class BuildScriptInvocation(object):
291
403
source_root = SWIFT_SOURCE_ROOT ,
292
404
build_root = os .path .join (SWIFT_BUILD_ROOT , args .build_subdir ))
293
405
406
+ # Compute derived information from the arguments.
407
+ #
408
+ # FIXME: We should move the platform-derived arguments to be entirely
409
+ # data driven, so that we can eliminate this code duplication and just
410
+ # iterate over all supported platforms.
411
+
412
+ self .platforms_to_skip_build = set ()
413
+ if args .skip_build_linux :
414
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .Linux )
415
+ if args .skip_build_freebsd :
416
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .FreeBSD )
417
+ if args .skip_build_cygwin :
418
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .Cygwin )
419
+ if args .skip_build_osx :
420
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .OSX )
421
+ if args .skip_build_ios_device :
422
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .iOS )
423
+ if args .skip_build_ios_simulator :
424
+ self .platforms_to_skip_build .add (
425
+ StdlibDeploymentTarget .iOSSimulator )
426
+ if args .skip_build_tvos_device :
427
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .AppleTV )
428
+ if args .skip_build_tvos_simulator :
429
+ self .platforms_to_skip_build .add (
430
+ StdlibDeploymentTarget .AppleTVSimulator )
431
+ if args .skip_build_watchos_device :
432
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .AppleWatch )
433
+ if args .skip_build_watchos_simulator :
434
+ self .platforms_to_skip_build .add (
435
+ StdlibDeploymentTarget .AppleWatchSimulator )
436
+ if args .skip_build_android :
437
+ self .platforms_to_skip_build .add (StdlibDeploymentTarget .Android )
438
+
439
+ self .platforms_to_skip_test = set ()
440
+ if args .skip_test_linux :
441
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .Linux )
442
+ if args .skip_test_freebsd :
443
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .FreeBSD )
444
+ if args .skip_test_cygwin :
445
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .Cygwin )
446
+ if args .skip_test_osx :
447
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .OSX )
448
+ if args .skip_test_ios_host :
449
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .iOS )
450
+ if args .skip_test_ios_simulator :
451
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .iOSSimulator )
452
+ if args .skip_test_tvos_host :
453
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .AppleTV )
454
+ if args .skip_test_tvos_simulator :
455
+ self .platforms_to_skip_test .add (
456
+ StdlibDeploymentTarget .AppleTVSimulator )
457
+ if args .skip_test_watchos_host :
458
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .AppleWatch )
459
+ if args .skip_test_watchos_simulator :
460
+ self .platforms_to_skip_test .add (
461
+ StdlibDeploymentTarget .AppleWatchSimulator )
462
+ # We never allow testing Android, currently.
463
+ #
464
+ # FIXME: Allow Android host tests to be enabled/disabled by the build
465
+ # script.
466
+ self .platforms_to_skip_test .add (StdlibDeploymentTarget .Android )
467
+
468
+ self .platforms_to_skip_test_host = set ()
469
+ if args .skip_test_ios_host :
470
+ self .platforms_to_skip_test_host .add (StdlibDeploymentTarget .iOS )
471
+ if args .skip_test_tvos_host :
472
+ self .platforms_to_skip_test_host .add (StdlibDeploymentTarget .AppleTV )
473
+ if args .skip_test_watchos_host :
474
+ self .platforms_to_skip_test_host .add (
475
+ StdlibDeploymentTarget .AppleWatch )
476
+
294
477
def initialize_runtime_environment (self ):
295
478
"""Change the program environment for building."""
296
479
@@ -381,7 +564,7 @@ class BuildScriptInvocation(object):
381
564
if args .cross_compile_hosts :
382
565
impl_args += [
383
566
"--cross-compile-hosts" , " " .join (args .cross_compile_hosts )]
384
-
567
+
385
568
if toolchain .ninja :
386
569
impl_args += ["--ninja-bin=%s" % toolchain .ninja ]
387
570
if args .distcc :
@@ -565,7 +748,29 @@ class BuildScriptInvocation(object):
565
748
Compute the host-specific options, organized as a dictionary keyed by
566
749
host of options.
567
750
"""
568
- return {}
751
+
752
+ args = self .args
753
+
754
+ options = {}
755
+ for host in [args .host_target ] + args .cross_compile_hosts :
756
+ # Compute the host specific configuration.
757
+ config = HostSpecificConfiguration (host , self )
758
+
759
+ # Convert into `build-script-impl` style variables.
760
+ options [host ] = {
761
+ "SWIFT_SDKS" : " " .join (sorted (
762
+ config .sdks_to_configure )),
763
+ "SWIFT_STDLIB_TARGETS" : " " .join (
764
+ config .swift_stdlib_build_targets ),
765
+ "SWIFT_BENCHMARK_TARGETS" : " " .join (
766
+ config .swift_benchmark_build_targets ),
767
+ "SWIFT_RUN_BENCHMARK_TARGETS" : " " .join (
768
+ config .swift_benchmark_run_targets ),
769
+ "SWIFT_TEST_TARGETS" : " " .join (
770
+ config .swift_test_run_targets ),
771
+ }
772
+
773
+ return options
569
774
570
775
571
776
# Main entry point for the preset mode.
@@ -850,15 +1055,15 @@ details of the setups of other systems or automated environments.""")
850
1055
"tools for. Can be used multiple times." ,
851
1056
action = arguments .action .concat , type = arguments .type .shell_split ,
852
1057
default = [])
1058
+ stdlib_targets = StdlibDeploymentTarget .default_stdlib_deployment_targets ()
853
1059
targets_group .add_argument (
854
1060
"--stdlib-deployment-targets" ,
855
1061
help = "list of targets to compile or cross-compile the Swift standard "
856
1062
"library for. %(default)s by default." ,
857
1063
nargs = "*" ,
858
1064
default = [
859
1065
target .name
860
- for target in
861
- StdlibDeploymentTarget .default_stdlib_deployment_targets ()])
1066
+ for target in stdlib_targets ])
862
1067
targets_group .add_argument (
863
1068
"--build-stdlib-deployment-targets" ,
864
1069
help = "A space-separated list that filters which of the configured "
@@ -1527,6 +1732,7 @@ details of the setups of other systems or automated environments.""")
1527
1732
"--build-jobs" ,
1528
1733
"--common-cmake-options" ,
1529
1734
"--only-execute" ,
1735
+ "--skip-test-optimized" ,
1530
1736
action = arguments .action .unavailable )
1531
1737
1532
1738
args = migration .parse_args (parser , sys .argv [1 :])
0 commit comments