diff --git a/.circleci/config.yml b/.circleci/config.yml index 77d840210..1cde10714 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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 diff --git a/scripts/compile_binary.sh b/scripts/compile_binary.sh new file mode 100755 index 000000000..124d772a8 --- /dev/null +++ b/scripts/compile_binary.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -euo pipefail + +CROSS_VERSION="v0.2.5" + +if [ $# != 1 ]; then + echo "Error: $0 " + 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" diff --git a/scripts/install_foundry.sh b/scripts/install_foundry.sh index 156c93cb2..ed55e3e2b 100755 --- a/scripts/install_foundry.sh +++ b/scripts/install_foundry.sh @@ -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