@@ -56,33 +56,44 @@ def install(self, host_target):
56
56
"""
57
57
install_destdir = self .host_install_destdir (host_target )
58
58
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' )
60
61
61
62
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 )
64
65
# Copy the built binary to ./bin
65
66
dest_bin_path = self .__class__ .cli_file_path (self .build_dir )
66
67
print ("Copying wasmkit-cli to: " + dest_bin_path )
67
68
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 )
69
70
70
71
@classmethod
71
72
def cli_file_path (cls , build_dir ):
72
73
return os .path .join (build_dir , 'bin' , 'wasmkit-cli' )
73
74
74
75
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 ):
76
77
# Building with the freshly-built SwiftPM
77
78
swift_build = os .path .join (product .install_toolchain_path (host_target ), "bin" , "swift-build" )
78
79
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
+
79
90
build_args = [
80
91
swift_build ,
81
- '--product' , swpft_package_product_name ,
92
+ '--product' , swiftpm_package_product_name ,
82
93
'--package-path' , os .path .join (product .source_dir ),
83
94
'--build-path' , product .build_dir ,
84
95
'--configuration' , 'release' ,
85
- ]
96
+ ] + rpath_args
86
97
87
98
if product .args .verbose_build :
88
99
build_args .append ('--verbose' )
@@ -94,4 +105,4 @@ def run_swift_build(host_target, product, swpft_package_product_name):
94
105
95
106
bin_dir_path = shell .capture (
96
107
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