File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed 
Sources/PackageModel/SwiftSDKs Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -698,7 +698,8 @@ public struct SwiftSDK: Equatable {
698698                ) 
699699            } 
700700
701-             swiftSDK. append ( toolsetRootPath:  binDir. appending ( components:  " usr " ,  " bin " ) ) 
701+             // `--tooolchain` should override existing anything in the SDK and search paths.
702+             swiftSDK. prepend ( toolsetRootPath:  binDir. appending ( components:  " usr " ,  " bin " ) ) 
702703        } 
703704        if  let  sdk =  customCompileSDK { 
704705            swiftSDK. pathsConfiguration. sdkRootPath =  sdk
@@ -727,7 +728,20 @@ public struct SwiftSDK: Equatable {
727728        self . toolset. knownTools [ . swiftCompiler]  =  properties
728729    } 
729730
731+     /// Prepends a path to the array of toolset root paths.
732+     ///
733+     /// Note: Use this operation if you want new root path to take priority over existing paths.
734+     ///
735+     /// - Parameter toolsetRootPath: new path to add to Swift SDK's toolset.
736+     public  mutating  func  prepend( toolsetRootPath path:  AbsolutePath )  { 
737+         self . toolset. rootPaths. insert ( path,  at:  0 ) 
738+     } 
739+ 
730740    /// Appends a path to the array of toolset root paths.
741+     ///
742+     /// Note: The paths are evaluated in insertion order which means that newly added path would
743+     /// have a lower priority vs. existing paths.
744+     ///
731745    /// - Parameter toolsetRootPath: new path to add to Swift SDK's toolset.
732746    public  mutating  func  append( toolsetRootPath:  AbsolutePath )  { 
733747        self . toolset. rootPaths. append ( toolsetRootPath) 
Original file line number Diff line number Diff line change @@ -424,7 +424,7 @@ final class SwiftSDKBundleTests: XCTestCase {
424424                fileSystem:  fileSystem
425425            ) 
426426            // With toolset in the target SDK, it should contain the host toolset roots at the end.
427-             XCTAssertEqual ( targetSwiftSDK. toolset. rootPaths,  hostSwiftSDK. toolset. rootPaths  +   [ toolsetRootPath ] ) 
427+             XCTAssertEqual ( targetSwiftSDK. toolset. rootPaths,  [ toolsetRootPath ]   +   hostSwiftSDK. toolset. rootPaths) 
428428        } 
429429
430430        do  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments