9
9
import subprocess
10
10
import sys
11
11
12
+ driver_tools = ['swift' , 'swift-frontend' , 'ld' , 'libtool' , 'clang' ,
13
+ 'swift-autolink-extract' , 'lldb' , 'dwarfdump' , 'swift-help' ]
14
+
12
15
def swiftpm (action , swift_exec , swiftpm_args , env = None ):
13
16
cmd = [swift_exec , action ] + swiftpm_args
14
17
print (' ' .join (cmd ))
@@ -91,9 +94,11 @@ def should_test_parallel():
91
94
return True
92
95
93
96
94
- def handle_invocation (swift_exec , swift_frontend_exec , args ):
97
+ def handle_invocation (toolchain_bin , args ):
95
98
swiftpm_args = get_swiftpm_options (args )
96
99
100
+ swift_exec = os .path .join (toolchain_bin , 'swift' )
101
+
97
102
env = os .environ
98
103
# Use local dependencies (i.e. checked out next to swift-driver).
99
104
if not args .no_local_deps :
@@ -108,7 +113,8 @@ def handle_invocation(swift_exec, swift_frontend_exec, args):
108
113
if args .action == 'build' :
109
114
swiftpm ('build' , swift_exec , swiftpm_args , env )
110
115
elif args .action == 'test' :
111
- env ['SWIFT_DRIVER_SWIFT_FRONTEND_EXEC' ] = '%s' % (swift_frontend_exec )
116
+ for tool in driver_tools :
117
+ env ['SWIFT_DRIVER_' + tool .upper ().replace ('-' ,'_' ) + '_EXEC' ] = '%s' % (os .path .join (toolchain_bin , tool ))
112
118
env ['SWIFT_EXEC' ] = '%sc' % (swift_exec )
113
119
test_args = swiftpm_args
114
120
if should_test_parallel ():
@@ -151,13 +157,11 @@ def add_common_args(parser):
151
157
args .toolchain = os .path .abspath (args .toolchain )
152
158
153
159
if args .toolchain :
154
- swift_exec = os .path .join (args .toolchain , 'bin' , 'swift' )
155
- swift_frontend_exec = os .path .join (args .toolchain , 'bin' , 'swift-frontend' )
160
+ toolchain_bin = os .path .join (args .toolchain , 'bin' )
156
161
else :
157
- swift_exec = 'swift'
158
- swift_frontend_exec = 'swift-frontend'
162
+ toolchain_bin = ''
159
163
160
- handle_invocation (swift_exec , swift_frontend_exec , args )
164
+ handle_invocation (toolchain_bin , args )
161
165
162
166
if __name__ == '__main__' :
163
167
main ()
0 commit comments