diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e1b564a..793fd83 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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" diff --git a/BUILD.bazel b/BUILD.bazel index b41c3b1..5e7b418 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", diff --git a/Package.swift b/Package.swift index ff37b4e..4d319c7 100644 --- a/Package.swift +++ b/Package.swift @@ -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 @@ -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", diff --git a/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BuildTargetsHandler.swift b/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BuildTargetsHandler.swift index b37e2dd..23cfbf8 100644 --- a/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BuildTargetsHandler.swift +++ b/Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BuildTargetsHandler.swift @@ -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() diff --git a/Sources/SourceKitBazelBSP/RequestHandlers/InitializeHandler.swift b/Sources/SourceKitBazelBSP/RequestHandlers/InitializeHandler.swift index a9d8a87..b3b3e29 100644 --- a/Sources/SourceKitBazelBSP/RequestHandlers/InitializeHandler.swift +++ b/Sources/SourceKitBazelBSP/RequestHandlers/InitializeHandler.swift @@ -172,6 +172,7 @@ final class InitializeHandler { } else { watchers = nil } + let batchSize: Int? = initializedConfig.baseConfig.indexBuildBatchSize return InitializeBuildResponse( displayName: "sourcekit-bazel-bsp", version: sourcekitBazelBSPVersion, @@ -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, diff --git a/Sources/SourceKitBazelBSP/RequestHandlers/PrepareHandler.swift b/Sources/SourceKitBazelBSP/RequestHandlers/PrepareHandler.swift index 17f080c..e233fb8 100644 --- a/Sources/SourceKitBazelBSP/RequestHandlers/PrepareHandler.swift +++ b/Sources/SourceKitBazelBSP/RequestHandlers/PrepareHandler.swift @@ -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, diff --git a/Sources/SourceKitBazelBSP/Server/BaseServerConfig.swift b/Sources/SourceKitBazelBSP/Server/BaseServerConfig.swift index 6c8d056..570a63d 100644 --- a/Sources/SourceKitBazelBSP/Server/BaseServerConfig.swift +++ b/Sources/SourceKitBazelBSP/Server/BaseServerConfig.swift @@ -32,6 +32,7 @@ package struct BaseServerConfig: Equatable { let buildTestPlatformPlaceholder: String let filesToWatch: String? let useSeparateOutputBaseForAquery: Bool + let indexBuildBatchSize: Int? package init( bazelWrapper: String, @@ -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 @@ -49,5 +51,6 @@ package struct BaseServerConfig: Equatable { self.buildTestPlatformPlaceholder = buildTestPlatformPlaceholder self.filesToWatch = filesToWatch self.useSeparateOutputBaseForAquery = useSeparateOutputBaseForAquery + self.indexBuildBatchSize = indexBuildBatchSize } } diff --git a/Sources/sourcekit-bazel-bsp/Commands/Serve.swift b/Sources/sourcekit-bazel-bsp/Commands/Serve.swift index 1ee58f3..c633e33 100644 --- a/Sources/sourcekit-bazel-bsp/Commands/Serve.swift +++ b/Sources/sourcekit-bazel-bsp/Commands/Serve.swift @@ -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...") @@ -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() diff --git a/rules/setup_sourcekit_bsp.bzl b/rules/setup_sourcekit_bsp.bzl index e1fa248..91c8284 100644 --- a/rules/setup_sourcekit_bsp.bzl +++ b/rules/setup_sourcekit_bsp.bzl @@ -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) @@ -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, + ) }, )