14
14
import sys
15
15
from argparse import ArgumentError
16
16
17
+ from . import compiler_stage
17
18
from .targets import StdlibDeploymentTarget
18
19
19
20
20
21
class HostSpecificConfiguration (object ):
21
-
22
22
"""Configuration information for an individual host."""
23
23
24
- def __init__ (self , host_target , args ):
24
+ def __init__ (self , host_target , args , stage_dependent_args = None ):
25
25
"""Initialize for the given `host_target`."""
26
+ # If we were not passed a stage_dependent_args object, then we do not need
27
+ # to make a distinction in between them and can just use args.
28
+ if not isinstance (args , compiler_stage .StageArgs ):
29
+ args = compiler_stage .StageArgs (compiler_stage .STAGE_1 , args )
30
+ if stage_dependent_args is None :
31
+ stage_dependent_args = args
26
32
27
33
# Compute the set of deployment targets to configure/build.
28
- if host_target == args .host_target :
34
+ if host_target == stage_dependent_args .host_target :
29
35
# This host is the user's desired product, so honor the requested
30
36
# set of targets to configure/build.
31
- stdlib_targets_to_configure = args .stdlib_deployment_targets
32
- if "all" in args .build_stdlib_deployment_targets :
37
+ stdlib_targets_to_configure = stage_dependent_args .stdlib_deployment_targets
38
+ if "all" in stage_dependent_args .build_stdlib_deployment_targets :
33
39
stdlib_targets_to_build = set (stdlib_targets_to_configure )
34
40
else :
35
41
stdlib_targets_to_build = set (
36
- args .build_stdlib_deployment_targets ).intersection (
37
- set (args .stdlib_deployment_targets ))
42
+ stage_dependent_args .build_stdlib_deployment_targets ).intersection (
43
+ set (stage_dependent_args .stdlib_deployment_targets ))
38
44
else :
39
45
# Otherwise, this is a host we are building as part of
40
46
# cross-compiling, so we only need the target itself.
41
47
stdlib_targets_to_configure = [host_target ]
42
- if ( hasattr ( args , ' stdlib_deployment_targets' )) :
48
+ if stage_dependent_args . stdlib_deployment_targets :
43
49
# there are some build configs that expect
44
50
# not to be building the stdlib for the target
45
51
# since it will be provided by different means
46
52
stdlib_targets_to_build = set (
47
53
stdlib_targets_to_configure ).intersection (
48
- set (args .stdlib_deployment_targets ))
54
+ set (stage_dependent_args .stdlib_deployment_targets ))
49
55
else :
50
56
stdlib_targets_to_build = set (stdlib_targets_to_configure )
51
57
52
- if ( hasattr ( args , ' stdlib_deployment_targets' ) and
53
- args .stdlib_deployment_targets == []) :
58
+ if stage_dependent_args . stdlib_deployment_targets and \
59
+ stage_dependent_args .stdlib_deployment_targets == []:
54
60
stdlib_targets_to_configure = []
55
61
stdlib_targets_to_build = []
56
62
@@ -59,11 +65,15 @@ def __init__(self, host_target, args):
59
65
# FIXME: We should move the platform-derived arguments to be entirely
60
66
# data driven, so that we can eliminate this code duplication and just
61
67
# iterate over all supported platforms.
62
- platforms_to_skip_build = self .__platforms_to_skip_build (args )
63
- platforms_to_skip_test = self .__platforms_to_skip_test (args )
68
+ platforms_to_skip_build = \
69
+ self .__platforms_to_skip_build (args , stage_dependent_args )
70
+ platforms_to_skip_test = \
71
+ self .__platforms_to_skip_test (args , stage_dependent_args )
64
72
platforms_archs_to_skip_test = \
65
- self .__platforms_archs_to_skip_test (args , host_target )
66
- platforms_to_skip_test_host = self .__platforms_to_skip_test_host (args )
73
+ self .__platforms_archs_to_skip_test (args , stage_dependent_args ,
74
+ host_target )
75
+ platforms_to_skip_test_host = \
76
+ self .__platforms_to_skip_test_host (args , stage_dependent_args )
67
77
68
78
# Compute the lists of **CMake** targets for each use case (configure
69
79
# vs. build vs. run) and the SDKs to configure with.
@@ -125,7 +135,10 @@ def __init__(self, host_target, args):
125
135
# Validation, long, and stress tests require building the full
126
136
# standard library, whereas the other targets can build a
127
137
# slightly smaller subset which is faster to build.
128
- if args .build_swift_stdlib_unittest_extra or \
138
+ #
139
+ # NOTE: We currently do not seperate testing options for
140
+ # stage1/stage2 compiler. This can change with time.
141
+ if stage_dependent_args .build_swift_stdlib_unittest_extra or \
129
142
args .validation_test or args .long_test or \
130
143
args .stress_test :
131
144
self .swift_stdlib_build_targets .append (
@@ -172,7 +185,7 @@ def __init__(self, host_target, args):
172
185
# If the compiler is being tested after being built to use the
173
186
# standalone swift-driver, we build a test-target to
174
187
# run a reduced set of lit-tests that verify the early swift-driver.
175
- if getattr ( args , ' test_early_swift_driver' , False ) and \
188
+ if args . test_early_swift_driver and \
176
189
not test_host_only :
177
190
self .swift_test_run_targets .append (
178
191
"check-swift-only_early_swiftdriver-{}" .format (name ))
@@ -215,80 +228,82 @@ def add_flags_for_cross_compilation(self, args, deployment_target):
215
228
self .swift_flags = deployment_target .platform .swift_flags (args )
216
229
self .cmake_options = deployment_target .platform .cmake_options (args )
217
230
218
- def __platforms_to_skip_build (self , args ):
231
+ def __platforms_to_skip_build (self , args , stage_dependent_args ):
219
232
platforms_to_skip_build = set ()
220
- if not args .build_linux :
233
+ if not stage_dependent_args .build_linux :
221
234
platforms_to_skip_build .add (StdlibDeploymentTarget .Linux )
222
- if not args .build_freebsd :
235
+ if not stage_dependent_args .build_freebsd :
223
236
platforms_to_skip_build .add (StdlibDeploymentTarget .FreeBSD )
224
- if not args .build_cygwin :
237
+ if not stage_dependent_args .build_cygwin :
225
238
platforms_to_skip_build .add (StdlibDeploymentTarget .Cygwin )
226
- if not args .build_osx :
239
+ if not stage_dependent_args .build_osx :
227
240
platforms_to_skip_build .add (StdlibDeploymentTarget .OSX )
228
- if not args .build_ios_device :
241
+ if not stage_dependent_args .build_ios_device :
229
242
platforms_to_skip_build .add (StdlibDeploymentTarget .iOS )
230
- if not args .build_ios_simulator :
243
+ if not stage_dependent_args .build_ios_simulator :
231
244
platforms_to_skip_build .add (StdlibDeploymentTarget .iOSSimulator )
232
- if not args .build_tvos_device :
245
+ if not stage_dependent_args .build_tvos_device :
233
246
platforms_to_skip_build .add (StdlibDeploymentTarget .AppleTV )
234
- if not args .build_tvos_simulator :
247
+ if not stage_dependent_args .build_tvos_simulator :
235
248
platforms_to_skip_build .add (
236
249
StdlibDeploymentTarget .AppleTVSimulator )
237
- if not args .build_watchos_device :
250
+ if not stage_dependent_args .build_watchos_device :
238
251
platforms_to_skip_build .add (StdlibDeploymentTarget .AppleWatch )
239
- if not args .build_watchos_simulator :
252
+ if not stage_dependent_args .build_watchos_simulator :
240
253
platforms_to_skip_build .add (
241
254
StdlibDeploymentTarget .AppleWatchSimulator )
242
- if not args .build_android :
255
+ if not stage_dependent_args .build_android :
243
256
platforms_to_skip_build .add (StdlibDeploymentTarget .Android )
244
257
return platforms_to_skip_build
245
258
246
- def __platforms_to_skip_test (self , args ):
259
+ def __platforms_to_skip_test (self , args , stage_dependent_args ):
247
260
platforms_to_skip_test = set ()
248
- if not args .test_linux :
261
+ if not stage_dependent_args .test_linux :
249
262
platforms_to_skip_test .add (StdlibDeploymentTarget .Linux )
250
- if not args .test_freebsd :
263
+ if not stage_dependent_args .test_freebsd :
251
264
platforms_to_skip_test .add (StdlibDeploymentTarget .FreeBSD )
252
- if not args .test_cygwin :
265
+ if not stage_dependent_args .test_cygwin :
253
266
platforms_to_skip_test .add (StdlibDeploymentTarget .Cygwin )
254
- if not args .test_osx :
267
+ if not stage_dependent_args .test_osx :
255
268
platforms_to_skip_test .add (StdlibDeploymentTarget .OSX )
256
- if not args .test_ios_host and not args .only_non_executable_test :
269
+ if not stage_dependent_args .test_ios_host and not args .only_non_executable_test :
257
270
platforms_to_skip_test .add (StdlibDeploymentTarget .iOS )
258
271
elif not args .only_non_executable_test :
259
272
raise ArgumentError (None ,
260
273
"error: iOS device tests are not " +
261
274
"supported in open-source Swift." )
262
- if not args .test_ios_simulator :
275
+ if not stage_dependent_args .test_ios_simulator :
263
276
platforms_to_skip_test .add (StdlibDeploymentTarget .iOSSimulator )
264
- if not args .test_tvos_host and not args .only_non_executable_test :
277
+ if not stage_dependent_args .test_tvos_host and \
278
+ not args .only_non_executable_test :
265
279
platforms_to_skip_test .add (StdlibDeploymentTarget .AppleTV )
266
280
elif not args .only_non_executable_test :
267
281
raise ArgumentError (None ,
268
282
"error: tvOS device tests are not " +
269
283
"supported in open-source Swift." )
270
- if not args .test_tvos_simulator :
284
+ if not stage_dependent_args .test_tvos_simulator :
271
285
platforms_to_skip_test .add (StdlibDeploymentTarget .AppleTVSimulator )
272
- if not args .test_watchos_host and not args .only_non_executable_test :
286
+ if not stage_dependent_args .test_watchos_host and \
287
+ not args .only_non_executable_test :
273
288
platforms_to_skip_test .add (StdlibDeploymentTarget .AppleWatch )
274
289
elif not args .only_non_executable_test :
275
290
raise ArgumentError (None ,
276
291
"error: watchOS device tests are not " +
277
292
"supported in open-source Swift." )
278
- if not args .test_watchos_simulator :
293
+ if not stage_dependent_args .test_watchos_simulator :
279
294
platforms_to_skip_test .add (
280
295
StdlibDeploymentTarget .AppleWatchSimulator )
281
- if not args .test_android :
296
+ if not stage_dependent_args .test_android :
282
297
platforms_to_skip_test .add (StdlibDeploymentTarget .Android )
283
298
284
299
return platforms_to_skip_test
285
300
286
- def __platforms_archs_to_skip_test (self , args , host_target ):
301
+ def __platforms_archs_to_skip_test (self , args , stage_dependent_args , host_target ):
287
302
platforms_archs_to_skip_test = set ()
288
- if not args .test_ios_32bit_simulator :
303
+ if not stage_dependent_args .test_ios_32bit_simulator :
289
304
platforms_archs_to_skip_test .add (
290
305
StdlibDeploymentTarget .iOSSimulator .i386 )
291
- if not args .test_watchos_32bit_simulator :
306
+ if not stage_dependent_args .test_watchos_32bit_simulator :
292
307
platforms_archs_to_skip_test .add (
293
308
StdlibDeploymentTarget .AppleWatchSimulator .i386 )
294
309
if host_target == StdlibDeploymentTarget .OSX .x86_64 .name :
@@ -312,14 +327,17 @@ def __platforms_archs_to_skip_test(self, args, host_target):
312
327
313
328
return platforms_archs_to_skip_test
314
329
315
- def __platforms_to_skip_test_host (self , args ):
330
+ def __platforms_to_skip_test_host (self , args , stage_dependent_args ):
316
331
platforms_to_skip_test_host = set ()
317
- if not args .test_android_host :
332
+ if not stage_dependent_args .test_android_host :
318
333
platforms_to_skip_test_host .add (StdlibDeploymentTarget .Android )
319
- if not args .test_ios_host and not args .only_non_executable_test :
334
+ if not stage_dependent_args .test_ios_host and \
335
+ not args .only_non_executable_test :
320
336
platforms_to_skip_test_host .add (StdlibDeploymentTarget .iOS )
321
- if not args .test_tvos_host and not args .only_non_executable_test :
337
+ if not stage_dependent_args .test_tvos_host and \
338
+ not args .only_non_executable_test :
322
339
platforms_to_skip_test_host .add (StdlibDeploymentTarget .AppleTV )
323
- if not args .test_watchos_host and not args .only_non_executable_test :
340
+ if not stage_dependent_args .test_watchos_host and \
341
+ not args .only_non_executable_test :
324
342
platforms_to_skip_test_host .add (StdlibDeploymentTarget .AppleWatch )
325
343
return platforms_to_skip_test_host
0 commit comments