Skip to content

Use SwiftPM's SDK computation logic #1643

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 4 commits into from
Aug 29, 2024

Conversation

kabiroberai
Copy link
Contributor

@kabiroberai kabiroberai commented Aug 28, 2024

Using SwiftSDK.deriveTargetSwiftSDK, which is the same method that SwiftPM's own CLI tools use to determine the SDK from passed-in info (target --triple, --swift-sdk, and host sdk). This allows us to better uphold the contract in the Configuration File docs, namely that the swiftSDK param is "Equivalent to SwiftPM's --swift-sdk option" and similarly for triple.

As concrete examples of where (AFAICT) the current implementation diverges:

This PR depends on:

But I feel that the two PRs are worth discussing as one since this use case is the primary motivating factor. Will flesh out the SwiftPM PR if the SourceKit/SwiftPM teams agree that this is the right strategy.

@kabiroberai kabiroberai requested a review from ahoppen as a code owner August 28, 2024 04:58
@kabiroberai
Copy link
Contributor Author

GitHub won't let me request reviewers but cc @kateinoigakukun @MaxDesiatov

@MaxDesiatov
Copy link
Contributor

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @kabiroberai! Do you think you could write a test to make sure we don’t regress this in the future? Probably something like SwiftPMIntegrationTests.testWasm but that utilizes the Wasm SDK in a way that fails before your PR and succeeds after? Maybe it would be sufficient to just update that test.

@kabiroberai
Copy link
Contributor Author

@ahoppen added a test! Confirmed that it fails prior to applying the changes in this PR. Don't think it can be an end-to-end integration test because afaik we'd need to provide a real WASI sysroot for that, but I added logic to test that we calculate the correct SDK path.

@kateinoigakukun
Copy link
Member

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the test @kabiroberai!

@ahoppen
Copy link
Member

ahoppen commented Aug 29, 2024

swiftlang/swift-package-manager#7925

@swift-ci Please test Windows

MaxDesiatov pushed a commit to swiftlang/swift-package-manager that referenced this pull request Aug 29, 2024
Used by swiftlang/sourcekit-lsp#1643

### Motivation:

Allows us to achieve parity between sourcekit-lsp's configuration
options and SwiftPM's `--triple`/`--swift-sdk`.

### Modifications:

Make `SwiftSDK.deriveTargetSwiftSDK` public

### Result:

See swiftlang/sourcekit-lsp#1643
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) August 29, 2024 12:05
@MaxDesiatov MaxDesiatov merged commit 821663c into swiftlang:main Aug 29, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code autocompletion stop working after specify SDK
5 participants