@@ -109,7 +109,9 @@ func withSession(
109
109
}
110
110
}
111
111
112
- private final class PlanningOperationDelegate : SWBPlanningOperationDelegate , Sendable {
112
+ package final class SwiftBuildSystemPlanningOperationDelegate : SWBPlanningOperationDelegate , SWBIndexingDelegate , Sendable {
113
+ package init ( ) { }
114
+
113
115
public func provisioningTaskInputs(
114
116
targetGUID: String ,
115
117
provisioningSourceData: SWBProvisioningTaskInputsSourceData
@@ -194,7 +196,7 @@ public struct PluginConfiguration {
194
196
}
195
197
196
198
public final class SwiftBuildSystem : SPMBuildCore . BuildSystem {
197
- private let buildParameters : BuildParameters
199
+ package let buildParameters : BuildParameters
198
200
private let packageGraphLoader : ( ) async throws -> ModulesGraph
199
201
private let packageManagerResourcesDirectory : Basics . AbsolutePath ?
200
202
private let logLevel : Basics . Diagnostic . Severity
@@ -349,7 +351,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
349
351
)
350
352
}
351
353
352
- try await writePIF ( buildParameters : buildParameters )
354
+ try await writePIF ( )
353
355
354
356
return try await startSWBuildOperation (
355
357
pifTargetName: subset. pifTargetName,
@@ -545,7 +547,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
545
547
546
548
let operation = try await session. createBuildOperation (
547
549
request: request,
548
- delegate: PlanningOperationDelegate ( )
550
+ delegate: SwiftBuildSystemPlanningOperationDelegate ( )
549
551
)
550
552
551
553
var buildState = BuildState ( )
@@ -631,7 +633,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
631
633
)
632
634
}
633
635
634
- private func makeBuildParameters( session: SWBBuildServiceSession , genSymbolGraph: Bool ) async throws -> SwiftBuild . SWBBuildParameters {
636
+ package func makeBuildParameters( session: SWBBuildServiceSession , genSymbolGraph: Bool ) async throws -> SwiftBuild . SWBBuildParameters {
635
637
// Generate the run destination parameters.
636
638
let runDestination = makeRunDestination ( )
637
639
@@ -767,8 +769,8 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
767
769
buildProductsPath: ddPathPrefix + " /Products " ,
768
770
buildIntermediatesPath: ddPathPrefix + " /Intermediates.noindex " ,
769
771
pchPath: ddPathPrefix + " /PCH " ,
770
- indexRegularBuildProductsPath: nil ,
771
- indexRegularBuildIntermediatesPath: nil ,
772
+ indexRegularBuildProductsPath: ddPathPrefix + " /Index/Products " ,
773
+ indexRegularBuildIntermediatesPath: ddPathPrefix + " /Index/Intermediates.noindex " ,
772
774
indexPCHPath: ddPathPrefix,
773
775
indexDataStoreFolderPath: ddPathPrefix,
774
776
indexEnableDataStore: request. parameters. arenaInfo? . indexEnableDataStore ?? false
@@ -902,7 +904,9 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
902
904
}
903
905
}
904
906
905
- public func writePIF( buildParameters: BuildParameters ) async throws {
907
+ public func writePIF( ) async throws {
908
+ pifBuilder = . init( )
909
+ packageGraph = . init( )
906
910
let pifBuilder = try await getPIFBuilder ( )
907
911
let pif = try await pifBuilder. generatePIF (
908
912
printPIFManifestGraphviz: buildParameters. printPIFManifestGraphviz,
@@ -912,6 +916,27 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
912
916
try self . fileSystem. writeIfChanged ( path: buildParameters. pifManifest, string: pif)
913
917
}
914
918
919
+ package struct LongLivedBuildServiceSession {
920
+ package var session : SWBBuildServiceSession
921
+ package var diagnostics : [ SwiftBuildMessage . DiagnosticInfo ]
922
+ package var teardownHandler : ( ) async throws -> Void
923
+ }
924
+
925
+ package func createLongLivedSession( name: String ) async throws -> LongLivedBuildServiceSession {
926
+ let service = try await SWBBuildService ( connectionMode: . inProcessStatic( swiftbuildServiceEntryPoint) )
927
+ do {
928
+ let ( session, diagnostics) = try await createSession ( service: service, name: name, toolchainPath: buildParameters. toolchain. toolchainDir, packageManagerResourcesDirectory: packageManagerResourcesDirectory)
929
+ let teardownHandler = {
930
+ try await session. close ( )
931
+ await service. close ( )
932
+ }
933
+ return LongLivedBuildServiceSession ( session: session, diagnostics: diagnostics, teardownHandler: teardownHandler)
934
+ } catch {
935
+ await service. close ( )
936
+ throw error
937
+ }
938
+ }
939
+
915
940
public func cancel( deadline: DispatchTime ) throws { }
916
941
917
942
/// Returns the package graph using the graph loader closure.
0 commit comments