Skip to content

Commit

Permalink
Use M1 executor for mac binary builds (#465)
Browse files Browse the repository at this point in the history
* [skip ci]
  • Loading branch information
FabijanC authored May 20, 2024
1 parent 69f183a commit 1d9d2da
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
9 changes: 2 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ executors:
apple-darwin:
macos:
xcode: 15.3.0
resource_class: macos.m1.medium.gen1
environment:
COMPILER_ARCHIVE: cross-x86_64-apple-darwin.tar.gz

Expand Down Expand Up @@ -114,15 +115,9 @@ jobs:
command: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |
sh -s -- -y --default-toolchain=1.74.0
- run: rustup target add << parameters.target_triplet >>
- run:
name: Install Cross
command: |
curl -SsL https://github.com/cross-rs/cross/releases/download/v0.2.5/${COMPILER_ARCHIVE} |
tar -xvz -C /tmp
- run:
name: Compile binary
command: /tmp/cross build --release --target=<< parameters.target_triplet >>
command: ./scripts/compile_binary.sh << parameters.target_triplet >>
- run:
name: Archive and compress binary artifact # only the file, not the whole dir structure
command: tar -czvf << parameters.archive_path >> --directory target/<< parameters.target_triplet >>/release starknet-devnet
Expand Down
33 changes: 33 additions & 0 deletions scripts/compile_binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -euo pipefail

CROSS_VERSION="v0.2.5"

if [ $# != 1 ]; then
echo "Error: $0 <TARGET>"
exit 1
fi
TARGET="$1"

kernel_name=$(uname -s)
case "$kernel_name" in
Darwin*)
# on mac (for apple-darwin targets), rely on host compiler's targets
rustup target add "$TARGET"
compiler_command="cargo"
;;
Linux*)
# on linux, rely on cross compiler
download_url="https://github.com/cross-rs/cross/releases/download/${CROSS_VERSION}/cross-x86_64-unknown-linux-gnu.tar.gz"
curl -SsL "$download_url" |
tar -xvz -C /tmp
compiler_command="/tmp/cross"
;;
*)
echo "Unsupported kernel: $kernel_name"
exit 1
;;
esac

"$compiler_command" build --release --target="$TARGET"
2 changes: 1 addition & 1 deletion scripts/install_foundry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ -n "$CIRCLE_BRANCH" ]; then
fi

echo "Installing foundry"
foundryup --version nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a
foundryup --version nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a

# assert it works
anvil --version

0 comments on commit 1d9d2da

Please sign in to comment.