Skip to content
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

Feature request: Swift SDK installation #123

Open
kkebo opened this issue Jun 18, 2024 · 4 comments
Open

Feature request: Swift SDK installation #123

kkebo opened this issue Jun 18, 2024 · 4 comments

Comments

@kkebo
Copy link
Contributor

kkebo commented Jun 18, 2024

What is Swift SDK?

Swift SDK is defined in SE-0387.

It can be installed by swift sdk install and uninstalled by swift sdk remove.

Nowadays, Swift SDKs are distributed in some places. It is expected to increase more and more in the future.

Motivations

The current installation process of Swift SDK has two problems I think.

  1. Users have to know the specific URLs to install Swift SDKs.
    • If swiftly can install Swift SDKs published on swift.org, this problem will be resolved. This can be achieved by wrapping the swift sdk command with swiftly.
  2. Installed Swift SDKs are shared in all toolchains regardless of their versions even if it is not usable in that version.
    • All Swift SDKs installed are stored in $HOME/.swiftpm/swift-sdks/ and shared between all Swift toolchains installed even if it cannot be usable in that version.

Proposed solutions

I'd like to discuss more.

@adam-fowler
Copy link
Contributor

I'm not sure swiftly is the best place to resolve these issues. They should probably be fixed at the swift sdk level.

@kkebo
Copy link
Contributor Author

kkebo commented Jun 18, 2024

I understand what you are saying, but I think it is too much of a responsibility for swift sdk to have the feature to download a Swift SDK from somewhere like swift.org without specifying its URL.

And it is what swiftly already does.

@adam-fowler
Copy link
Contributor

Including @al45tair as he was working on this

@kateinoigakukun
Copy link
Member

I think we can split this into two features: 1. Install Swift SDKs isolated to a specific toolchain, 2. Install Swift SDKs declared in a configuration file automatically.

Feature 1: Install Swift SDKs isolated to a specific toolchain

The feature 1 should satisfy @kkebo's motivation 2.

  1. Installed Swift SDKs are shared in all toolchains regardless of their versions even if it is not usable in that version.

It can be implemented in SwiftPM standalone or cooperating with SwiftPM and swiftly:

  • Option 1: Install Swift SDK bundles inside the toolchain directory e.g. usr/lib/swift-sdks/ (like what Rust toolchain does)
    • Pros:
      • Users without swiftly can benefit from the isolation
      • No need to modify swiftly
    • Cons: It breaks the assumption that toolchain directory is read-only.
      • Prebuilt swiftinterface and __pycache__ for lldb Python scripts are already written after installation. But they are just caches, so it's fine even if the current user can't write under the toolchain directory.
      • But in this context, If a toolchain is installed by root user at /, and user me invokes swift sdk install ..., the installation fails.
  • Option 2: Allow specifying Swift SDK directory via an environment variable in SwiftPM and set it in swiftly proxies per toolchain version. (thanks to recent @cmcgee1024's recent Proxy work)
    • Pros: We can keep the toolchain directory clean
    • Cons: It requires inter-tool cooperation and users without swiftly cannot benefit from the isolation.

I'd like to hear @MaxDesiatov's opinion here.

Feature 2: Install Swift SDKs from URLs or by SDK names declared in a configuration file

The feature 2 should mitigate @kkebo's motivation 1. How about the following interface?

Given the following configuration file:

$ cat .swiftly/config.json
{
  "toolchain-version": "6.0.2",
  "swift-sdks": [
    // Download from swift.org
    "x86_64-swift-linux-musl",
    // Download custom Swift SDKs
    {
      "download-url": "https://github.com/finagolfin/swift-android-sdk/releases/download/6.0.2/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle.tar.gz",
      "checksum": "d75615eac3e614131133c7cc2076b0b8fb4327d89dce802c25cd53e75e1881f4"
    },
    {
      "download-url": "https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.0.2-RELEASE/swift-wasm-6.0.2-RELEASE-wasm32-unknown-wasi.artifactbundle.zip",
      "checksum": "6ffedb055cb9956395d9f435d03d53ebe9f6a8d45106b979d1b7f53358e1dcb4"
    }
  ]
}

Then swiftly install installs those SDKs. We can hard code known official SDK URLs and checksum hashes in swiftly to allow users to specify SDKs by target name.

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

No branches or pull requests

3 participants