@@ -74,7 +74,7 @@ package struct LLBuildSystemConfiguration {
7474 self . traitConfiguration = traitConfiguration
7575 self . manifestPath = manifestPath ?? destinationBuildParameters. llbuildManifest
7676 self . databasePath = databasePath ?? scratchDirectory. appending ( " build.db " )
77- self . buildDescriptionPath = buildDescriptionPath ?? destinationBuildParameters . buildDescriptionPath
77+ self . buildDescriptionPath = buildDescriptionPath ?? BuildOperation . buildDescriptionPath ( for : destinationBuildParameters )
7878 self . fileSystem = fileSystem
7979 self . logLevel = logLevel
8080 self . outputStream = outputStream
@@ -109,13 +109,6 @@ package struct LLBuildSystemConfiguration {
109109 }
110110 }
111111
112- func buildPath( for description: BuildParameters . Destination ) -> AbsolutePath {
113- switch description {
114- case . host: self . toolsBuildParameters. buildPath
115- case . target: self . destinationBuildParameters. buildPath
116- }
117- }
118-
119112 func dataPath( for description: BuildParameters . Destination ) -> AbsolutePath {
120113 switch description {
121114 case . host: self . toolsBuildParameters. dataPath
@@ -125,8 +118,8 @@ package struct LLBuildSystemConfiguration {
125118
126119 func buildDescriptionPath( for description: BuildParameters . Destination ) -> AbsolutePath {
127120 switch description {
128- case . host: self . toolsBuildParameters. buildDescriptionPath
129- case . target: self . destinationBuildParameters. buildDescriptionPath
121+ case . host: BuildOperation . buildDescriptionPath ( for : self . toolsBuildParameters)
122+ case . target: BuildOperation . buildDescriptionPath ( for : self . destinationBuildParameters)
130123 }
131124 }
132125
@@ -200,6 +193,44 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
200193
201194 public var hasIntegratedAPIDigesterSupport : Bool { false }
202195
196+ public func buildProductsPath( for parameters: BuildParameters ) async throws -> AbsolutePath {
197+ Self . buildProductsPath ( for: parameters)
198+ }
199+
200+ public static func buildProductsPath( for parameters: BuildParameters ) -> AbsolutePath {
201+ parameters. dataPath. appending ( component: parameters. configuration. dirname)
202+ }
203+
204+ /// The path to the index store directory for the given build parameters under the native build system.
205+ public static func indexStore( for parameters: BuildParameters ) -> AbsolutePath {
206+ buildProductsPath ( for: parameters) . appending ( components: " index " , " store " )
207+ }
208+
209+ /// The path to the build description for the given build parameters under the native build system.
210+ public static func buildDescriptionPath( for parameters: BuildParameters ) -> AbsolutePath {
211+ buildProductsPath ( for: parameters) . appending ( components: " description.json " )
212+ }
213+
214+ /// The path to the test output file for the given build parameters under the native build system.
215+ public static func testOutputPath( for parameters: BuildParameters ) -> AbsolutePath {
216+ buildProductsPath ( for: parameters) . appending ( component: " testOutput.txt " )
217+ }
218+
219+ /// Returns the path to the binary of a product for the given build parameters under the native build system.
220+ public static func binaryPath( for product: ResolvedProduct , parameters: BuildParameters ) throws -> AbsolutePath {
221+ try buildProductsPath ( for: parameters) . appending ( parameters. binaryRelativePath ( for: product) )
222+ }
223+
224+ /// Returns the path to the built binary for a macro module under the native build system.
225+ public static func macroBinaryPath( for module: ResolvedModule , parameters: BuildParameters ) throws -> AbsolutePath {
226+ assert ( module. type == . macro)
227+ #if BUILD_MACROS_AS_DYLIBS
228+ return try buildProductsPath ( for: parameters) . appending ( parameters. dynamicLibraryPath ( for: module. name) )
229+ #else
230+ return try buildProductsPath ( for: parameters) . appending ( parameters. executablePath ( for: module. name) )
231+ #endif
232+ }
233+
203234 public convenience init (
204235 productsBuildParameters: BuildParameters ,
205236 toolsBuildParameters: BuildParameters ,
@@ -524,7 +555,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
524555 do {
525556 try self . fileSystem. createSymbolicLink (
526557 oldBuildPath,
527- pointingAt: self . config . buildPath ( for: . target ) ,
558+ pointingAt: Self . buildProductsPath ( for: self . config . destinationBuildParameters ) ,
528559 relative: true
529560 )
530561 } catch {
@@ -984,7 +1015,7 @@ extension BuildOperation {
9841015 // `buildPackageStructure` to recognize the split.
9851016 config. databasePath = config. scratchDirectory. appending ( " plugin-tools.db " )
9861017
987- config. buildDescriptionPath = config . buildPath ( for: . host ) . appending (
1018+ config. buildDescriptionPath = Self . buildProductsPath ( for: self . config . toolsBuildParameters ) . appending (
9881019 component: " plugin-tools-description.json "
9891020 )
9901021
@@ -1034,7 +1065,7 @@ extension BuildOperation {
10341065 if let result = try await buildToolBuilder ( name, path) {
10351066 return result
10361067 } else {
1037- return config . buildPath ( for: . host ) . appending ( path)
1068+ return Self . buildProductsPath ( for: config . toolsBuildParameters ) . appending ( path)
10381069 }
10391070 }
10401071
0 commit comments