@@ -280,8 +280,8 @@ def clean_swift_package(path, swiftc, sandbox_profile,
280
280
stdout = stdout , stderr = stderr )
281
281
282
282
283
- def build_swift_package (path , swiftc , configuration , sandbox_profile ,
284
- stdout = sys .stdout , stderr = sys .stderr ,
283
+ def build_swift_package (path , swiftc , swift_version , configuration ,
284
+ sandbox_profile , stdout = sys .stdout , stderr = sys .stderr ,
285
285
added_swift_flags = None ,
286
286
incremental = False ):
287
287
"""Build a Swift package manager project."""
@@ -297,6 +297,20 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
297
297
if (swift_branch not in ['swift-3.0-branch' ,
298
298
'swift-3.1-branch' ]):
299
299
command .insert (2 , '--disable-sandbox' )
300
+
301
+ if swift_version :
302
+ if '.' not in swift_version :
303
+ swift_version += '.0'
304
+
305
+ major , minor = swift_version .split ('.' , 1 )
306
+ # Need to use float for minor version parsing
307
+ # because it's possible that it would be specified
308
+ # as e.g. `4.0.3`
309
+ if int (major ) == 4 and float (minor ) == 2.0 :
310
+ command += ['-Xswiftc' , '-swift-version' , '-Xswiftc' , swift_version ]
311
+ else :
312
+ command += ['-Xswiftc' , '-swift-version' , '-Xswiftc' , major ]
313
+
300
314
if added_swift_flags is not None :
301
315
for flag in added_swift_flags .split ():
302
316
command += ["-Xswiftc" , flag ]
@@ -379,7 +393,7 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
379
393
if not build_config :
380
394
build_config = action ['configuration' ]
381
395
return build_swift_package (os .path .join (root_path , repo ['path' ]),
382
- swiftc ,
396
+ swiftc , swift_version ,
383
397
build_config ,
384
398
sandbox_profile_package ,
385
399
stdout = stdout , stderr = stderr ,
0 commit comments