@@ -130,6 +130,11 @@ def add_build_args(parser):
130
130
help = "paths (relative to the project root) where to install build products [%(default)s]" ,
131
131
default = ["/tmp/swiftpm" ],
132
132
metavar = "PATHS" )
133
+ parser .add_argument (
134
+ "--cross-compile-hosts" ,
135
+ dest = "cross_compile_hosts" ,
136
+ help = "List of cross compile hosts targets." ,
137
+ default = [])
133
138
134
139
def add_test_args (parser ):
135
140
"""Configures the parser with the arguments necessary for the test action."""
@@ -182,7 +187,7 @@ def parse_build_args(args):
182
187
args .clang_path = get_clang_path (args )
183
188
args .cmake_path = get_cmake_path (args )
184
189
args .ninja_path = get_ninja_path (args )
185
- if os . getenv ( "CROSS_COMPILE_HOSTS" ) : # Use XCBuild target directory when building for multiple arches.
190
+ if args . cross_compile_hosts : # Use XCBuild target directory when building for multiple arches.
186
191
args .target_dir = os .path .join (args .build_dir , "apple/Products" )
187
192
else :
188
193
args .target_dir = os .path .join (args .build_dir , get_build_target (args ))
@@ -356,7 +361,7 @@ def install(args):
356
361
# Install the swiftmodule and swiftdoc files.
357
362
for module in libswiftpm_modules :
358
363
install_binary (args , module + ".swiftmodule" , dest )
359
- if not os . getenv ( "CROSS_COMPILE_HOSTS" ) : # When compiling for multiple arches, swiftdoc is part of the swiftmodule directory
364
+ if not args . cross_compile_hosts : # When compiling for multiple arches, swiftdoc is part of the swiftmodule directory
360
365
install_binary (args , module + ".swiftdoc" , dest )
361
366
362
367
# Install the C headers.
@@ -403,7 +408,7 @@ def install_binary(args, binary, dest_dir):
403
408
note ("Installing %s to %s" % (src , dest ))
404
409
405
410
mkdir_p (os .path .dirname (dest ))
406
- if os .path .isdir (src ) and os . getenv ( "CROSS_COMPILE_HOSTS" ) : # Handle swiftmodule directories if compiling for multiple arches.
411
+ if os .path .isdir (src ) and args . cross_compile_hosts : # Handle swiftmodule directories if compiling for multiple arches.
407
412
dir_util .copy_tree (src , dest )
408
413
else :
409
414
file_util .copy_file (src , dest , update = 1 )
@@ -569,11 +574,11 @@ def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
569
574
swiftpm_args .append ("--use-integrated-swift-driver" )
570
575
571
576
build_target = get_build_target (args )
572
- cross_compile_host = os . getenv ( "CROSS_COMPILE_HOSTS" )
573
- if build_target == 'x86_64-apple-macosx' and cross_compile_host == "macosx-arm64" :
577
+ cross_compile_hosts = args . cross_compile_hosts
578
+ if build_target == 'x86_64-apple-macosx' and "macosx-arm64" in cross_compile_hosts :
574
579
swiftpm_args += ["--arch" , "x86_64" , "--arch" , "arm64" ]
575
- elif cross_compile_host :
576
- error ("cannot cross-compile for %s" % cross_compile_host )
580
+ elif cross_compile_hosts :
581
+ error ("cannot cross-compile for %s" % cross_compile_hosts )
577
582
578
583
call_swiftpm (args , swiftpm_args )
579
584
0 commit comments