Skip to content

Make .index-build a subdirectory of .build #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2024
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
4 changes: 1 addition & 3 deletions .devcontainer/default/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

"mounts": [
// Use a named volume for the build products for optimal performance (https://code.visualstudio.com/remote/advancedcontainers/improve-performance#_use-a-targeted-named-volume)
"source=${localWorkspaceFolderBasename}-build,target=${containerWorkspaceFolder}/.build,type=volume",
// Do the same for experimental background indexing
"source=${localWorkspaceFolderBasename}-index-build,target=${containerWorkspaceFolder}/.index-build,type=volume"
"source=${localWorkspaceFolderBasename}-build,target=${containerWorkspaceFolder}/.build,type=volume"
],
"customizations": {
"vscode": {
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Enable Experimental Background Indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ By default SourceKit-LSP does not update its global index in the background or b

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:
- A diagnostic bundle generated by running `path/to/sourcekit-lsp diagnose`.
- Your project including the `.index-build` folder, if possible.
- Your project including the `.build` folder, if possible.
4 changes: 2 additions & 2 deletions Sources/BuildSystemIntegration/SwiftPMBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {

package let connectionToSourceKitLSP: any Connection

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

Expand Down Expand Up @@ -320,7 +320,7 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
fileSystem: localFileSystem
)
if options.backgroundIndexingOrDefault {
location.scratchDirectory = AbsolutePath(projectRoot.appending(component: ".index-build"))
location.scratchDirectory = AbsolutePath(projectRoot.appending(components: ".build", "index-build"))
} else if let scratchDirectory = options.swiftPMOrDefault.scratchPath,
let scratchDirectoryPath = try? AbsolutePath(validating: scratchDirectory)
{
Expand Down
5 changes: 3 additions & 2 deletions Tests/SourceKitLSPTests/BackgroundIndexingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,8 @@ final class BackgroundIndexingTests: XCTestCase {
let nestedIndexBuildURL = try XCTUnwrap(
project.uri(for: "OtherLib.swift").fileURL?
.deletingLastPathComponent()
.appendingPathComponent(".index-build")
.appendingPathComponent(".build")
.appendingPathComponent("index-build")
)
XCTAssertFalse(
FileManager.default.fileExists(at: nestedIndexBuildURL),
Expand Down Expand Up @@ -1258,7 +1259,7 @@ final class BackgroundIndexingTests: XCTestCase {
// Simulate a package update which goes as follows:
// - The user runs `swift package update`
// - This updates `Package.resolved`, which we watch
// - We reload the package, which updates `Dependency.swift` in `.index-build/checkouts`, which we also watch.
// - We reload the package, which updates `Dependency.swift` in `.build/index-build/checkouts`, which we also watch.
try await Process.run(
arguments: [
unwrap(ToolchainRegistry.forTesting.default?.swift?.pathString),
Expand Down