Skip to content

Commit 0704c88

Browse files
feat: Support aarch64-darwin. (#100)
* Support aarch64-darwin. * Check if the version has aarch64-darwin support. * Update changelog.
1 parent 384520c commit 0704c88

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- `--available`: List the available versions.
1414
- `--limit`: The maximum number of available versions to list in reverse chronological order, with default value `10`.
1515

16+
- `dfxvm` now supports installing dfx with the aarch64-Darwin binaries.
17+
1618
## [1.0.0] - 2024-02-20
1719

1820
## [0.3.1] - 2024-02-07

src/dfxvm/install.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub async fn install(version: Version, locations: &Locations) -> Result<(), Inst
5555

5656
extract_binary(&downloaded_tarball_path, install_dir.path())?;
5757

58-
let tarball_basename = format_tarball_basename();
58+
let tarball_basename = format_tarball_basename(&version);
5959
rename(&install_dir.path().join(tarball_basename), &version_dir)?;
6060

6161
info!("installed dfx {version}");
@@ -68,7 +68,7 @@ async fn download_verified_tarball(
6868
download_dir: &Path,
6969
settings: &Settings,
7070
) -> Result<PathBuf, DownloadVerifiedTarballError> {
71-
let tarball_basename = format_tarball_basename();
71+
let tarball_basename = format_tarball_basename(version);
7272
let tarball_filename = format!("{tarball_basename}.tar.gz");
7373
let shasum_filename = format!("{tarball_filename}.sha256");
7474
let downloaded_tarball_path = download_dir.join(tarball_filename);
@@ -99,12 +99,21 @@ async fn download_verified_tarball(
9999
Ok(downloaded_tarball_path)
100100
}
101101

102-
fn format_tarball_basename() -> &'static str {
102+
#[allow(unused_variables)]
103+
fn format_tarball_basename(version: &Version) -> &'static str {
103104
#[cfg(target_os = "linux")]
104-
let basename = "dfx-x86_64-unknown-linux-gnu";
105-
#[cfg(target_os = "macos")]
106-
let basename = "dfx-x86_64-apple-darwin";
107-
basename
105+
return "dfx-x86_64-unknown-linux-gnu";
106+
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
107+
return "dfx-x86_64-apple-darwin";
108+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
109+
{
110+
// This is the first version that supports aarch64-apple-darwin.
111+
let aarch64_apple_darwin_version = Version::parse("0.28.0-beta.1").unwrap();
112+
if version >= &aarch64_apple_darwin_version {
113+
return "dfx-aarch64-apple-darwin";
114+
}
115+
return "dfx-x86_64-apple-darwin";
116+
}
108117
}
109118

110119
fn format_tarball_url(

0 commit comments

Comments
 (0)