Bazel implemention for build server protocol and mainly working with sourcekit-lsp.
- Xcode 16.3
- Swift toolchain 6.1.0
- Enable global_index_store in .bazelrc
- Creating a buildServer.json at the root of your project shown below.
- The
argv
need to point at the buildserver executable - The
target
will be used byaquery
to get all the compiler arguments and targets. - The
sdk
is what will be replaced for__BAZEL_XCODE_SDKROOT__
- The
indexStorePath
is the location where all indexstore files are. - The
indexDatabasePath
is the location for index.db output
- The
{
"name": "example-app",
"argv": [
"/Users/sean7218/bazel/buildserver/target/debug/buildserver"
],
"version": "1.0.0",
"bspVersion": "2.0.0",
"languages": ["swift"],
"target": "//App:App",
"sdk": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.4.sdk",
"indexStorePath": "/Users/sean7218/bazel/buildserver/example-app/bazel-out/_global_index_store",
"indexDatabasePath": "/Users/sean7218/bazel/buildserver/example-app/.index-db",
"bazelOut": null,
"aqueryArgs": []
}
- Compile the build server by running
cargo build
, and the executable will be inbazel-build-server/target/debug/buildserver
, and change theargv
in the buildServer.json file as well.
cargo build
- Before compile your project with bazel, you need to set the global index in
.bazelrc
file, then compile your project based on the target specified in thebuildServer.json
such asbazel build //App:App
# either this
build --features swift.use_global_index_store
build --features swift.index_while_building
# or
build --features swift.use_global_index_store
build --swiftcopt=-index-store-path
build --swiftcopt=$(OUTPUT_BASE)/indexstore
-
Open your project in vscode or neovim, you should be see logs both in sourcekit-lsp and bsp.log
-
Once the server is started Logging is stored in
~/.sourcekit-bsp/bsp.log
, it is recommended to open it and see any issues.
todo!