@@ -289,7 +289,6 @@ public final class ManifestLoader: ManifestLoaderProtocol {
289289 public var delegate : Delegate ?
290290
291291 private let databaseCacheDir : AbsolutePath ?
292- private let sdkRootCache = ThreadSafeBox < AbsolutePath > ( )
293292
294293 private let useInMemoryCache : Bool
295294 private let memoryCache = ThreadSafeKeyValueStore < CacheKey , ManifestJSONParser . Result > ( )
@@ -1114,35 +1113,12 @@ public final class ManifestLoader: ManifestLoaderProtocol {
11141113 }
11151114 }
11161115
1117- /// Returns path to the sdk, if possible.
1118- private func sdkRoot( ) -> AbsolutePath ? {
1119- if let sdkRoot = self . sdkRootCache. get ( ) {
1120- return sdkRoot
1121- }
1122-
1123- var sdkRootPath : AbsolutePath ? = nil
1124- // Find SDKROOT on macOS using xcrun.
1125- #if os(macOS)
1126- let foundPath = try ? AsyncProcess . checkNonZeroExit (
1127- args: " /usr/bin/xcrun " , " --sdk " , " macosx " , " --show-sdk-path " )
1128- guard let sdkRoot = foundPath? . spm_chomp ( ) , !sdkRoot. isEmpty else {
1129- return nil
1130- }
1131- if let path = try ? AbsolutePath ( validating: sdkRoot) {
1132- sdkRootPath = path
1133- self . sdkRootCache. put ( path)
1134- }
1135- #endif
1136-
1137- return sdkRootPath
1138- }
1139-
1140- /// Returns the interpreter flags for a manifest.
1141- public func interpreterFlags(
1142- for toolsVersion: ToolsVersion
1116+ package static func interpreterFlags(
1117+ for toolsVersion: ToolsVersion ,
1118+ toolchain: some Toolchain
11431119 ) -> [ String ] {
11441120 var cmd = [ String] ( )
1145- let modulesPath = self . toolchain. swiftPMLibrariesLocation. manifestModulesPath
1121+ let modulesPath = toolchain. swiftPMLibrariesLocation. manifestModulesPath
11461122 cmd += [ " -swift-version " , toolsVersion. swiftLanguageVersion. rawValue]
11471123 // if runtimePath is set to "PackageFrameworks" that means we could be developing SwiftPM in Xcode
11481124 // which produces a framework for dynamic package products.
@@ -1152,14 +1128,21 @@ public final class ManifestLoader: ManifestLoaderProtocol {
11521128 cmd += [ " -I " , modulesPath. pathString]
11531129 }
11541130 #if os(macOS)
1155- if let sdkRoot = self . toolchain. sdkRootPath ?? self . sdkRoot ( ) {
1131+ if let sdkRoot = toolchain. sdkRootPath {
11561132 cmd += [ " -sdk " , sdkRoot. pathString]
11571133 }
11581134 #endif
11591135 cmd += [ " -package-description-version " , toolsVersion. description]
11601136 return cmd
11611137 }
11621138
1139+ /// Returns the interpreter flags for a manifest.
1140+ public func interpreterFlags(
1141+ for toolsVersion: ToolsVersion
1142+ ) -> [ String ] {
1143+ return Self . interpreterFlags ( for: toolsVersion, toolchain: toolchain)
1144+ }
1145+
11631146 /// Returns path to the manifest database inside the given cache directory.
11641147 private static func manifestCacheDBPath( _ cacheDir: AbsolutePath ) -> AbsolutePath {
11651148 return cacheDir. appending ( " manifest.db " )
0 commit comments