Commit Graph

79 Commits

Author SHA1 Message Date
Evan Wilde
4fcb707eb3 build-script: find sqlite header
User-installed package headers are installed to `/usr/local/include` on
FreeBSD. The build system should tell the compiler where the additional
headers are located.
2025-05-30 15:32:31 -07:00
Finagolfin
01834589e0 [build-script-helper] Remove unneeded flags for Android
Removing the definition of `_GNU_SOURCE` is no longer needed since
swiftlang/swift-tools-support-core#500 made sure the right `strerror_r()` is used.
2025-04-02 02:53:20 +05:30
Alex Hoppen
c393525a19 Introduce a timeout to test execution
We have seen a few infinite spins in SourceKit-LSP testing recently. We should fix those spins but as a last stop-gap measure, introduce a timeout to all subprocess invocations, which will at least give us a failure instead of infinite waiting.
2025-03-19 10:50:50 -07:00
Alex Hoppen
cf828a8135 Consistently add license headers to all files
To prepare for the GitHub Action license header check.
2025-03-06 22:01:00 -08:00
Alex Hoppen
58f7766aa1 Install SourceKit plugin to lib instead of bin 2025-01-13 10:07:58 -08:00
Alex Hoppen
150423b490 Fix test failures 2025-01-09 14:09:01 +01:00
Alex Hoppen
5709e1a864 Add a SourceKit plugin to handle code completion requests
This adds a sourcekitd plugin that drives the code completion requests. It also includes a `CompletionScoring` module that’s used to rank code completion results based on their contextual match, allowing us to show more relevant code completion results at the top.
2025-01-03 14:21:54 +01:00
Alex Hoppen
213b62f27a Merge pull request #1717 from ahoppen/ahoppen/cross-compile-lsp
Build sourcekit-lsp for multiple arches and lipo them
2024-10-11 15:14:08 -07:00
Alex Hoppen
d232ba7a93 Build sourcekit-lsp for multiple arches and lipo them
Instead of building SourceKit-LSP using SwiftPM's multi-arch xcbuild backend, build it for only one arch at a time and then run `lipo` to merge the two resulting binaries.

This should allow us to share build products between building installing and testing and also eliminates other quirks resulting from the xcbuild backend.
2024-09-26 14:12:44 -07:00
Alex Hoppen
8d6ff3df9a Consistently use SOURCEKIT_LSP_ as prefix of environment variables instead of SOURCEKIT_LSP 2024-09-25 14:05:46 -07:00
Finagolfin
636bc1fb48 [build-script-helper] Switch the --no-clean flag to --clean and have it actually do something
Instead, swiftlang/swift#75053 makes sure `build-script` doesn't pass in the flag by
default, so you can explicitly invoke it only when needed.
2024-07-19 21:38:02 +05:30
Alex Hoppen
259d49e12c Share module cache between test projects
This improves serial test execution time of eg. `DocumentTestDiscoveryTests` from 36s to 22s because we don’t need to re-build the XCTest module from its interface when using an open source toolchain.

This also uncovered that we weren‘t passing the build setup flags to the prepare command.

rdar://126493151
2024-06-03 09:29:16 -07:00
Alex Hoppen
e2f6f5d991 Flush stdout after issuing message that we re-run tests in serial
For some reason the log message that we’re re-running tests in serial always showed up after the serial run in the build log output. Test if flushing stdout fixes the issue.
2024-05-30 23:45:41 -07:00
Rintaro Ishizaki
555df60730 [build-script-helper] Prefer just-built plugins to SDK plugins
Add '-Xswiftc -plugin-path -Xswiftc ${toolchain}/lib/swift/host/plugins'
to swiftpm invocations.
2024-05-03 17:08:49 -07:00
Alex Hoppen
adb8d22b7e Don’t print log test log output when running tests in parallel
`swift test --parallel --verbose` prints the entire log output. We were assuming that it did not and re-run `sourcekit-lsp` tests in serial with log output if the parallel test run failed.

