From 5b7402dc16148ebf3cf08ced5120bdd70d880771 Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Tue, 30 Nov 2021 19:30:34 +0100 Subject: [PATCH] feat: update macOS builds for multi-arch --- .github/workflows/stacks-blockchain.yml | 2 +- build-scripts/Dockerfile.macos-arm64 | 23 ++++++----------------- build-scripts/Dockerfile.macos-x64 | 18 ++++++------------ build-scripts/build-dist.sh | 4 +++- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/.github/workflows/stacks-blockchain.yml b/.github/workflows/stacks-blockchain.yml index ee7828189..9d091586e 100644 --- a/.github/workflows/stacks-blockchain.yml +++ b/.github/workflows/stacks-blockchain.yml @@ -99,7 +99,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - platform: [ windows-x64, macos-x64, linux-x64, linux-musl-x64, linux-armv7, linux-arm64 ] + platform: [ windows-x64, macos-x64, macos-arm64, linux-x64, linux-musl-x64, linux-armv7, linux-arm64 ] steps: - uses: actions/checkout@v2 diff --git a/build-scripts/Dockerfile.macos-arm64 b/build-scripts/Dockerfile.macos-arm64 index bbeef757c..b97182c01 100644 --- a/build-scripts/Dockerfile.macos-arm64 +++ b/build-scripts/Dockerfile.macos-arm64 @@ -10,28 +10,17 @@ COPY . . RUN rustup target add aarch64-apple-darwin -RUN apt-get update && apt-get install -y git clang cmake +RUN apt-get update && apt-get install -y clang zstd -RUN git clone --depth 1 https://github.com/tpoechtrager/osxcross /opt/osxcross +RUN wget -nc -O /tmp/osxcross.tar.zst "https://github.com/hirosystems/docker-osxcross-rust/releases/download/MacOSX12.0.sdk/osxcross-d904031_MacOSX12.0.sdk.tar.zst" +RUN mkdir /opt/osxcross && tar -xaf /tmp/osxcross.tar.zst -C /opt/osxcross -RUN cd /opt/osxcross/tarballs && wget -nc "http://192.168.1.76:3000/MacOSX12.0.sdk.tar.bz2" +RUN . /opt/osxcross/env-macos-aarch64 && printenv -RUN cd /opt/osxcross && UNATTENDED=1 ./build.sh -RUN cargo update --workspace=./ -RUN cargo fetch --target aarch64-apple-darwin -#RUN ls /opt/osxcross/target/bin && exit 1 -#RUN ls /opt/osxcross/target/lib && exit 1 -RUN PATH="/opt/osxcross/target/bin:${PATH}" \ - TARGET_CC=aarch64-apple-darwin21.1-clang \ - LIBZ_SYS_STATIC=1 \ - LD_LIBRARY_PATH="/opt/osxcross/target/lib:$LD_LIBRARY_PATH" \ - CC=o64-clang \ - CC_aarch64_apple_darwin=aarch64-apple-darwin21.1-clang \ - CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=aarch64-apple-darwin21.1-clang \ - CARGO_TARGET_AARCH64_APPLE_DARWIN_AR=aarch64-apple-darwin21.1-ar \ +RUN . /opt/osxcross/env-macos-aarch64 && \ cargo build --target aarch64-apple-darwin --release --workspace=./ RUN mkdir /out && cp -R /src/target/aarch64-apple-darwin/release/. /out FROM scratch AS export-stage -COPY --from=build /out/blockstack-core /out/blockstack-cli /out/clarity-cli /out/stacks-node / \ No newline at end of file +COPY --from=build /out/blockstack-core /out/blockstack-cli /out/clarity-cli /out/stacks-node / diff --git a/build-scripts/Dockerfile.macos-x64 b/build-scripts/Dockerfile.macos-x64 index 4bbff2cf2..db8d6908f 100644 --- a/build-scripts/Dockerfile.macos-x64 +++ b/build-scripts/Dockerfile.macos-x64 @@ -1,4 +1,4 @@ -FROM rust:stretch as build +FROM rust:bullseye as build ARG STACKS_NODE_VERSION="No Version Info" ARG GIT_BRANCH='No Branch Info' @@ -10,18 +10,12 @@ COPY . . RUN rustup target add x86_64-apple-darwin -RUN apt-get update && apt-get install -y git clang +RUN apt-get update && apt-get install -y clang zstd -RUN wget -nc "https://github.com/hirosystems/osxcross/releases/download/v1/osxcross-e0a1718_xcode-v10.2.1.tar.xz" && \ - tar --checkpoint=25000 -xf "osxcross-e0a1718_xcode-v10.2.1.tar.xz" -C /tmp && \ - PATH="/tmp/osxcross/bin:$PATH" \ - LD_LIBRARY_PATH="/tmp/osxcross/lib:$LD_LIBRARY_PATH" \ - CC=o64-clang \ - CXX=o64-clang++ \ - LIBZ_SYS_STATIC=1 \ - CC_x86_64_apple_darwin=x86_64-apple-darwin18-clang \ - CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=x86_64-apple-darwin18-clang \ - CARGO_TARGET_X86_64_APPLE_DARWIN_AR=x86_64-apple-darwin18-ar \ +RUN wget -nc -O /tmp/osxcross.tar.zst "https://github.com/hirosystems/docker-osxcross-rust/releases/download/MacOSX12.0.sdk/osxcross-d904031_MacOSX12.0.sdk.tar.zst" +RUN mkdir /opt/osxcross && tar -xaf /tmp/osxcross.tar.zst -C /opt/osxcross + +RUN . /opt/osxcross/env-macos-x86_64 && \ cargo build --target x86_64-apple-darwin --release --workspace=./ RUN mkdir /out && cp -R /src/target/x86_64-apple-darwin/release/. /out diff --git a/build-scripts/build-dist.sh b/build-scripts/build-dist.sh index 0d8a74565..760d0ea61 100755 --- a/build-scripts/build-dist.sh +++ b/build-scripts/build-dist.sh @@ -9,7 +9,7 @@ cd "$src_dir" build_platform () { echo "Building $1" rm -rf dist/$1 - DOCKER_BUILDKIT=1 docker build -o dist/$1 -f ./build-scripts/Dockerfile.$1 . + DOCKER_BUILDKIT=1 docker build --progress=plain -o dist/$1 -f ./build-scripts/Dockerfile.$1 . } case $DIST_TARGET_FILTER in @@ -21,6 +21,7 @@ case $DIST_TARGET_FILTER in linux-arm64) build_platform linux-arm64 ;; windows-x64) build_platform windows-x64 ;; macos-x64) build_platform macos-x64 ;; + macos-arm64) build_platform macos-arm64 ;; *) echo "Invalid dist target filter '$DIST_TARGET_FILTER'" exit 1 @@ -35,5 +36,6 @@ case $DIST_TARGET_FILTER in build_platform linux-arm64 build_platform windows-x64 build_platform macos-x64 + build_platform macos-arm64 ;; esac