@@ -16,34 +16,50 @@ import TSCBasic
1616/// using the package manager with alternate toolchains in the future.
1717public struct ToolchainConfiguration {
1818 /// The path of the swift compiler.
19- public let swiftCompiler : AbsolutePath
19+ public let swiftCompilerPath : AbsolutePath
2020
2121 /// Extra flags to pass the Swift compiler.
2222 public let swiftCompilerFlags : [ String ]
2323
24- /// The path of the library resources.
25- public let libDir : AbsolutePath
26-
27- /// The bin directory.
28- public let binDir : AbsolutePath ?
24+ /// SwiftPM library paths.
25+ public let swiftPMLibrariesLocation : SwiftPMLibrariesLocation
2926
3027 /// The path to SDK root.
3128 ///
3229 /// If provided, it will be passed to the swift interpreter.
33- public let sdkRoot : AbsolutePath ?
30+ public let sdkRootPath : AbsolutePath ?
3431
3532 /// XCTest Location
36- public let xctestLocation : AbsolutePath ?
33+ public let xctestPath : AbsolutePath ?
3734
3835 /// Creates the set of manifest resources associated with a `swiftc` executable.
3936 ///
4037 /// - Parameters:
41- /// - swiftCompiler : The absolute path of the associated `swiftc` executable.
38+ /// - swiftCompilerPath : The absolute path of the associated `swiftc` executable.
4239 /// - swiftCompilerFlags: Extra flags to pass the Swift compiler.: Extra flags to pass the Swift compiler.
43- /// - libDir: The path of the library resources.
44- /// - binDir: The bin directory.
45- /// - sdkRoot: The path to SDK root.
46- /// - xctestLocation: XCTest Location
40+ /// - swiftPMLibrariesRootPath: Custom path for SwiftPM libraries.
41+ /// - sdkRootPath: The path to SDK root.
42+ /// - xctestPath: XCTest Location
43+ public init (
44+ swiftCompilerPath: AbsolutePath ,
45+ swiftCompilerFlags: [ String ] = [ ] ,
46+ swiftPMLibrariesLocation: SwiftPMLibrariesLocation ? = nil ,
47+ sdkRootPath: AbsolutePath ? = nil ,
48+ xctestPath: AbsolutePath ? = nil
49+ ) {
50+ let swiftPMLibrariesLocation = swiftPMLibrariesLocation ?? {
51+ return . init( swiftCompilerPath: swiftCompilerPath)
52+ } ( )
53+
54+ self . swiftCompilerPath = swiftCompilerPath
55+ self . swiftCompilerFlags = swiftCompilerFlags
56+ self . swiftPMLibrariesLocation = swiftPMLibrariesLocation
57+ self . sdkRootPath = sdkRootPath
58+ self . xctestPath = xctestPath
59+ }
60+
61+ // deprecated 8/2021
62+ @available ( * , deprecated, message: " use non-deprecated initializer instead " )
4763 public init (
4864 swiftCompiler: AbsolutePath ,
4965 swiftCompilerFlags: [ String ] = [ ] ,
@@ -52,15 +68,36 @@ public struct ToolchainConfiguration {
5268 sdkRoot: AbsolutePath ? = nil ,
5369 xctestLocation: AbsolutePath ? = nil
5470 ) {
55- self . swiftCompiler = swiftCompiler
56- self . swiftCompilerFlags = swiftCompilerFlags
57- self . libDir = libDir ?? Self . libDir ( forBinDir: swiftCompiler. parentDirectory)
58- self . binDir = binDir
59- self . sdkRoot = sdkRoot
60- self . xctestLocation = xctestLocation
71+ self . init (
72+ swiftCompilerPath: swiftCompiler,
73+ swiftCompilerFlags: swiftCompilerFlags,
74+ swiftPMLibrariesLocation: libDir. map { . init( root: $0) } ,
75+ sdkRootPath: sdkRoot,
76+ xctestPath: xctestLocation
77+ )
6178 }
79+ }
80+
81+ extension ToolchainConfiguration {
82+ public struct SwiftPMLibrariesLocation {
83+ public var manifestAPI : AbsolutePath
84+ public var pluginAPI : AbsolutePath
85+
86+ public init ( manifestAPI: AbsolutePath , pluginAPI: AbsolutePath ) {
87+ self . manifestAPI = manifestAPI
88+ self . pluginAPI = pluginAPI
89+ }
90+
91+ public init ( root: AbsolutePath ) {
92+ self . init (
93+ manifestAPI: root. appending ( component: " ManifestAPI " ) ,
94+ pluginAPI: root. appending ( component: " PluginAPI " )
95+ )
96+ }
6297
63- public static func libDir( forBinDir binDir: AbsolutePath ) -> AbsolutePath {
64- return binDir. parentDirectory. appending ( components: " lib " , " swift " , " pm " )
98+ fileprivate init ( swiftCompilerPath: AbsolutePath ) {
99+ let rootPath = swiftCompilerPath. parentDirectory. parentDirectory. appending ( components: " lib " , " swift " , " pm " )
100+ self . init ( root: rootPath)
101+ }
65102 }
66103}
0 commit comments