Skip to content

Commit

Permalink
Enable aarch64-apple-darwin builds (#1893) (#1894)
Browse files Browse the repository at this point in the history
* Build pipeline for building on arm64 macOS host architecture. Included CI build workflow for building the arm64 binaries

* Rename to aarch64-apple-darwin to resolve build dependency bug

* Amended markdown documentation

(cherry picked from commit 29e10be)
  • Loading branch information
sieniven committed Apr 13, 2023
1 parent 01abebc commit 046d9a2
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 10 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,20 @@ jobs:
with:
name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin
path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz

mac-aarch64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Populate environment
run: GIT_VERSION=1 ./make.sh ci-export-vars

- name: Build and package
run: GIT_VERSION=1 TARGET="aarch64-apple-darwin" ./make.sh docker-release

- name: Publish artifact - aarch64-apple-darwin
uses: actions/upload-artifact@v3
with:
name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin
path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz
24 changes: 24 additions & 0 deletions contrib/dockerfiles/aarch64-apple-darwin.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ARG TARGET=aarch64-apple-darwin

# -----------
FROM --platform=linux/amd64 ubuntu:latest as builder
ARG TARGET
LABEL org.defichain.name="defichain-builder"
LABEL org.defichain.arch=${TARGET}

WORKDIR /work
COPY ./make.sh .

RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base
RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps
RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps_osx_tools

COPY . .
RUN ./make.sh clean-depends && ./make.sh build-deps
RUN ./make.sh clean-conf && ./make.sh build-conf
RUN ./make.sh build-make

RUN mkdir /app && cd build/${TARGET} && \
make -s prefix=/ DESTDIR=/app install

# NOTE: These are not runnable images. So we do not add into a scratch base image.
2 changes: 1 addition & 1 deletion contrib/dockerfiles/aarch64-linux-gnu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TARGET=aarch64-linux-gnu

# -----------
FROM ubuntu:latest as builder
FROM --platform=linux/amd64 ubuntu:latest as builder
ARG TARGET
LABEL org.defichain.name="defichain-builder"
LABEL org.defichain.arch=${TARGET}
Expand Down
2 changes: 1 addition & 1 deletion contrib/dockerfiles/arm-linux-gnueabihf.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TARGET=arm-linux-gnueabihf

# -----------
FROM ubuntu:latest as builder
FROM --platform=linux/amd64 ubuntu:latest as builder
ARG TARGET
LABEL org.defichain.name="defichain-builder"
LABEL org.defichain.arch=${TARGET}
Expand Down
2 changes: 1 addition & 1 deletion contrib/dockerfiles/x86_64-apple-darwin.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TARGET=x86_64-apple-darwin

# -----------
FROM ubuntu:latest as builder
FROM --platform=linux/amd64 ubuntu:latest as builder
ARG TARGET
LABEL org.defichain.name="defichain-builder"
LABEL org.defichain.arch=${TARGET}
Expand Down
4 changes: 2 additions & 2 deletions contrib/dockerfiles/x86_64-pc-linux-gnu-clang.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TARGET=x86_64-pc-linux-gnu

# -----------
FROM debian:10 as builder
FROM --platform=linux/amd64 debian:10 as builder
ARG TARGET
ARG CLANG_VERSION=15
LABEL org.defichain.name="defichain-builder"
Expand Down Expand Up @@ -31,7 +31,7 @@ RUN mkdir /app && cd build/${TARGET} && \

# -----------
### Actual image that contains defi binaries
FROM debian:10
FROM --platform=linux/amd64 debian:10
ARG TARGET
LABEL org.defichain.name="defichain"
LABEL org.defichain.arch=${TARGET}
Expand Down
4 changes: 2 additions & 2 deletions contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TARGET=x86_64-pc-linux-gnu

# -----------
FROM ubuntu:latest as builder
FROM --platform=linux/amd64 ubuntu:latest as builder
ARG TARGET
LABEL org.defichain.name="defichain-builder"
LABEL org.defichain.arch=${TARGET}
Expand All @@ -23,7 +23,7 @@ RUN mkdir /app && cd build/${TARGET} && \

# -----------
### Actual image that contains defi binaries
FROM ubuntu:latest
FROM --platform=linux/amd64 ubuntu:latest
ARG TARGET
LABEL org.defichain.name="defichain"
LABEL org.defichain.arch=${TARGET}
Expand Down
2 changes: 1 addition & 1 deletion contrib/dockerfiles/x86_64-w64-mingw32.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TARGET=x86_64-w64-mingw32

# -----------
FROM ubuntu:latest as builder
FROM --platform=linux/amd64 ubuntu:latest as builder
ARG TARGET
LABEL org.defichain.name="defichain-builder"
LABEL org.defichain.arch=${TARGET}
Expand Down
2 changes: 1 addition & 1 deletion doc/build-quick.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ an environment with correct arch and pre-requisites configured.

- aarch64-linux-gnu
- arm-linux-gnueabihf
- arm-apple-darwin
- aarch64-apple-darwin

## Defined `env` variables

Expand Down
8 changes: 7 additions & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,13 @@ clean() {
_get_default_target() {
local default_target=""
if [[ "${OSTYPE}" == "darwin"* ]]; then
default_target="x86_64-apple-darwin"
local macos_arch=""
macos_arch=$(uname -m || true)
if [[ "$macos_arch" == "x86_64" ]]; then
default_target="x86_64-apple-darwin"
else
default_target="aarch64-apple-darwin"
fi
elif [[ "${OSTYPE}" == "msys" ]]; then
default_target="x86_64-w64-mingw32"
else
Expand Down

0 comments on commit 046d9a2

Please sign in to comment.