Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Build and test
runs-on: macos-15
env:
XCODE_VERSION: ${{ '16.4' }}
XCODE_VERSION: ${{ '26.0' }}
steps:
- name: Select Xcode
run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app"
Expand Down
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ setup_sourcekit_bsp(
bazel_wrapper = "bazel",
files_to_watch = ["Sources/**/*.swift"],
index_flags = [],
index_build_batch_size = 7,
targets = [
"//Sources/sourcekit-bazel-bsp",
"//Sources/SourceKitBazelBSP",
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 6.1
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -14,8 +14,8 @@ let package = Package(
revision: "1.5.0"
),
.package(
url: "https://github.com/apple/sourcekit-lsp",
revision: "1aae2a4c329035163db85d64ae7bc81ee80aaa3c"
url: "https://github.com/rockbruno/sourcekit-lsp",
revision: "c052baae81ec6532bb2f939a21acc4650fb1dc86"
),
.package(
url: "https://github.com/apple/swift-protobuf.git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class BuildTargetsHandler {
_ id: RequestID
) throws -> WorkspaceBuildTargetsResponse {
let taskId = TaskId(id: "buildTargets-\(id.description)")
connection?.startWorkTask(id: taskId, title: "sourcekit-bazel-bsp: Processing updates to the build graph...")
connection?.startWorkTask(id: taskId, title: "sourcekit-bazel-bsp: Processing the build graph...")
do {
let result = try targetStore.stateLock.withLockUnchecked {
return try targetStore.fetchTargets()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ final class InitializeHandler {
} else {
watchers = nil
}
let batchSize: Int? = initializedConfig.baseConfig.indexBuildBatchSize
return InitializeBuildResponse(
displayName: "sourcekit-bazel-bsp",
version: sourcekitBazelBSPVersion,
Expand All @@ -192,6 +193,10 @@ final class InitializeHandler {
data: SourceKitInitializeBuildResponseData(
indexDatabasePath: initializedConfig.indexDatabasePath,
indexStorePath: initializedConfig.indexStorePath,
multiTargetPreparation: MultiTargetPreparationSupport(
supported: true,
batchSize: batchSize
),
outputPathsProvider: nil, // FIXME: Not sure if we need this or not
prepareProvider: true,
sourceKitOptionsProvider: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,9 @@ final class PrepareHandler {

let taskId = TaskId(id: "buildPrepare-\(id.description)")
let taskTitle: String = {
guard targetsToBuild.count == 1 else {
return "sourcekit-bazel-bsp: Building \(targetsToBuild.count) targets..."
}
let targetUrl = targetsToBuild[0].uri.fileURL
let targetName = targetUrl?.lastPathComponent ?? targetsToBuild[0].uri.stringValue
return "sourcekit-bazel-bsp: Building \(targetName)..."
let targetUrls = targetsToBuild.compactMap { $0.uri.fileURL }
let targetNames = targetUrls.map { $0.lastPathComponent }.joined(separator: ", ")
return "sourcekit-bazel-bsp: Building \(targetNames)..."
}()
connection?.startWorkTask(
id: taskId,
Expand Down
5 changes: 4 additions & 1 deletion Sources/SourceKitBazelBSP/Server/BaseServerConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ package struct BaseServerConfig: Equatable {
let buildTestPlatformPlaceholder: String
let filesToWatch: String?
let useSeparateOutputBaseForAquery: Bool
let indexBuildBatchSize: Int?

package init(
bazelWrapper: String,
Expand All @@ -40,7 +41,8 @@ package struct BaseServerConfig: Equatable {
buildTestSuffix: String,
buildTestPlatformPlaceholder: String,
filesToWatch: String?,
useSeparateOutputBaseForAquery: Bool = false
useSeparateOutputBaseForAquery: Bool = false,
indexBuildBatchSize: Int? = nil
) {
self.bazelWrapper = bazelWrapper
self.targets = targets
Expand All @@ -49,5 +51,6 @@ package struct BaseServerConfig: Equatable {
self.buildTestPlatformPlaceholder = buildTestPlatformPlaceholder
self.filesToWatch = filesToWatch
self.useSeparateOutputBaseForAquery = useSeparateOutputBaseForAquery
self.indexBuildBatchSize = indexBuildBatchSize
}
}
9 changes: 8 additions & 1 deletion Sources/sourcekit-bazel-bsp/Commands/Serve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ struct Serve: ParsableCommand {
)
var topLevelRuleToDiscover: [TopLevelRuleType] = []

@Option(
help:
"The number of targets to prepare in parallel. If not specified, SourceKit-LSP will calculate an appropriate value based on the environment. Requires using the pre-built SourceKit-LSP binary from the release archive.",
)
var indexBuildBatchSize: Int? = nil

func run() throws {
logger.info("`serve` invoked, initializing BSP server...")

Expand Down Expand Up @@ -111,7 +117,8 @@ struct Serve: ParsableCommand {
buildTestSuffix: buildTestSuffix,
buildTestPlatformPlaceholder: buildTestPlatformPlaceholder,
filesToWatch: filesToWatch,
useSeparateOutputBaseForAquery: separateAqueryOutput
useSeparateOutputBaseForAquery: separateAqueryOutput,
indexBuildBatchSize: indexBuildBatchSize
)
let server = SourceKitBazelBSPServer(baseConfig: config)
server.run()
Expand Down
7 changes: 7 additions & 0 deletions rules/setup_sourcekit_bsp.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def _setup_sourcekit_bsp_impl(ctx):
bsp_config_argv.append(ctx.attr.build_test_platform_placeholder)
if ctx.attr.separate_aquery_output:
bsp_config_argv.append("--separate-aquery-output")
if ctx.attr.index_build_batch_size:
bsp_config_argv.append("--index-build-batch-size")
bsp_config_argv.append(ctx.attr.index_build_batch_size)
for index_flag in ctx.attr.index_flags:
bsp_config_argv.append("--index-flag")
bsp_config_argv.append(index_flag)
Expand Down Expand Up @@ -107,5 +110,9 @@ setup_sourcekit_bsp = rule(
doc = "Whether to use a separate output base for compiler arguments requests. This greatly increases the performance of the server at the cost of more disk usage.",
default = False,
),
"index_build_batch_size": attr.int(
doc = "The number of targets to prepare in parallel. If not specified, SourceKit-LSP will calculate an appropriate value based on the environment. Requires using the pre-built SourceKit-LSP binary from the release archive.",
mandatory = False,
)
},
)