Skip to content

Commit e406cd3

Browse files
Stop hardcoding the Swift toolchain version in the Multithreading example
1 parent 28d5ec0 commit e406cd3

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Examples/Multithreading/README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
# Multithreading example
22

3-
Install Development Snapshot toolchain `DEVELOPMENT-SNAPSHOT-2024-07-08-a` from [swift.org/install](https://www.swift.org/install/) and run the following commands:
3+
Install Development Snapshot toolchain `DEVELOPMENT-SNAPSHOT-2024-07-08-a` or later from [swift.org/install](https://www.swift.org/install/) and run the following commands:
44

55
```sh
6-
$ swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasip1-threads.artifactbundle.zip
6+
$ (
7+
set -eo pipefail; \
8+
V="$(swiftc --version | head -n1)"; \
9+
TAG="$(curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -e -r --arg v "$V" '.[$v] | .[-1]')"; \
10+
curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG.json" | \
11+
jq -r '.["swift-sdks"]["wasm32-unknown-wasip1-threads"] | "swift sdk install \"\(.url)\" --checksum \"\(.checksum)\""' | sh -x
12+
)
13+
$ export SWIFT_SDK_ID=$(
14+
V="$(swiftc --version | head -n1)"; \
15+
TAG="$(curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -e -r --arg v "$V" '.[$v] | .[-1]')"; \
16+
curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG.json" | \
17+
jq -r '.["swift-sdks"]["wasm32-unknown-wasip1-threads"]["id"]'
18+
)
719
$ ./build.sh
820
$ npx serve
921
```

Examples/Multithreading/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
swift build --swift-sdk DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasip1-threads -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export=__main_argc_argv -c release -Xswiftc -g
1+
swift build --swift-sdk "${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}" -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export=__main_argc_argv -c release -Xswiftc -g

0 commit comments

Comments
 (0)