Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to download the correct binary for Apple silicon Macs #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion node/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod download {

include!("src/versions.rs");

#[cfg(all(target_os = "macos", any(target_arch = "x86_64", target_arch = "aarch64"),))]
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
fn download_filename() -> String {
if cfg!(not(feature = "23_2")) {
format!("bitcoin-{}-osx64.tar.gz", &VERSION)
Expand All @@ -31,6 +31,9 @@ mod download {
}
}

#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
fn download_filename() -> String { format!("bitcoin-{}-arm64-apple-darwin.tar.gz", &VERSION) }

#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
fn download_filename() -> String { format!("bitcoin-{}-x86_64-linux-gnu.tar.gz", &VERSION) }

Expand Down Expand Up @@ -155,6 +158,24 @@ mod download {
}
}
}

// Code signing for arm64 macOS:
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
{
use std::process::Command;
let status = Command::new("codesign")
.arg("-s")
.arg("-")
.arg(existing_filename.to_str().unwrap())
.status()
.with_context(|| "failed to execute codesign")?;
if !status.success() {
return Err(anyhow::anyhow!(
"codesign failed with exit code {}",
status.code().unwrap_or(-1)
));
}
}
}
Ok(())
}
Expand Down