Suppress `--verbose` on `swift test`. This will cause it to not log any stderr logging output when running in parallel and log all stderr logging output when running in serial.
2024-03-15 11:51:19 -07:00
Alex Hoppen
b5fd79fbb9 Generate sourcekitd UIDs instead of manually maintaining the list
rdar://121953119
2024-02-14 16:33:34 -08:00
Alex Hoppen
19859ae2c3 Log at the debug level in CI 2024-02-02 15:34:47 -08:00
Alex Hoppen
423c03ebbf Clean up rpaths of installed sourcekit-lsp
- Don’t explicitly add rpaths to `/usr/lib/swift`, `@executable_path/../lib/swift/macosx` and `@executable_path/../lib/swift-5.5/macosx` on Darwin. I don’t know what they were needed for but they don’t seem to be necessary. Also standard Swift command line tools created from Xcode don’t contain these rpaths.

rdar://121400644
2024-01-24 18:24:56 -08:00
Alex Hoppen
313e46eb28 Execute sourcekit-lsp tests in parallel and re-run them serially only if a test fails
This speeds up testing time for successful runs and minimizes log output if all tests succeed while still producing actionable output on failure.
2023-12-08 09:44:26 -08:00
Alex Hoppen
cc209f60a4 Reduce log level in CI to info
This reduced the CI log generated by sourcekit-lsp tests from 76MB to 2.7MB
2023-11-10 10:53:42 -08:00
Alex Hoppen
2476f0289d Merge pull request #894 from finagolfin/origin
Use new SwiftPM flag to remove `$ORIGIN` from installed sourcekit-lsp ELF executable runpath
2023-10-19 17:09:01 -07:00
Alex Hoppen
86751b8b74 Use NonDarwinLogger when running tests instead of os_log
'swift test' doesn't print os_log output to the command line. Use the  `NonDarwinLogger` that prints to stderr so we can view the log output in CI test runs.
2023-10-16 13:37:43 -07:00
Finagolfin
3292aed123 Use new SwiftPM flag to remove $ORIGIN from installed sourcekit-lsp ELF executable runpath
Also, move installation-only environment variable into get_swiftpm_environment_variables().
2023-10-13 00:42:06 +05:30
Alex Hoppen
73bbba385a Merge pull request #835 from ahoppen/ahoppen/disable-parallel-testing
Run tests sequentially in CI
2023-09-27 13:19:51 -07:00
Alex Hoppen
bc19c78873 Run tests sequentially in CI
The parallel test logs are just so hard to read that they don’t really provide any value. Locally, running the tests in serial only increases test times by 1 minute, which I think is a tradeoff worth making to actually be able to tell what’s going wrong in CI.
2023-09-27 09:18:35 -07:00
Alex Hoppen
92798038ab Merge pull request #832 from ahoppen/ahoppen/automatic-targets
Make targets automatic
2023-09-27 08:54:20 -07:00
Alex Hoppen
958e77c1b3 Only build the sourcekit-lsp executable in CI
sourcekit-lsp builds all the targets and there shouldn’t be any need to build `LSPBindings` and `_SourceKitLSP`. In fact, we can’t even build them if they are automatic targets.
2023-09-26 19:21:01 -07:00
Alex Hoppen
16c61ba1ce Make long test execution opt-out instead of opt-in
This matches what swift-syntax is doing and ensures that new contributors run all tests by default.
2023-09-26 18:37:31 -07:00
Butta
bb7da2fa16 Check the target triple to determine what build flags to apply when building sourcekit-lsp
I also replaced unnecessary regex checks.
2023-04-12 20:27:36 +05:30
Butta
4a22e0e725 Add back -no-toolchain-stdlib-rpath when installing sourcekit-lsp on linux
Pull #597 incorrectly removed this, as it's still needed on ELF platforms.
2023-03-10 11:06:00 +05:30
Eric Miotto
d4c6e2c0c6 Allow cross-compilation on Apple Silicon (#622)
Address rdar://99486698
2022-09-06 00:23:37 -07:00
Alex Hoppen
4741486af0 Add rpath of /usr/lib/swift and swift-5.5 compatibility library
Without it, sourcekit-lsp crashes on launch with the same errors as in apple/swift-package-manager#5467.
2022-08-16 21:34:17 +02:00
Alex Hoppen
3f1ae077ba Don’t build SourceKitLSPPackageTests in build-script-helper’s build action
Building SourceKitLSPPackageTests with cross-compilation enabled fails with
```
error: Could not find target named 'mypackagePackageTests_586B622B321A3B86_PackageProduct'
error: fatalError
```

For testing, we work around this by disabling cross-compilation. This is not possible for building, so we need to explicitly build all products.
2022-08-04 08:41:10 +02:00
Alex Hoppen
ac24fd613d Rename --build-path to --scratch-path in SwiftPM invocation
`--build-path` has been deprectated in favor of `--scratch-path` in SwiftPM.
2022-08-03 19:12:43 +02:00
Alex Hoppen
88d4b73b43 Ignore stderr when retrieving SwifitPM’s bin path 2022-08-03 19:12:43 +02:00
Alex Hoppen
ccf4d069a3 Don’t pass -no-toolchain-stdlib-rpath when installing sourcekit-lsp
Since https://github.com/apple/swift-package-manager/pull/4208 SwiftPM no longer adds rpath to the toolchain libraries, so we don’t need to exclude them.
2022-08-03 19:12:43 +02:00
Alex Hoppen
5eefa672f4 Print environment variables that were specified when executing commands 2022-08-03 19:12:43 +02:00
Alex Hoppen
cdcc924079 Add a --multiroot-data-file option to build sourcekit-lsp in a unified build 2022-08-03 19:12:43 +02:00
Alex Hoppen
dd92afb553 Explicitly build all targets
When we build SourceKit-LSP in a unified SwiftPM workspace, a simple `swift build` invocation will build all products in the unified workspace (not just SourceKit-LSP products).
2022-08-03 19:12:41 +02:00
Alex Hoppen
37d003eb73 Don’t clean build directory prior to building
AFAICT cleaning the build directory prior to building was done to work around a bug in SwiftPM at some point. I don’t think that it’s needed anymore.
2022-08-03 07:53:15 +02:00
Alex Hoppen
8e21003484 Restructure build-script-helper.py to make it more readable 2022-07-29 22:26:45 +02:00
Alex Hoppen
42f4239ff0 Change indentation of build-script-helper.py to 4 spaces
This matches the indentation of Python scripts in the rest of the Swift project.
2022-07-29 18:03:20 +02:00
Alex Hoppen
e5e949171c Remove dead code from build-script-helper.py 2022-07-29 18:03:05 +02:00
Alex Hoppen
d1c152ad9d Add type annotations to build-script-helper.py 2022-07-29 18:02:59 +02:00
Alex Hoppen
b8d8181a8c Merge pull request #556 from ahoppen/pr/cross-compile-arm64
Support creation of fat binaries that run on x86_64 and arm64
2022-06-01 09:34:22 +02:00
Alex Hoppen
59c5b63238 Update python scripts to Python3 2022-05-31 22:58:25 +02:00
Alex Hoppen
926414ce1a Support creation of fat binaries that run on x86_64 and arm64
Currently, when building an open source toolchain, SourceKit-LSP is only built for x86_64.  Copy the necessary cross-compilation parts from SwiftPM’s build script to also produce a fat sourcekit-lsp executable for both x86_64 and arm64.

rdar://78039145
2022-05-30 12:05:53 +02:00
Alex Hoppen
ef8bb5ae07 Disabe testable imports when testing
Otherwise, we still need to rebuild SourceKit-LSP even if no-clean is specified.
2022-05-23 17:50:37 +02:00
Alex Hoppen
ba1d590ccc Add option to not clean build directory prior to performing action 2022-05-23 17:50:22 +02:00
Alex Hoppen
215de9a835 Only run tests in parallel on Linux again
The underlying issue in the SwiftPM test runner has been fixed.

rdar://92262856
2022-05-13 15:09:58 +02:00