@@ -283,15 +283,16 @@ def clean_swift_package(path, swiftc, sandbox_profile,
283
283
def build_swift_package (path , swiftc , swift_version , configuration ,
284
284
sandbox_profile , stdout = sys .stdout , stderr = sys .stderr ,
285
285
added_swift_flags = None ,
286
- incremental = False ):
286
+ incremental = False ,
287
+ override_swift_exec = None ):
287
288
"""Build a Swift package manager project."""
288
289
swift = os .path .join (os .path .dirname (swiftc ), 'swift' )
289
290
if not incremental :
290
291
clean_swift_package (path , swiftc , sandbox_profile ,
291
292
stdout = stdout , stderr = stderr )
292
293
env = os .environ
293
294
env ['DYLD_LIBRARY_PATH' ] = get_stdlib_platform_path (swiftc , 'macOS' )
294
- env ['SWIFT_EXEC' ] = swiftc
295
+ env ['SWIFT_EXEC' ] = override_swift_exec or swiftc
295
296
command = [swift , 'build' , '-C' , path , '--verbose' ,
296
297
'--configuration' , configuration ]
297
298
if (swift_branch not in ['swift-3.0-branch' ,
@@ -323,13 +324,14 @@ def build_swift_package(path, swiftc, swift_version, configuration,
323
324
def test_swift_package (path , swiftc , sandbox_profile ,
324
325
stdout = sys .stdout , stderr = sys .stderr ,
325
326
added_swift_flags = None ,
326
- incremental = False ):
327
+ incremental = False ,
328
+ override_swift_exec = None ):
327
329
"""Test a Swift package manager project."""
328
330
swift = os .path .join (os .path .dirname (swiftc ), 'swift' )
329
331
if not incremental :
330
332
clean_swift_package (path , swiftc , sandbox_profile )
331
333
env = os .environ
332
- env ['SWIFT_EXEC' ] = swiftc
334
+ env ['SWIFT_EXEC' ] = override_swift_exec or swiftc
333
335
command = [swift , 'test' , '-C' , path , '--verbose' ]
334
336
if added_swift_flags is not None :
335
337
for flag in added_swift_flags .split ():
@@ -372,7 +374,7 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
372
374
added_swift_flags , added_xcodebuild_flags ,
373
375
build_config , should_strip_resource_phases = False ,
374
376
stdout = sys .stdout , stderr = sys .stderr ,
375
- incremental = False , time_reporter = None ):
377
+ incremental = False , time_reporter = None , override_swift_exec = None ):
376
378
"""Call functions corresponding to actions."""
377
379
378
380
substitutions = action .copy ()
@@ -398,22 +400,24 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
398
400
sandbox_profile_package ,
399
401
stdout = stdout , stderr = stderr ,
400
402
added_swift_flags = added_swift_flags ,
401
- incremental = incremental )
403
+ incremental = incremental ,
404
+ override_swift_exec = override_swift_exec )
402
405
elif action ['action' ] == 'TestSwiftPackage' :
403
406
return test_swift_package (os .path .join (root_path , repo ['path' ]),
404
407
swiftc ,
405
408
sandbox_profile_package ,
406
409
stdout = stdout , stderr = stderr ,
407
410
added_swift_flags = added_swift_flags ,
408
- incremental = incremental )
411
+ incremental = incremental ,
412
+ override_swift_exec = override_swift_exec )
409
413
elif re .match (r'^(Build|Test)Xcode(Workspace|Project)(Scheme|Target)$' ,
410
414
action ['action' ]):
411
415
match = re .match (
412
416
r'^(Build|Test)Xcode(Workspace|Project)(Scheme|Target)$' ,
413
417
action ['action' ]
414
418
)
415
419
416
- initial_xcodebuild_flags = ['SWIFT_EXEC=%s' % swiftc ,
420
+ initial_xcodebuild_flags = ['SWIFT_EXEC=%s' % ( override_swift_exec or swiftc ) ,
417
421
'-IDEPackageSupportDisableManifestSandbox=YES' ]
418
422
419
423
if build_config == 'debug' :
@@ -543,11 +547,18 @@ def add_arguments(parser):
543
547
help = 'swiftc executable' ,
544
548
required = True ,
545
549
type = os .path .abspath )
550
+ parser .add_argument ('--override-swift-exec' ,
551
+ metavar = 'PATH' ,
552
+ help = 'override the SWIFT_EXEC that is used to build the projects' ,
553
+ type = os .path .abspath )
546
554
else :
547
555
parser .add_argument ('--swiftc' ,
548
556
metavar = 'PATH' ,
549
557
help = 'swiftc executable' ,
550
558
required = True )
559
+ parser .add_argument ('--override-swift-exec' ,
560
+ metavar = 'PATH' ,
561
+ help = 'override the SWIFT_EXEC that is used to build the projects' )
551
562
parser .add_argument ('--projects' ,
552
563
metavar = 'PATH' ,
553
564
required = True ,
@@ -1031,6 +1042,7 @@ def __init__(self, swiftc, swift_version, swift_branch, job_type,
1031
1042
strip_resource_phases ,
1032
1043
project_cache_path ,
1033
1044
time_reporter ,
1045
+ override_swift_exec ,
1034
1046
action , project ):
1035
1047
self .swiftc = swiftc
1036
1048
self .swift_version = swift_version
@@ -1049,6 +1061,7 @@ def __init__(self, swiftc, swift_version, swift_branch, job_type,
1049
1061
self .strip_resource_phases = strip_resource_phases
1050
1062
self .time_reporter = time_reporter
1051
1063
self .job_type = job_type
1064
+ self .override_swift_exec = override_swift_exec
1052
1065
self .init ()
1053
1066
1054
1067
def init (self ):
@@ -1107,7 +1120,8 @@ def dispatch(self, identifier, stdout=sys.stdout, stderr=sys.stderr):
1107
1120
self .build_config ,
1108
1121
incremental = self .skip_clean ,
1109
1122
time_reporter = self .time_reporter ,
1110
- stdout = stdout , stderr = stderr )
1123
+ stdout = stdout , stderr = stderr ,
1124
+ override_swift_exec = self .override_swift_exec )
1111
1125
except common .ExecuteCommandFailure as error :
1112
1126
return self .failed (identifier , error )
1113
1127
else :
@@ -1146,6 +1160,7 @@ def __init__(self,
1146
1160
only_latest_versions ,
1147
1161
project_cache_path ,
1148
1162
time_reporter ,
1163
+ override_swift_exec ,
1149
1164
action , version , project ):
1150
1165
super (CompatActionBuilder , self ).__init__ (
1151
1166
swiftc , swift_version , swift_branch , job_type ,
@@ -1157,6 +1172,7 @@ def __init__(self,
1157
1172
strip_resource_phases ,
1158
1173
project_cache_path ,
1159
1174
time_reporter ,
1175
+ override_swift_exec ,
1160
1176
action , project
1161
1177
)
1162
1178
self .only_latest_versions = only_latest_versions
@@ -1184,7 +1200,8 @@ def dispatch(self, identifier, stdout=sys.stdout, stderr=sys.stderr):
1184
1200
incremental = self .skip_clean ,
1185
1201
should_strip_resource_phases = self .strip_resource_phases ,
1186
1202
time_reporter = self .time_reporter ,
1187
- stdout = stdout , stderr = stderr )
1203
+ stdout = stdout , stderr = stderr ,
1204
+ override_swift_exec = self .override_swift_exec )
1188
1205
except common .ExecuteCommandFailure as error :
1189
1206
return self .failed (identifier , error )
1190
1207
else :
@@ -1331,7 +1348,7 @@ def __init__(self, swiftc, swift_version, swift_branch, job_type,
1331
1348
sandbox_profile_package ,
1332
1349
added_swift_flags , build_config ,
1333
1350
strip_resource_phases ,
1334
- time_reporter ,
1351
+ time_reporter , override_swift_exec ,
1335
1352
project , action ):
1336
1353
super (IncrementalActionBuilder ,
1337
1354
self ).__init__ (swiftc , swift_version , swift_branch , job_type ,
@@ -1342,6 +1359,7 @@ def __init__(self, swiftc, swift_version, swift_branch, job_type,
1342
1359
build_config = build_config ,
1343
1360
strip_resource_phases = strip_resource_phases ,
1344
1361
time_reporter = time_reporter ,
1362
+ override_swift_exec = override_swift_exec ,
1345
1363
project = project ,
1346
1364
action = action )
1347
1365
self .proj_path = os .path .join (self .root_path , self .project ['path' ])
@@ -1449,7 +1467,8 @@ def dispatch(self, identifier, incremental, stdout=sys.stdout, stderr=sys.stderr
1449
1467
should_strip_resource_phases = False ,
1450
1468
time_reporter = self .time_reporter ,
1451
1469
stdout = stdout , stderr = stderr ,
1452
- incremental = incremental )
1470
+ incremental = incremental ,
1471
+ override_swift_exec = self .override_swift_exec )
1453
1472
except common .ExecuteCommandFailure as error :
1454
1473
return self .failed (identifier , error )
1455
1474
else :
0 commit comments