@@ -20,10 +20,11 @@ error() { printf -- "** ERROR: %s\n" "$*" >&2; }
2020fatal () { error " $@ " ; exit 1; }
2121
2222# 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" } "
2728
2829if [[ ! ( -n " $branch " && -z " $version " ) && ! ( -z " $branch " && -n " $version " ) ]]; then
2930 fatal " Exactly one of build or version must be defined."
@@ -43,6 +44,24 @@ case "$arch" in
4344 fatal " Unexpected architecture: $arch " ;;
4445esac
4546
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+ " android-sdk" )
57+ sdk_dir=" android-sdk"
58+ sdk_suffix=" _android-0.1"
59+ ;;
60+ * )
61+ fatal " Unexpected Swift SDK: $sdk "
62+ ;;
63+ esac
64+
4665os_image_sanitized=" ${os_image// ./ } "
4766
4867if [[ -n " $branch " ]]; then
@@ -54,24 +73,24 @@ if [[ -n "$branch" ]]; then
5473
5574 for snapshot in $snapshots ; do
5675 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-
76+ sdk_url =" https://download.swift.org/development/${sdk_dir} /${snapshot} /${snapshot}${sdk_suffix} .artifactbundle.tar.gz"
77+
5978 # check that the files exist
6079 " $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
80+ " $CURL_BIN " -sILXGET --fail " $sdk_url " > /dev/null; sdk_return_code =$?
81+
82+ if [[ (" $snapshot_return_code " -eq 0) && (" $sdk_return_code " -eq 0) ]]; then
6483 log " Discovered branch snapshot: $snapshot "
6584 break
6685 else
67- log " Snapshot unavailable: $snapshot (Snapshot return code: $snapshot_return_code , Static SDK return code: $static_sdk_return_code )"
86+ log " Snapshot unavailable: $snapshot (Snapshot return code: $snapshot_return_code , Swift SDK return code: $sdk_return_code )"
6887 snapshot=" "
6988 fi
7089 done
7190 if [[ -z " $snapshot " ]]; then
7291 fatal " Failed to discover usable Swift snapshot"
7392 fi
74-
93+
7594elif [[ -n " $version " ]]; then
7695 if [[ " $version " == " latest" ]]; then
7796 log " Discovering latest version"
@@ -83,7 +102,7 @@ elif [[ -n "$version" ]]; then
83102 fi
84103
85104 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"
105+ sdk_url =" https://download.swift.org/swift-${version} -release/${sdk_dir} /swift-${version} -RELEASE/swift-${version} -RELEASE ${sdk_suffix} .artifactbundle.tar.gz"
87106fi
88107
89108log " Obtaining Swift toolchain"
@@ -95,16 +114,16 @@ log "Installing Swift toolchain"
95114mkdir -p /tmp/snapshot
96115" $TAR_BIN " xfz " $snapshot_path " --strip-components 1 -C /
97116
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"
117+ log " Obtaining Swift SDK"
118+ log " Swift SDK URL: $sdk_url "
119+ sdk_path =" /tmp/$( basename " $sdk_url " ) "
120+ " $CURL_BIN " -sfL " $sdk_url " -o " $sdk_path " || fatal " Failed to download Swift SDK"
102121
103122log " Looking for swift"
104123which swift || fatal " Failed to locate installed Swift"
105124
106125log " Checking swift"
107126swift --version
108127
109- log " Installing Static SDK"
110- swift sdk install " $static_sdk_path "
128+ log " Installing Swift SDK"
129+ swift sdk install " $sdk_path "
0 commit comments