Skip to content

Make some SWBBuildService APIs public #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/SWBBuildService/BuildOperationMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import struct Foundation.Date

package import SWBBuildSystem
package import SWBCore
public import SWBCore
import SWBLibc
import SWBProtocol
import SWBServiceCore
Expand All @@ -25,7 +25,7 @@ import SWBMacro
// FIXME: Workaround: <rdar://problem/26249252> Unable to prefer my own type over NS renamed types
import class SWBTaskExecution.Task

package protocol ActiveBuildOperation {
public protocol ActiveBuildOperation {
/// A unique identifier for this build.
var id: Int { get }

Expand Down
8 changes: 4 additions & 4 deletions Sources/SWBBuildService/BuildService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Foundation
import SWBBuildSystem
import SWBCore
import SWBLibc
package import SWBProtocol
package import SWBServiceCore
public import SWBProtocol
public import SWBServiceCore
import SWBUtil

typealias Cache = SWBUtil.Cache
Expand Down Expand Up @@ -46,7 +46,7 @@ private struct CoreCacheKey: Equatable, Hashable {
/// This is the central class which manages a service instance communicating with a unique client.
///
/// 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.
package class BuildService: Service, @unchecked Sendable {
open class BuildService: Service, @unchecked Sendable {
/// The map of registered sessions.
var sessionMap = Dictionary<String, Session>()

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

package func nextBuildOperationID() -> Int {
public func nextBuildOperationID() -> Int {
return lastBuildOperationID.withLock { value in
let lastID = value
value += 1
Expand Down
20 changes: 10 additions & 10 deletions Sources/SWBBuildService/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import SWBBuildSystem
package import SWBCore
import SWBProtocol
package import SWBServiceCore
public import SWBServiceCore
import SWBTaskConstruction
import SWBTaskExecution
package import SWBUtil
Expand Down Expand Up @@ -1557,10 +1557,10 @@ private struct ClearAllCaches: MessageHandler {

// MARK: ServiceExtension Support

package struct ServiceSessionMessageHandlers: ServiceExtension {
package init() {}
public struct ServiceSessionMessageHandlers: ServiceExtension {
public init() {}

package func register(_ service: Service) {
public func register(_ service: Service) {
service.registerMessageHandler(CreateSessionHandler.self)
service.registerMessageHandler(ListSessionsHandler.self)
service.registerMessageHandler(WaitForQuiescenceHandler.self)
Expand All @@ -1573,10 +1573,10 @@ package struct ServiceSessionMessageHandlers: ServiceExtension {
}
}

package struct ServicePIFMessageHandlers: ServiceExtension {
package init() {}
public struct ServicePIFMessageHandlers: ServiceExtension {
public init() {}

package func register(_ service: Service) {
public func register(_ service: Service) {
service.registerMessageHandler(SetSessionPIFMsg.self)
service.registerMessageHandler(TransferSessionPIFMsg.self)
service.registerMessageHandler(TransferSessionPIFObjectsMsg.self)
Expand All @@ -1595,10 +1595,10 @@ package struct WorkspaceModelMessageHandlers: ServiceExtension {
}
}

package struct ActiveBuildBasicMessageHandlers: ServiceExtension {
package init() {}
public struct ActiveBuildBasicMessageHandlers: ServiceExtension {
public init() {}

package func register(_ service: Service) {
public func register(_ service: Service) {
service.registerMessageHandler(CreateBuildRequestMsg.self)
service.registerMessageHandler(BuildStartRequestMsg.self)
service.registerMessageHandler(BuildCancelRequestMsg.self)
Expand Down
16 changes: 8 additions & 8 deletions Sources/SWBBuildService/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
//===----------------------------------------------------------------------===//

import SWBBuildSystem
package import SWBCore
package import SWBProtocol
package import SWBServiceCore
public import SWBCore
public import SWBProtocol
public import SWBServiceCore
package import SWBTaskExecution
import SWBUtil
import struct Foundation.UUID
Expand All @@ -26,7 +26,7 @@ enum SessionError: Error {
/// This class manages a unique session corresponding to a unique remote client session.
///
/// A session object manages a single workspace, but the client might elect to create multiple sessions for the same workspace.
package final class Session {
public final class Session {
/// A PIF transfer operation.
final class PIFTransferOperation {
enum Status {
Expand Down Expand Up @@ -149,7 +149,7 @@ package final class Session {
let UID: String

/// The active workspace session
package internal(set) var workspaceContext: WorkspaceContext?
public internal(set) var workspaceContext: WorkspaceContext?

/// The incremental PIF loader.
private let incrementalPIFLoader: IncrementalPIFLoader
Expand Down Expand Up @@ -343,7 +343,7 @@ package final class Session {
}

/// Registers a build operation with the session
package func registerActiveBuild(_ build: any ActiveBuildOperation) throws {
public func registerActiveBuild(_ build: any ActiveBuildOperation) throws {
// We currently don't support running multiple build operations in one session, this is just a defensive precondition.
// 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.
// 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.
Expand All @@ -370,7 +370,7 @@ package final class Session {
}

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

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