Skip to content

Commit 4b503cd

Browse files
authored
Make some SWBBuildService APIs public (#373)
This will allow experimentation with making build service executables which use Swift Build as a dependency.
1 parent c8e594b commit 4b503cd

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

Sources/SWBBuildService/BuildOperationMessages.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import struct Foundation.Date
1414

1515
package import SWBBuildSystem
16-
package import SWBCore
16+
public import SWBCore
1717
import SWBLibc
1818
import SWBProtocol
1919
import SWBServiceCore
@@ -25,7 +25,7 @@ import SWBMacro
2525
// FIXME: Workaround: <rdar://problem/26249252> Unable to prefer my own type over NS renamed types
2626
import class SWBTaskExecution.Task
2727

28-
package protocol ActiveBuildOperation {
28+
public protocol ActiveBuildOperation {
2929
/// A unique identifier for this build.
3030
var id: Int { get }
3131

Sources/SWBBuildService/BuildService.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import Foundation
1414
import SWBBuildSystem
1515
import SWBCore
1616
import SWBLibc
17-
package import SWBProtocol
18-
package import SWBServiceCore
17+
public import SWBProtocol
18+
public import SWBServiceCore
1919
import SWBUtil
2020

2121
typealias Cache = SWBUtil.Cache
@@ -46,7 +46,7 @@ private struct CoreCacheKey: Equatable, Hashable {
4646
/// This is the central class which manages a service instance communicating with a unique client.
4747
///
4848
/// This class is designed to be thread safe: clients can send messages from any thread and they will be sent in FIFO order. Note that individual messages are currently always processed in FIFO order non-concurrently. Messages which require non-trivial amounts of time to service should always be split to use an asynchronous reply.
49-
package class BuildService: Service, @unchecked Sendable {
49+
open class BuildService: Service, @unchecked Sendable {
5050
/// The map of registered sessions.
5151
var sessionMap = Dictionary<String, Session>()
5252

@@ -67,7 +67,7 @@ package class BuildService: Service, @unchecked Sendable {
6767
/// Async lock to guard access to `sharedCoreCache`, since its `getOrInsert` method can't be given an async closure.
6868
private var sharedCoreCacheLock = ActorLock()
6969

70-
package func nextBuildOperationID() -> Int {
70+
public func nextBuildOperationID() -> Int {
7171
return lastBuildOperationID.withLock { value in
7272
let lastID = value
7373
value += 1

Sources/SWBBuildService/Messages.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import SWBBuildSystem
1414
package import SWBCore
1515
import SWBProtocol
16-
package import SWBServiceCore
16+
public import SWBServiceCore
1717
import SWBTaskConstruction
1818
import SWBTaskExecution
1919
package import SWBUtil
@@ -1521,10 +1521,10 @@ private struct ClearAllCaches: MessageHandler {
15211521

15221522
// MARK: ServiceExtension Support
15231523

1524-
package struct ServiceSessionMessageHandlers: ServiceExtension {
1525-
package init() {}
1524+
public struct ServiceSessionMessageHandlers: ServiceExtension {
1525+
public init() {}
15261526

1527-
package func register(_ service: Service) {
1527+
public func register(_ service: Service) {
15281528
service.registerMessageHandler(CreateSessionHandler.self)
15291529
service.registerMessageHandler(ListSessionsHandler.self)
15301530
service.registerMessageHandler(WaitForQuiescenceHandler.self)
@@ -1537,10 +1537,10 @@ package struct ServiceSessionMessageHandlers: ServiceExtension {
15371537
}
15381538
}
15391539

1540-
package struct ServicePIFMessageHandlers: ServiceExtension {
1541-
package init() {}
1540+
public struct ServicePIFMessageHandlers: ServiceExtension {
1541+
public init() {}
15421542

1543-
package func register(_ service: Service) {
1543+
public func register(_ service: Service) {
15441544
service.registerMessageHandler(SetSessionPIFMsg.self)
15451545
service.registerMessageHandler(TransferSessionPIFMsg.self)
15461546
service.registerMessageHandler(TransferSessionPIFObjectsMsg.self)
@@ -1559,10 +1559,10 @@ package struct WorkspaceModelMessageHandlers: ServiceExtension {
15591559
}
15601560
}
15611561

1562-
package struct ActiveBuildBasicMessageHandlers: ServiceExtension {
1563-
package init() {}
1562+
public struct ActiveBuildBasicMessageHandlers: ServiceExtension {
1563+
public init() {}
15641564

1565-
package func register(_ service: Service) {
1565+
public func register(_ service: Service) {
15661566
service.registerMessageHandler(CreateBuildRequestMsg.self)
15671567
service.registerMessageHandler(BuildStartRequestMsg.self)
15681568
service.registerMessageHandler(BuildCancelRequestMsg.self)

Sources/SWBBuildService/Session.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import SWBBuildSystem
14-
package import SWBCore
15-
package import SWBProtocol
16-
package import SWBServiceCore
14+
public import SWBCore
15+
public import SWBProtocol
16+
public import SWBServiceCore
1717
package import SWBTaskExecution
1818
import SWBUtil
1919
import struct Foundation.UUID
@@ -26,7 +26,7 @@ enum SessionError: Error {
2626
/// This class manages a unique session corresponding to a unique remote client session.
2727
///
2828
/// A session object manages a single workspace, but the client might elect to create multiple sessions for the same workspace.
29-
package final class Session {
29+
public final class Session {
3030
/// A PIF transfer operation.
3131
final class PIFTransferOperation {
3232
enum Status {
@@ -149,7 +149,7 @@ package final class Session {
149149
let UID: String
150150

151151
/// The active workspace session
152-
package internal(set) var workspaceContext: WorkspaceContext?
152+
public internal(set) var workspaceContext: WorkspaceContext?
153153

154154
/// The incremental PIF loader.
155155
private let incrementalPIFLoader: IncrementalPIFLoader
@@ -345,7 +345,7 @@ package final class Session {
345345
}
346346

347347
/// Registers a build operation with the session
348-
package func registerActiveBuild(_ build: any ActiveBuildOperation) throws {
348+
public func registerActiveBuild(_ build: any ActiveBuildOperation) throws {
349349
// We currently don't support running multiple build operations in one session, this is just a defensive precondition.
350350
// But we do allow build description creation operations to run concurrently with normal builds. These are important for index queries to function properly even during a build.
351351
// We also allow 'prepare-for-index' build operations to run concurrently with a normal build but only one at a time. These are important for functionality in the Xcode editor to work properly, that the user directly interacts with.
@@ -372,7 +372,7 @@ package final class Session {
372372
}
373373

374374
/// Unregister a build operation from the session
375-
package func unregisterActiveBuild(_ build: any ActiveBuildOperation) {
375+
public func unregisterActiveBuild(_ build: any ActiveBuildOperation) {
376376
guard activeBuilds.removeValue(forKey: build.id) != nil else {
377377
fatalError("tried to unregister nonexistent build: '\(build)'")
378378
}
@@ -391,7 +391,7 @@ protocol ClientExchange {
391391

392392
extension Request {
393393
/// Retrieve the session for the message, or throw if invalid.
394-
package func session<T: SessionMessage>(for message: T) throws -> Session {
394+
public func session<T: SessionMessage>(for message: T) throws -> Session {
395395
guard let session = buildService.sessionMap[message.sessionHandle] else {
396396
throw MsgParserError.unknownSession(handle: message.sessionHandle)
397397
}

0 commit comments

Comments
 (0)