Skip to content

Commit ec0a7c4

Browse files
committed
Make .index-build a subdirectory of .build
This means that users of SourceKit-LSP’s background indexing don’t need to add another directory to their `.gitignore`.
1 parent d913222 commit ec0a7c4

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

.devcontainer/default/devcontainer.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
"mounts": [
1111
// Use a named volume for the build products for optimal performance (https://code.visualstudio.com/remote/advancedcontainers/improve-performance#_use-a-targeted-named-volume)
12-
"source=${localWorkspaceFolderBasename}-build,target=${containerWorkspaceFolder}/.build,type=volume",
13-
// Do the same for experimental background indexing
14-
"source=${localWorkspaceFolderBasename}-index-build,target=${containerWorkspaceFolder}/.index-build,type=volume"
12+
"source=${localWorkspaceFolderBasename}-build,target=${containerWorkspaceFolder}/.build,type=volume"
1513
],
1614
"customizations": {
1715
"vscode": {

Documentation/Enable Experimental Background Indexing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ By default SourceKit-LSP does not update its global index in the background or b
3434

3535
If you hit any issues that are not mentioned above, please [file a GitHub issue](https://github.com/swiftlang/sourcekit-lsp/issues/new/choose) and attach the following information, if possible:
3636
- A diagnostic bundle generated by running `path/to/sourcekit-lsp diagnose`.
37-
- Your project including the `.index-build` folder, if possible.
37+
- Your project including the `.build` folder, if possible.

Sources/BuildSystemIntegration/SwiftPMBuildSystem.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
205205

206206
package let connectionToSourceKitLSP: any Connection
207207

208-
/// Whether the `SwiftPMBuildSystem` is pointed at a `.index-build` directory that's independent of the
208+
/// Whether the `SwiftPMBuildSystem` is pointed at a `.build/index-build` directory that's independent of the
209209
/// user's build.
210210
private var isForIndexBuild: Bool { options.backgroundIndexingOrDefault }
211211

@@ -320,7 +320,7 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
320320
fileSystem: localFileSystem
321321
)
322322
if options.backgroundIndexingOrDefault {
323-
location.scratchDirectory = AbsolutePath(projectRoot.appending(component: ".index-build"))
323+
location.scratchDirectory = AbsolutePath(projectRoot.appending(components: ".build", "index-build"))
324324
} else if let scratchDirectory = options.swiftPMOrDefault.scratchPath,
325325
let scratchDirectoryPath = try? AbsolutePath(validating: scratchDirectory)
326326
{

Tests/SourceKitLSPTests/BackgroundIndexingTests.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,8 @@ final class BackgroundIndexingTests: XCTestCase {
889889
let nestedIndexBuildURL = try XCTUnwrap(
890890
project.uri(for: "OtherLib.swift").fileURL?
891891
.deletingLastPathComponent()
892-
.appendingPathComponent(".index-build")
892+
.appendingPathComponent(".build")
893+
.appendingPathComponent("index-build")
893894
)
894895
XCTAssertFalse(
895896
FileManager.default.fileExists(at: nestedIndexBuildURL),
@@ -1258,7 +1259,7 @@ final class BackgroundIndexingTests: XCTestCase {
12581259
// Simulate a package update which goes as follows:
12591260
// - The user runs `swift package update`
12601261
// - This updates `Package.resolved`, which we watch
1261-
// - We reload the package, which updates `Dependency.swift` in `.index-build/checkouts`, which we also watch.
1262+
// - We reload the package, which updates `Dependency.swift` in `.build/index-build/checkouts`, which we also watch.
12621263
try await Process.run(
12631264
arguments: [
12641265
unwrap(ToolchainRegistry.forTesting.default?.swift?.pathString),

0 commit comments

Comments
 (0)