@@ -20,10 +20,11 @@ error() { printf -- "** ERROR: %s\n" "$*" >&2; }
20
20
fatal () { error " $@ " ; exit 1; }
21
21
22
22
# Parameter environment variables
23
- branch=" ${INSTALL_SWIFT_STATIC_SDK_BRANCH:= " " } "
24
- version=" ${INSTALL_SWIFT_STATIC_SDK_VERSION:= " " } "
25
- arch=" ${INSTALL_SWIFT_STATIC_SDK_ARCH:= " aarch64" } "
26
- os_image=" ${INSTALL_SWIFT_STATIC_SDK_OS_IMAGE:= " ubuntu22.04" } "
23
+ branch=" ${INSTALL_SWIFT_BRANCH:= " " } "
24
+ version=" ${INSTALL_SWIFT_VERSION:= " " } "
25
+ arch=" ${INSTALL_SWIFT_ARCH:= " aarch64" } "
26
+ os_image=" ${INSTALL_SWIFT_OS_IMAGE:= " ubuntu22.04" } "
27
+ sdk=" ${INSTALL_SWIFT_SDK:= " static-sdk" } "
27
28
28
29
if [[ ! ( -n " $branch " && -z " $version " ) && ! ( -z " $branch " && -n " $version " ) ]]; then
29
30
fatal " Exactly one of build or version must be defined."
@@ -43,6 +44,20 @@ case "$arch" in
43
44
fatal " Unexpected architecture: $arch " ;;
44
45
esac
45
46
47
+ case " $sdk " in
48
+ " static-sdk" )
49
+ sdk_dir=" static-sdk"
50
+ sdk_suffix=" _static-linux-0.0.1"
51
+ ;;
52
+ " wasm-sdk" )
53
+ sdk_dir=" wasm-sdk"
54
+ sdk_suffix=" _wasm"
55
+ ;;
56
+ * )
57
+ fatal " Unexpected SDK: $sdk "
58
+ ;;
59
+ esac
60
+
46
61
os_image_sanitized=" ${os_image// ./ } "
47
62
48
63
if [[ -n " $branch " ]]; then
@@ -54,24 +69,24 @@ if [[ -n "$branch" ]]; then
54
69
55
70
for snapshot in $snapshots ; do
56
71
snapshot_url=" https://download.swift.org/development/${os_image_sanitized}${arch_suffix} /${snapshot} /${snapshot} -${os_image}${arch_suffix} .tar.gz"
57
- static_sdk_url =" https://download.swift.org/development/static-sdk /${snapshot} /${snapshot} _static-linux-0.0.1 .artifactbundle.tar.gz"
58
-
72
+ sdk_url =" https://download.swift.org/development/${sdk_dir} /${snapshot} /${snapshot}${sdk_suffix} .artifactbundle.tar.gz"
73
+
59
74
# check that the files exist
60
75
" $CURL_BIN " -sILXGET --fail " $snapshot_url " > /dev/null; snapshot_return_code=$?
61
- " $CURL_BIN " -sILXGET --fail " $static_sdk_url " > /dev/null; static_sdk_return_code =$?
62
-
63
- if [[ (" $snapshot_return_code " -eq 0) && (" $static_sdk_return_code " -eq 0) ]]; then
76
+ " $CURL_BIN " -sILXGET --fail " $sdk_url " > /dev/null; sdk_return_code =$?
77
+
78
+ if [[ (" $snapshot_return_code " -eq 0) && (" $sdk_return_code " -eq 0) ]]; then
64
79
log " Discovered branch snapshot: $snapshot "
65
80
break
66
81
else
67
- log " Snapshot unavailable: $snapshot (Snapshot return code: $snapshot_return_code , Static SDK return code: $static_sdk_return_code )"
82
+ log " Snapshot unavailable: $snapshot (Snapshot return code: $snapshot_return_code , Swift SDK return code: $sdk_return_code )"
68
83
snapshot=" "
69
84
fi
70
85
done
71
86
if [[ -z " $snapshot " ]]; then
72
87
fatal " Failed to discover usable Swift snapshot"
73
88
fi
74
-
89
+
75
90
elif [[ -n " $version " ]]; then
76
91
if [[ " $version " == " latest" ]]; then
77
92
log " Discovering latest version"
@@ -83,7 +98,7 @@ elif [[ -n "$version" ]]; then
83
98
fi
84
99
85
100
snapshot_url=" https://download.swift.org/swift-${version} -release/${os_image_sanitized}${arch_suffix} /swift-${version} -RELEASE/swift-${version} -RELEASE-${os_image}${arch_suffix} .tar.gz"
86
- static_sdk_url =" https://download.swift.org/swift-${version} -release/static-sdk /swift-${version} -RELEASE/swift-${version} -RELEASE_static-linux-0.0.1 .artifactbundle.tar.gz"
101
+ sdk_url =" https://download.swift.org/swift-${version} -release/${sdk_dir} /swift-${version} -RELEASE/swift-${version} -RELEASE ${sdk_suffix} .artifactbundle.tar.gz"
87
102
fi
88
103
89
104
log " Obtaining Swift toolchain"
@@ -95,16 +110,16 @@ log "Installing Swift toolchain"
95
110
mkdir -p /tmp/snapshot
96
111
" $TAR_BIN " xfz " $snapshot_path " --strip-components 1 -C /
97
112
98
- log " Obtaining Static SDK"
99
- log " Static SDK URL: $static_sdk_url "
100
- static_sdk_path =" /tmp/$( basename " $static_sdk_url " ) "
101
- " $CURL_BIN " -sfL " $static_sdk_url " -o " $static_sdk_path " || fatal " Failed to download Static SDK"
113
+ log " Obtaining Swift SDK"
114
+ log " Swift SDK URL: $sdk_url "
115
+ sdk_path =" /tmp/$( basename " $sdk_url " ) "
116
+ " $CURL_BIN " -sfL " $sdk_url " -o " $sdk_path " || fatal " Failed to download Swift SDK"
102
117
103
118
log " Looking for swift"
104
119
which swift || fatal " Failed to locate installed Swift"
105
120
106
121
log " Checking swift"
107
122
swift --version
108
123
109
- log " Installing Static SDK"
110
- swift sdk install " $static_sdk_path "
124
+ log " Installing Swift SDK"
125
+ swift sdk install " $sdk_path "
0 commit comments