@@ -280,8 +280,8 @@ def clean_swift_package(path, swiftc, sandbox_profile,
280280 stdout = stdout , stderr = stderr )
281281
282282
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 ,
285285 added_swift_flags = None ,
286286 incremental = False ):
287287 """Build a Swift package manager project."""
@@ -297,6 +297,20 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
297297 if (swift_branch not in ['swift-3.0-branch' ,
298298 'swift-3.1-branch' ]):
299299 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+
300314 if added_swift_flags is not None :
301315 for flag in added_swift_flags .split ():
302316 command += ["-Xswiftc" , flag ]
@@ -379,7 +393,7 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
379393 if not build_config :
380394 build_config = action ['configuration' ]
381395 return build_swift_package (os .path .join (root_path , repo ['path' ]),
382- swiftc ,
396+ swiftc , swift_version ,
383397 build_config ,
384398 sandbox_profile_package ,
385399 stdout = stdout , stderr = stderr ,
0 commit comments