Skip to content

Commit 4278f97

Browse files
authored
Merge pull request #91 from benlangmuir/head-deps
Remove Package.resolved and move to depending on HEAD
2 parents dbd474e + b6e9182 commit 4278f97

File tree

5 files changed

+40
-43
lines changed

5 files changed

+40
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
default.profraw
3+
Package.resolved
34
/.build
45
/Packages
56
/*.xcodeproj

Package.resolved

Lines changed: 0 additions & 34 deletions
This file was deleted.

Package.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ let package = Package(
77
products: [
88
],
99
dependencies: [
10-
.package(url: "https://github.com/apple/swift-package-manager.git", .branch("master")),
11-
.package(url: "https://github.com/apple/indexstore-db.git", .branch("master")),
10+
// See 'Dependencies' below.
1211
],
1312
targets: [
1413
.target(
@@ -82,3 +81,28 @@ let package = Package(
8281
dependencies: ["SKSupport", "SKTestSupport"]),
8382
]
8483
)
84+
85+
// MARK: Dependencies
86+
87+
// When building with the swift build-script, use local dependencies whose contents are controlled
88+
// by the external environment. This allows sourcekit-lsp to take advantage of the automation used
89+
// for building the swift toolchain, such as `update-checkout`, or cross-repo PR tests.
90+
91+
#if os(Linux)
92+
import Glibc
93+
#else
94+
import Darwin.C
95+
#endif
96+
97+
if getenv("SWIFTCI_USE_LOCAL_DEPS") == nil {
98+
// Building standalone.
99+
package.dependencies += [
100+
.package(url: "https://github.com/apple/indexstore-db.git", .branch("master")),
101+
.package(url: "https://github.com/apple/swift-package-manager.git", .branch("master")),
102+
]
103+
} else {
104+
package.dependencies += [
105+
.package(path: "../indexstore-db"),
106+
.package(path: "../swiftpm"),
107+
]
108+
}

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SourceKit-LSP is an implementation of the [Language Server Protocol](https://mic
77

88
SourceKit-LSP is under heavy development! The best way to try it out is to build it from source. You will also need a Swift development toolchain and an editor that supports LSP.
99

10-
1. Install the `swift-DEVELOPMENT-SNAPSHOT-2019-02-14-a` toolchain snapshot from https://swift.org/download/#snapshots. Set the environment variable `SOURCEKIT_TOOLCHAIN_PATH` to the absolute path to the toolchain or otherwise configure your editor to use this toolchain. See [Toolchains](#toolchains) for more information.
10+
1. Install the latest master toolchain snapshot from https://swift.org/download/#snapshots. Set the environment variable `SOURCEKIT_TOOLCHAIN_PATH` to the absolute path to the toolchain or otherwise configure your editor to use this toolchain. See [Toolchains](#toolchains) for more information.
1111

1212
2. Build the language server executable `sourcekit-lsp` using `swift build`. See [Building](#building-sourcekit-lsp) for more information.
1313

@@ -23,11 +23,14 @@ SourceKit-LSP is built using the [Swift Package Manager](https://github.com/appl
2323
For a standard debug build:
2424

2525
```sh
26+
$ swift package update
2627
$ swift build
2728
```
2829

2930
After building, the server will be located at `.build/debug/sourcekit-lsp`, or a similar path, if you passed any custom options to `swift build`. Editors will generally need to be provided with this path in order to run the newly built server - see [Editors](Editors) for more information about configuration.
3031

32+
SourceKit-LSP is designed to build against the latest SwiftPM, so if you run into any issue make sure you have the most up-to-date dependencies by running `swift package update`.
33+
3134
### Building on Linux
3235

3336
The C++ code in the index requires `libdispatch`, but unlike Swift code, it cannot find it automatically on Linux. You can work around this by adding a search path manually.
@@ -73,7 +76,7 @@ SourceKit-LSP depends on tools such as `sourcekitd` and `clangd`, which it loads
7376

7477
### Recommended Toolchain
7578

76-
Use the `swift-DEVELOPMENT-SNAPSHOT-2019-02-14-a` toolchain snapshot from https://swift.org/download/#snapshots. SourceKit-LSP is still early in its development and we are actively adding functionality to the toolchain to support it.
79+
Use the latest master toolchain snapshot from https://swift.org/download/#snapshots. SourceKit-LSP is still early in its development and we are actively adding functionality to the toolchain to support it.
7780

7881
### Selecting the Toolchain
7982

Utilities/build-script-helper.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,18 @@ def add_common_args(parser):
6666

6767
swiftpm_args = get_swiftpm_options(args)
6868

69+
env = os.environ
70+
# Set the toolchain used in tests at runtime
71+
env['SOURCEKIT_TOOLCHAIN_PATH'] = args.toolchain
72+
# Use local dependencies (i.e. checked out next sourcekit-lsp).
73+
env['SWIFTCI_USE_LOCAL_DEPS'] = "1"
74+
6975
if args.action == 'build':
70-
swiftpm('build', swift_exec, swiftpm_args)
76+
swiftpm('build', swift_exec, swiftpm_args, env)
7177
elif args.action == 'test':
72-
# Set the toolchain used in tests at runtime
73-
env = os.environ
74-
env['SOURCEKIT_TOOLCHAIN_PATH'] = args.toolchain
7578
swiftpm('test', swift_exec, swiftpm_args, env)
7679
else:
7780
assert False, 'unknown action \'{}\''.format(args.action)
7881

7982
if __name__ == '__main__':
80-
main()
83+
main()

0 commit comments

Comments
 (0)