Skip to content

Commit

Permalink
Merge pull request swiftlang#1803 from ahoppen/indexbuild-subfolder
Browse files Browse the repository at this point in the history
Make `.index-build` a subdirectory of `.build`
  • Loading branch information
ahoppen authored Nov 14, 2024
2 parents 6237c30 + ec0a7c4 commit c23b4ff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
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 @@ -207,7 +207,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 @@ -322,7 +322,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 @@ -868,7 +868,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 @@ -1237,7 +1238,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

0 comments on commit c23b4ff

Please sign in to comment.