Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions scripts/dvm
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,26 @@ _dvm_download_dartium() {
curl -f -O "$base_uri/dartium/$dartium_archive"
}

# Returns the CPU architechture for Dart in the specified SDK version.
#
# Used by Apple Silicon (arm64) based Macs to determine the architecture of the
# Dart SDK archive to download. For SDK 2.14.1 and later, download the arm64
# bundle. Prior to that, only Intel binaries are available.
_macos_arm64_sdk_arch() {
local archBoundary="2.14.1"
if [[ "$1" == "latest" || "$(printf "$1\n$archBoundary\n" | sort -t. -n -k 1,1 -k 2,2 -k 3,3 | head -n1)" == "$archBoundary" ]]; then
echo "arm64"
else
echo "x64"
fi
}

# Returns the CPU architechture for Dartium in the specified SDK version.
_dvm_dartium_arch() {
# SDKs <= 1.19.x are ia32, > 1.20.0 are x64.
# Through a happy quirk of fate, 1.20.0 never existed.
#
# In Dart SDKx 1.19.x and earlier, Dartium shipped only as an ia32 build. In
# SDKs later than 1.20.0, it was produced as an x64 build. Through a happy
# quirk of fate, 1.20.0 never existed.
_macos_dartium_arch() {
local archBoundary="1.20.0"
if [[ "$1" == "latest" || "$(printf "$1\n$archBoundary\n" | sort -t. -n -k 1,1 -k 2,2 -k 3,3 | head -n1)" == "$archBoundary" ]]; then
echo "x64"
Expand Down Expand Up @@ -275,8 +291,15 @@ dvm_install() {
fi

case $(uname -a) in
Darwin*arm64*)
local arch="$(_macos_arm64_sdk_arch "$version")"
local sdk_archive="dartsdk-macos-$arch-release.zip"
arch="$(_macos_dartium_arch "$version")"
local content_shell_archive="content_shell-macos-$arch-release.zip"
local dartium_archive="dartium-macos-$arch-release.zip"
;;
Darwin*)
local arch="$(_dvm_dartium_arch "$version")"
local arch="$(_macos_dartium_arch "$version")"
local sdk_archive="dartsdk-macos-x64-release.zip"
local content_shell_archive="content_shell-macos-$arch-release.zip"
local dartium_archive="dartium-macos-$arch-release.zip"
Expand Down