mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This reverts commit beb8ecd8cc. Add a
workaround for the dependency issue.
It is unclear why `sourcekitd` is getting added improperly as a
dependency on `lib/sourcekitd.framework/sourcekitd`. This workaround
adjusts the dependency such that we end up with a dependency on
`lib/sourcekitd.framework/Versions/A/sourcekitd` as an order-only
dependency. This should fix the compile issue. I am unable to
reproduce this issue with the `add_library` usage for adding a Swift
library. This allows us to cleave the host and target libraries, and so
the workaround is sufficient to make progress and the problem will be
resolved with the migration towards CMake for handling the dependencies.
44 lines
1.6 KiB
Swift
44 lines
1.6 KiB
Swift
//===--------------------- SourceKitdClient.swift -------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// This file provides a wrapper of SourceKitd service.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import sourcekitd
|
|
|
|
public class SourceKitdService {
|
|
|
|
public init() {
|
|
sourcekitd_initialize()
|
|
}
|
|
deinit {
|
|
sourcekitd_shutdown()
|
|
}
|
|
|
|
/// Send a request synchronously with a handler for its response.
|
|
/// - Parameter request: The request to send.
|
|
/// - Returns: The response from the sourcekitd service.
|
|
public func sendSyn(request: SourceKitdRequest) -> SourceKitdResponse {
|
|
return SourceKitdResponse(resp: sourcekitd_send_request_sync(request.rawRequest))
|
|
}
|
|
|
|
/// Send a request asynchronously with a handler for its response.
|
|
/// - Parameter request: The request to send.
|
|
/// - Parameter handler: The handler for the response in the future.
|
|
public func send(request: SourceKitdRequest,
|
|
handler: @escaping (SourceKitdResponse) -> ()) {
|
|
sourcekitd_send_request(request.rawRequest, nil) { response in
|
|
guard let response = response else { return }
|
|
handler(SourceKitdResponse(resp: response))
|
|
}
|
|
}
|
|
}
|