@@ -74,47 +74,57 @@ class HostSpecificConfiguration(object):
74
74
def __init__ (self , host_target , invocation ):
75
75
"""Initialize for the given `host_target`."""
76
76
77
- # Compute the set of deployment targets to configure/build.
78
77
args = invocation .args
78
+
79
+ # [*] Compute the list of deployment targets to configure.
80
+ #
81
+ # We only need to configure cross-compiled stdlib targets.
82
+ # The host_target is implicitly configured by CMake.
83
+
84
+ self .host_target = StdlibDeploymentTarget \
85
+ .get_target_for_name (host_target )
86
+ if self .host_target is None :
87
+ diagnostics .fatal ("unknown host target: %r" % (
88
+ host_target ))
89
+
90
+ self .stdlib_targets_to_configure = []
91
+ # FIXME: Cross-compiled hosts don't support cross-compiled targets
92
+ # or filtering build lists, only because we don't
93
+ # have an argument structure to define them for NxM hosts and targets.
79
94
if host_target == args .host_target :
80
- # This host is the user's desired product, so honor the requested
81
- # set of targets to configure/build.
82
- stdlib_targets_to_configure = args .stdlib_deployment_targets
83
- if "all" in args .build_stdlib_deployment_targets :
84
- stdlib_targets_to_build = set (stdlib_targets_to_configure )
85
- else :
86
- stdlib_targets_to_build = set (
87
- args .build_stdlib_deployment_targets ).intersection (
88
- set (args .stdlib_deployment_targets ))
89
- else :
90
- # Otherwise, this is a host we are building as part of
91
- # cross-compiling, so we only need the target itself.
92
- stdlib_targets_to_configure = [host_target ]
93
- stdlib_targets_to_build = set (stdlib_targets_to_configure )
94
-
95
- # Compute the lists of **CMake** targets for each use case (configure
96
- # vs. build vs. run) and the SDKs to configure with.
97
- self .sdks_to_configure = set ()
95
+ for name in args .cross_compile_stdlib_deployment_targets :
96
+ dpymt_target = StdlibDeploymentTarget .get_target_for_name (name )
97
+ if dpymt_target is None :
98
+ diagnostics .fatal ("unknown stdlib target: %r" % (
99
+ name ))
100
+ else :
101
+ self .stdlib_targets_to_configure .append (dpymt_target )
102
+
103
+ # [*] Compute the list of deployment targets to build.
104
+ #
105
+ # Even though we don't need to configure host_target, we do need
106
+ # to explicitly build it.
107
+ # So by default, build all configured targets + the host
108
+
109
+ self .stdlib_targets_to_build = [self .host_target ]
110
+ self .stdlib_targets_to_build += self .stdlib_targets_to_configure
111
+
112
+ if host_target == args .host_target and \
113
+ "all" not in args .build_stdlib_deployment_targets :
114
+ self .stdlib_targets_to_build = \
115
+ [t for t in self .stdlib_targets_to_build
116
+ if t .name in args .build_stdlib_deployment_targets ]
117
+
118
+ # [*] Compute the lists of **CMake** build/run targets
119
+
98
120
self .swift_stdlib_build_targets = []
99
121
self .swift_test_run_targets = []
100
122
self .swift_benchmark_build_targets = []
101
123
self .swift_benchmark_run_targets = []
102
- for deployment_target_name in stdlib_targets_to_configure :
103
- # Get the target object.
104
- deployment_target = StdlibDeploymentTarget .get_target_for_name (
105
- deployment_target_name )
106
- if deployment_target is None :
107
- diagnostics .fatal ("unknown target: %r" % (
108
- deployment_target_name ,))
109
-
110
- # Add the SDK to use.
111
- deployment_platform = deployment_target .platform
112
- self .sdks_to_configure .add (deployment_platform .sdk_name )
124
+ for deployment_target in self .stdlib_targets_to_build :
113
125
114
- # If we aren't actually building this target (only configuring
115
- # it), do nothing else.
116
- if deployment_target_name not in stdlib_targets_to_build :
117
- continue
126
+ deployment_platform = deployment_target .platform
127
+ name = deployment_target .name
118
128
119
129
# Compute which actions are desired.
120
130
build = (
@@ -139,7 +149,6 @@ class HostSpecificConfiguration(object):
139
149
else :
140
150
test = False
141
151
142
- name = deployment_target .name
143
152
if build :
144
153
# Validation and long tests require building the full standard
145
154
# library, whereas the other targets can build a slightly
@@ -201,7 +210,7 @@ class BuildScriptInvocation(object):
201
210
diagnostics .fatal (
202
211
"can't find distcc-pump (please install distcc-pump)" )
203
212
204
- if args .host_target is None or args . stdlib_deployment_targets is None :
213
+ if args .host_target is None :
205
214
diagnostics .fatal ("unknown operating system" )
206
215
207
216
if args .symbols_package :
@@ -397,17 +406,19 @@ class BuildScriptInvocation(object):
397
406
args .build_subdir = \
398
407
swift_build_support .workspace .compute_build_subdir (args )
399
408
400
- # Add optional stdlib-deployment-targets
409
+ # Add optional cross-compile- stdlib-deployment-targets
401
410
if args .android :
402
- args .stdlib_deployment_targets .append (
411
+ args .cross_compile_stdlib_deployment_targets .append (
403
412
StdlibDeploymentTarget .Android .armv7 .name )
404
413
405
414
# Infer platform flags from manually-specified configure targets.
406
415
# This doesn't apply to Darwin platforms, as they are
407
416
# already configured. No building without the platform flag, though.
408
417
409
- android_tgts = [tgt for tgt in args .stdlib_deployment_targets
410
- if StdlibDeploymentTarget .Android .contains (tgt )]
418
+ android_tgts = \
419
+ [tgt for tgt in args .cross_compile_stdlib_deployment_targets
420
+ if StdlibDeploymentTarget .Android .contains (tgt )]
421
+
411
422
if not args .android and len (android_tgts ) > 0 :
412
423
args .android = True
413
424
args .skip_build_android = True
@@ -542,8 +553,6 @@ class BuildScriptInvocation(object):
542
553
"--build-dir" , self .workspace .build_root ,
543
554
"--install-prefix" , args .install_prefix ,
544
555
"--host-target" , args .host_target ,
545
- "--stdlib-deployment-targets" ,
546
- " " .join (args .stdlib_deployment_targets ),
547
556
"--host-cc" , toolchain .cc ,
548
557
"--host-cxx" , toolchain .cxx ,
549
558
"--darwin-xcrun-toolchain" , args .darwin_xcrun_toolchain ,
@@ -576,10 +585,24 @@ class BuildScriptInvocation(object):
576
585
pipes .quote (arg ) for arg in cmake .build_args ()),
577
586
]
578
587
588
+ # Specify additional stdlib targets to configure. Remove zero-length
589
+ # names.
590
+ args .cross_compile_stdlib_deployment_targets = \
591
+ [t for t in args .cross_compile_stdlib_deployment_targets
592
+ if len (t ) > 0 ]
593
+
594
+ if args .cross_compile_stdlib_deployment_targets is not None and \
595
+ len (args .cross_compile_stdlib_deployment_targets ) > 0 and \
596
+ 'none' not in args .cross_compile_stdlib_deployment_targets :
597
+ impl_args += ["--cross-compile-stdlib-deployment-targets" ,
598
+ " " .join (
599
+ args .cross_compile_stdlib_deployment_targets )]
600
+ # Specify stdlib targets to build
579
601
if args .build_stdlib_deployment_targets :
580
602
impl_args += [
581
603
"--build-stdlib-deployment-targets" , " " .join (
582
604
args .build_stdlib_deployment_targets )]
605
+ # Specify additional hosts to configure + build
583
606
if args .cross_compile_hosts :
584
607
impl_args += [
585
608
"--cross-compile-hosts" , " " .join (args .cross_compile_hosts )]
@@ -783,16 +806,18 @@ class BuildScriptInvocation(object):
783
806
config = HostSpecificConfiguration (host_target , self )
784
807
785
808
# Convert into `build-script-impl` style variables.
809
+ stdlib_target_names = [t .name for t
810
+ in config .stdlib_targets_to_configure ]
786
811
options [host_target ] = {
787
- "SWIFT_SDKS " : " " .join ( sorted (
788
- config . sdks_to_configure ) ),
789
- "SWIFT_STDLIB_TARGETS " : " " .join (
812
+ "SWIFT_CROSS_COMPILE_STDLIB_TARGETS " : " " .join (
813
+ stdlib_target_names ),
814
+ "SWIFT_STDLIB_BUILD_TARGETS " : " " .join (
790
815
config .swift_stdlib_build_targets ),
791
- "SWIFT_BENCHMARK_TARGETS " : " " .join (
816
+ "SWIFT_BENCHMARK_BUILD_TARGETS " : " " .join (
792
817
config .swift_benchmark_build_targets ),
793
- "SWIFT_RUN_BENCHMARK_TARGETS " : " " .join (
818
+ "SWIFT_BENCHMARK_RUN_TARGETS " : " " .join (
794
819
config .swift_benchmark_run_targets ),
795
- "SWIFT_TEST_TARGETS " : " " .join (
820
+ "SWIFT_TEST_RUN_TARGETS " : " " .join (
796
821
config .swift_test_run_targets ),
797
822
}
798
823
@@ -1088,15 +1113,14 @@ details of the setups of other systems or automated environments.""")
1088
1113
"tools for. Can be used multiple times." ,
1089
1114
action = arguments .action .concat , type = arguments .type .shell_split ,
1090
1115
default = [])
1091
- stdlib_targets = StdlibDeploymentTarget .default_stdlib_deployment_targets ()
1116
+ default_cross_stdlib_targets = StdlibDeploymentTarget \
1117
+ .default_cross_compile_stdlib_targets ()
1092
1118
targets_group .add_argument (
1093
- "--stdlib-deployment-targets" ,
1094
- help = "list of targets to compile or cross-compile the Swift standard "
1119
+ "--cross-compile- stdlib-deployment-targets" ,
1120
+ help = "list of targets to cross-compile the Swift standard "
1095
1121
"library for. %(default)s by default." ,
1096
1122
nargs = "*" ,
1097
- default = [
1098
- target .name
1099
- for target in stdlib_targets ])
1123
+ default = [t .name for t in default_cross_stdlib_targets ])
1100
1124
targets_group .add_argument (
1101
1125
"--build-stdlib-deployment-targets" ,
1102
1126
help = "A space-separated list that filters which of the configured "
0 commit comments