@@ -56,33 +56,44 @@ def install(self, host_target):
5656 """
5757 install_destdir = self .host_install_destdir (host_target )
5858 build_toolchain_path = install_destdir + self .args .install_prefix + '/bin'
59- shutil .copy (self .bin_path , build_toolchain_path + '/wasmkit' )
59+ bin_path = run_swift_build (host_target , self , 'wasmkit-cli' , set_installation_rpath = True )
60+ shutil .copy (bin_path , build_toolchain_path + '/wasmkit' )
6061
6162 def build (self , host_target ):
62- self . bin_path = run_swift_build (host_target , self , 'wasmkit-cli' )
63- print ("Built wasmkit-cli at: " + self . bin_path )
63+ bin_path = run_swift_build (host_target , self , 'wasmkit-cli' )
64+ print ("Built wasmkit-cli at: " + bin_path )
6465 # Copy the built binary to ./bin
6566 dest_bin_path = self .__class__ .cli_file_path (self .build_dir )
6667 print ("Copying wasmkit-cli to: " + dest_bin_path )
6768 os .makedirs (os .path .dirname (dest_bin_path ), exist_ok = True )
68- shutil .copy (self . bin_path , dest_bin_path )
69+ shutil .copy (bin_path , dest_bin_path )
6970
7071 @classmethod
7172 def cli_file_path (cls , build_dir ):
7273 return os .path .join (build_dir , 'bin' , 'wasmkit-cli' )
7374
7475
75- def run_swift_build (host_target , product , swpft_package_product_name ):
76+ def run_swift_build (host_target , product , swiftpm_package_product_name , set_installation_rpath = False ):
7677 # Building with the freshly-built SwiftPM
7778 swift_build = os .path .join (product .install_toolchain_path (host_target ), "bin" , "swift-build" )
7879
80+ build_os = host_target .split ('-' )[0 ]
81+ if set_installation_rpath and not host_target .startswith ('macos' ):
82+ # Library rpath for swift, dispatch, Foundation, etc. when installing
83+ rpath_args = [
84+ '--disable-local-rpath' , '-Xswiftc' , '-no-toolchain-stdlib-rpath' ,
85+ '-Xlinker' , '-rpath' , '-Xlinker' , '$ORIGIN/../lib/swift/' + build_os
86+ ]
87+ else :
88+ rpath_args = []
89+
7990 build_args = [
8091 swift_build ,
81- '--product' , swpft_package_product_name ,
92+ '--product' , swiftpm_package_product_name ,
8293 '--package-path' , os .path .join (product .source_dir ),
8394 '--build-path' , product .build_dir ,
8495 '--configuration' , 'release' ,
85- ]
96+ ] + rpath_args
8697
8798 if product .args .verbose_build :
8899 build_args .append ('--verbose' )
@@ -94,4 +105,4 @@ def run_swift_build(host_target, product, swpft_package_product_name):
94105
95106 bin_dir_path = shell .capture (
96107 build_args + ['--show-bin-path' ], dry_run = False , echo = False ).rstrip ()
97- return os .path .join (bin_dir_path , swpft_package_product_name )
108+ return os .path .join (bin_dir_path , swiftpm_package_product_name )
0 commit comments