@@ -289,7 +289,6 @@ public final class ManifestLoader: ManifestLoaderProtocol {
289
289
public var delegate : Delegate ?
290
290
291
291
private let databaseCacheDir : AbsolutePath ?
292
- private let sdkRootCache = ThreadSafeBox < AbsolutePath > ( )
293
292
294
293
private let useInMemoryCache : Bool
295
294
private let memoryCache = ThreadSafeKeyValueStore < CacheKey , ManifestJSONParser . Result > ( )
@@ -1114,35 +1113,12 @@ public final class ManifestLoader: ManifestLoaderProtocol {
1114
1113
}
1115
1114
}
1116
1115
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
1143
1119
) -> [ String ] {
1144
1120
var cmd = [ String] ( )
1145
- let modulesPath = self . toolchain. swiftPMLibrariesLocation. manifestModulesPath
1121
+ let modulesPath = toolchain. swiftPMLibrariesLocation. manifestModulesPath
1146
1122
cmd += [ " -swift-version " , toolsVersion. swiftLanguageVersion. rawValue]
1147
1123
// if runtimePath is set to "PackageFrameworks" that means we could be developing SwiftPM in Xcode
1148
1124
// which produces a framework for dynamic package products.
@@ -1152,14 +1128,21 @@ public final class ManifestLoader: ManifestLoaderProtocol {
1152
1128
cmd += [ " -I " , modulesPath. pathString]
1153
1129
}
1154
1130
#if os(macOS)
1155
- if let sdkRoot = self . toolchain. sdkRootPath ?? self . sdkRoot ( ) {
1131
+ if let sdkRoot = toolchain. sdkRootPath {
1156
1132
cmd += [ " -sdk " , sdkRoot. pathString]
1157
1133
}
1158
1134
#endif
1159
1135
cmd += [ " -package-description-version " , toolsVersion. description]
1160
1136
return cmd
1161
1137
}
1162
1138
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
+
1163
1146
/// Returns path to the manifest database inside the given cache directory.
1164
1147
private static func manifestCacheDBPath( _ cacheDir: AbsolutePath ) -> AbsolutePath {
1165
1148
return cacheDir. appending ( " manifest.db " )
0 commit comments