@@ -16,34 +16,54 @@ 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
24+ /// SwiftPM library paths .
25+ public let swiftPMLibrariesLocation : SwiftPMLibrariesLocation
2626
27- /// The bin directory.
28- public let binDir : AbsolutePath ?
27+ /// The swiftpm binary directory.
28+ // public let swiftPMBinaryPath : AbsolutePath?
2929
3030 /// The path to SDK root.
3131 ///
3232 /// If provided, it will be passed to the swift interpreter.
33- public let sdkRoot : AbsolutePath ?
33+ public let sdkRootPath : AbsolutePath ?
3434
3535 /// XCTest Location
36- public let xctestLocation : AbsolutePath ?
36+ public let xctestPath : AbsolutePath ?
3737
3838 /// Creates the set of manifest resources associated with a `swiftc` executable.
3939 ///
4040 /// - Parameters:
41- /// - swiftCompiler : The absolute path of the associated `swiftc` executable.
41+ /// - swiftCompilerPath : The absolute path of the associated `swiftc` executable.
4242 /// - 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
43+ /// - swiftPMLibrariesRootPath: Custom path for SwiftPM libraries.
44+ /// - sdkRootPath: The path to SDK root.
45+ /// - xctestPath: XCTest Location
46+ public init (
47+ swiftCompilerPath: AbsolutePath ,
48+ swiftCompilerFlags: [ String ] = [ ] ,
49+ swiftPMLibrariesLocation: SwiftPMLibrariesLocation ? = nil ,
50+ sdkRootPath: AbsolutePath ? = nil ,
51+ xctestPath: AbsolutePath ? = nil
52+ ) {
53+ let swiftPMLibrariesLocation = swiftPMLibrariesLocation ?? {
54+ let rootPath = Self . swiftPMLibrariesPath ( from: swiftCompilerPath. parentDirectory. parentDirectory)
55+ return . init( root: rootPath)
56+ } ( )
57+
58+ self . swiftCompilerPath = swiftCompilerPath
59+ self . swiftCompilerFlags = swiftCompilerFlags
60+ self . swiftPMLibrariesLocation = swiftPMLibrariesLocation
61+ self . sdkRootPath = sdkRootPath
62+ self . xctestPath = xctestPath
63+ }
64+
65+ // deprecated 8/2021
66+ @available ( * , deprecated, message: " use non-deprecated initializer instead " )
4767 public init (
4868 swiftCompiler: AbsolutePath ,
4969 swiftCompilerFlags: [ String ] = [ ] ,
@@ -52,15 +72,36 @@ public struct ToolchainConfiguration {
5272 sdkRoot: AbsolutePath ? = nil ,
5373 xctestLocation: AbsolutePath ? = nil
5474 ) {
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
75+ self . init (
76+ swiftCompilerPath: swiftCompiler,
77+ swiftCompilerFlags: swiftCompilerFlags,
78+ swiftPMLibrariesLocation: libDir. map { . init( root: $0) } ,
79+ sdkRootPath: sdkRoot,
80+ xctestPath: xctestLocation
81+ )
82+ }
83+
84+ public static func swiftPMLibrariesPath( from rootPath: AbsolutePath ) -> AbsolutePath {
85+ return rootPath. appending ( components: " lib " , " swift " , " pm " )
6186 }
6287
63- public static func libDir( forBinDir binDir: AbsolutePath ) -> AbsolutePath {
64- return binDir. parentDirectory. appending ( components: " lib " , " swift " , " pm " )
88+ public struct SwiftPMLibrariesLocation {
89+ public var root : AbsolutePath
90+ public var manifestAPI : AbsolutePath
91+ public var pluginsAPI : AbsolutePath
92+
93+ public init ( root: AbsolutePath , manifestAPI: AbsolutePath , pluginsAPI: AbsolutePath ) {
94+ self . root = root
95+ self . manifestAPI = manifestAPI
96+ self . pluginsAPI = pluginsAPI
97+ }
98+
99+ public init ( root: AbsolutePath ) {
100+ self . init (
101+ root: root,
102+ manifestAPI: root. appending ( component: " ManifestAPI " ) ,
103+ pluginsAPI: root. appending ( component: " PluginsAPI " )
104+ )
105+ }
65106 }
66107}
0 commit comments