1111# ----------------------------------------------------------------------------
1212
1313import os
14+ import platform
1415
1516from . import cmark
1617from . import foundation
2324from . import swift_testing
2425from . import xctest
2526from .. import shell
26- from ..targets import StdlibDeploymentTarget
27+ from ..targets import StdlibDeploymentTarget , darwin_toolchain_prefix
2728
2829
2930class SwiftPM (product .Product ):
@@ -50,6 +51,10 @@ def run_bootstrap_script(
5051 * ,
5152 compile_only_for_running_host_architecture = False ,
5253 ):
54+ toolchain_path = _get_toolchain_path (host_target , self , self .args )
55+ swift_lib_path = os .path .join (toolchain_path ,
56+ 'usr' , 'lib' , 'swift' , 'macosx' )
57+
5358 script_path = os .path .join (
5459 self .source_dir , 'Utilities' , 'bootstrap' )
5560
@@ -79,7 +84,8 @@ def run_bootstrap_script(
7984 "--cmake-path" , self .toolchain .cmake ,
8085 "--ninja-path" , self .toolchain .ninja ,
8186 "--build-dir" , self .build_dir ,
82- "--llbuild-build-dir" , llbuild_build_dir
87+ "--llbuild-build-dir" , llbuild_build_dir ,
88+ "--extra-dynamic-library-path" , swift_lib_path
8389 ]
8490
8591 # Pass Dispatch directory down if we built it
@@ -169,3 +175,16 @@ def get_dependencies(cls):
169175 xctest .XCTest ,
170176 llbuild .LLBuild ,
171177 swift_testing .SwiftTesting ]
178+
179+ def _get_toolchain_path (host_target , product , args ):
180+ # TODO check if we should prefer using product.install_toolchain_path
181+ # this logic initially was inside run_build_script_helper
182+ # and was factored out so it can be used in testing as well
183+
184+ toolchain_path = product .host_install_destdir (host_target )
185+ if platform .system () == 'Darwin' :
186+ # The prefix is an absolute path, so concatenate without os.path.
187+ toolchain_path += \
188+ darwin_toolchain_prefix (args .install_prefix )
189+
190+ return toolchain_path
0 commit comments