@@ -71,47 +71,57 @@ class HostSpecificConfiguration(object):
71
71
def __init__ (self , host_target , invocation ):
72
72
"""Initialize for the given `host_target`."""
73
73
74
- # Compute the set of deployment targets to configure/build.
75
74
args = invocation .args
75
+
76
+ # [*] Compute the list of deployment targets to configure.
77
+ #
78
+ # We only need to configure cross-compiled stdlib targets.
79
+ # The host_target is implicitly configured by CMake.
80
+
81
+ self .host_target = StdlibDeploymentTarget \
82
+ .get_target_for_name (host_target )
83
+ if self .host_target is None :
84
+ diagnostics .fatal ("unknown host target: %r" % (
85
+ host_target ))
86
+
87
+ self .stdlib_targets_to_configure = []
88
+ # FIXME: Cross-compiled hosts don't support cross-compiled targets
89
+ # or filtering build lists, only because we don't
90
+ # have an argument structure to define them for NxM hosts and targets.
76
91
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 ()
92
+ for name in args .cross_compile_stdlib_deployment_targets :
93
+ dpymt_target = StdlibDeploymentTarget .get_target_for_name (name )
94
+ if dpymt_target is None :
95
+ diagnostics .fatal ("unknown stdlib target: %r" % (
96
+ name ))
97
+ else :
98
+ self .stdlib_targets_to_configure .append (dpymt_target )
99
+
100
+ # [*] Compute the list of deployment targets to build.
101
+ #
102
+ # Even though we don't need to configure host_target, we do need
103
+ # to explicitly build it.
104
+ # So by default, build all configured targets + the host
105
+
106
+ self .stdlib_targets_to_build = [self .host_target ]
107
+ self .stdlib_targets_to_build += self .stdlib_targets_to_configure
108
+
109
+ if host_target == args .host_target and \
110
+ "all" not in args .build_stdlib_deployment_targets :
111
+ self .stdlib_targets_to_build = \
112
+ [t for t in self .stdlib_targets_to_build
113
+ if t .name in args .build_stdlib_deployment_targets ]
114
+
115
+ # [*] Compute the lists of **CMake** build/run targets
116
+
95
117
self .swift_stdlib_build_targets = []
96
118
self .swift_test_run_targets = []
97
119
self .swift_benchmark_build_targets = []
98
120
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 )
121
+ for deployment_target in self .stdlib_targets_to_build :
110
122
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
123
+ deployment_platform = deployment_target .platform
124
+ name = deployment_target .name
115
125
116
126
# Compute which actions are desired.
117
127
build = (
@@ -130,19 +140,18 @@ class HostSpecificConfiguration(object):
130
140
deployment_platform .is_embedded and \
131
141
not deployment_platform .is_simulator :
132
142
if deployment_platform not in \
133
- invocation .platforms_to_skip_test_host :
143
+ invocation .platforms_to_skip_test_host :
134
144
test_host_only = True
135
145
test = True
136
146
else :
137
147
test = False
138
148
139
- name = deployment_target .name
140
149
if build :
141
150
# Validation and long tests require building the full standard
142
151
# library, whereas the other targets can build a slightly
143
152
# smaller subset which is faster to build.
144
153
if args .build_swift_stdlib_unittest_extra or \
145
- args .validation_test or args .long_test :
154
+ args .validation_test or args .long_test :
146
155
self .swift_stdlib_build_targets .append (
147
156
"swift-stdlib-" + name )
148
157
else :
@@ -198,7 +207,7 @@ class BuildScriptInvocation(object):
198
207
diagnostics .fatal (
199
208
"can't find distcc-pump (please install distcc-pump)" )
200
209
201
- if args .host_target is None or args . stdlib_deployment_targets is None :
210
+ if args .host_target is None :
202
211
diagnostics .fatal ("unknown operating system" )
203
212
204
213
if args .symbols_package :
@@ -390,9 +399,9 @@ class BuildScriptInvocation(object):
390
399
args .build_subdir = \
391
400
swift_build_support .workspace .compute_build_subdir (args )
392
401
393
- # Add optional stdlib-deployment-targets
402
+ # Add optional cross-compile- stdlib-deployment-targets
394
403
if args .android :
395
- args .stdlib_deployment_targets .append (
404
+ args .cross_compile_stdlib_deployment_targets .append (
396
405
StdlibDeploymentTarget .Android .armv7 .name )
397
406
398
407
def __init__ (self , toolchain , args ):
@@ -525,8 +534,6 @@ class BuildScriptInvocation(object):
525
534
"--build-dir" , self .workspace .build_root ,
526
535
"--install-prefix" , args .install_prefix ,
527
536
"--host-target" , args .host_target ,
528
- "--stdlib-deployment-targets" ,
529
- " " .join (args .stdlib_deployment_targets ),
530
537
"--host-cc" , toolchain .cc ,
531
538
"--host-cxx" , toolchain .cxx ,
532
539
"--darwin-xcrun-toolchain" , args .darwin_xcrun_toolchain ,
@@ -559,10 +566,24 @@ class BuildScriptInvocation(object):
559
566
pipes .quote (arg ) for arg in cmake .build_args ()),
560
567
]
561
568
569
+ # Specify additional stdlib targets to configure. Remove zero-length
570
+ # names.
571
+ args .cross_compile_stdlib_deployment_targets = \
572
+ [t for t in args .cross_compile_stdlib_deployment_targets
573
+ if len (t ) > 0 ]
574
+
575
+ if args .cross_compile_stdlib_deployment_targets is not None and \
576
+ len (args .cross_compile_stdlib_deployment_targets ) > 0 and \
577
+ 'none' not in args .cross_compile_stdlib_deployment_targets :
578
+ impl_args += ["--cross-compile-stdlib-deployment-targets" ,
579
+ " " .join (
580
+ args .cross_compile_stdlib_deployment_targets )]
581
+ # Specify stdlib targets to build
562
582
if args .build_stdlib_deployment_targets :
563
583
impl_args += [
564
584
"--build-stdlib-deployment-targets" , " " .join (
565
585
args .build_stdlib_deployment_targets )]
586
+ # Specify additional hosts to configure + build
566
587
if args .cross_compile_hosts :
567
588
impl_args += [
568
589
"--cross-compile-hosts" , " " .join (args .cross_compile_hosts )]
@@ -759,16 +780,18 @@ class BuildScriptInvocation(object):
759
780
config = HostSpecificConfiguration (host_target , self )
760
781
761
782
# Convert into `build-script-impl` style variables.
783
+ stdlib_target_names = [t .name for t
784
+ in config .stdlib_targets_to_configure ]
762
785
options [host_target ] = {
763
- "SWIFT_SDKS " : " " .join ( sorted (
764
- config . sdks_to_configure ) ),
765
- "SWIFT_STDLIB_TARGETS " : " " .join (
786
+ "SWIFT_CROSS_COMPILE_STDLIB_TARGETS " : " " .join (
787
+ stdlib_target_names ),
788
+ "SWIFT_STDLIB_BUILD_TARGETS " : " " .join (
766
789
config .swift_stdlib_build_targets ),
767
- "SWIFT_BENCHMARK_TARGETS " : " " .join (
790
+ "SWIFT_BENCHMARK_BUILD_TARGETS " : " " .join (
768
791
config .swift_benchmark_build_targets ),
769
- "SWIFT_RUN_BENCHMARK_TARGETS " : " " .join (
792
+ "SWIFT_BENCHMARK_RUN_TARGETS " : " " .join (
770
793
config .swift_benchmark_run_targets ),
771
- "SWIFT_TEST_TARGETS " : " " .join (
794
+ "SWIFT_TEST_RUN_TARGETS " : " " .join (
772
795
config .swift_test_run_targets ),
773
796
}
774
797
@@ -1057,15 +1080,14 @@ details of the setups of other systems or automated environments.""")
1057
1080
"tools for. Can be used multiple times." ,
1058
1081
action = arguments .action .concat , type = arguments .type .shell_split ,
1059
1082
default = [])
1060
- stdlib_targets = StdlibDeploymentTarget .default_stdlib_deployment_targets ()
1083
+ default_cross_stdlib_targets = StdlibDeploymentTarget \
1084
+ .default_cross_compile_stdlib_targets ()
1061
1085
targets_group .add_argument (
1062
- "--stdlib-deployment-targets" ,
1063
- help = "list of targets to compile or cross-compile the Swift standard "
1086
+ "--cross-compile- stdlib-deployment-targets" ,
1087
+ help = "list of targets to cross-compile the Swift standard "
1064
1088
"library for. %(default)s by default." ,
1065
1089
nargs = "*" ,
1066
- default = [
1067
- target .name
1068
- for target in stdlib_targets ])
1090
+ default = [t .name for t in default_cross_stdlib_targets ])
1069
1091
targets_group .add_argument (
1070
1092
"--build-stdlib-deployment-targets" ,
1071
1093
help = "A space-separated list that filters which of the configured "
0 commit comments