Skip to content

Commit

Permalink
feat: Add arm tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpinder committed Jun 3, 2024
1 parent d87477f commit 3d90c69
Showing 1 changed file with 12 additions and 112 deletions.
124 changes: 12 additions & 112 deletions cargo/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,22 @@ VERSION 0.8

PROJECT blue-build/earthly-lib

IMPORT github.com/earthly/lib/rust AS rust

build:
FROM rust
RUN apt-get update && \
apt-get install -y musl-dev musl-tools jq && \
RUN dpkg --add-architecture arm64 && \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
musl-dev \
musl-dev:arm64 \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
g++-aarch64-linux-gnu \
musl-tools \
jq && \
apt-get clean && \
rustup component add clippy && \
rustup target add x86_64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl aarch64-unknown-linux-gnu

RUN cargo install --root $CARGO_HOME --locked cargo-sweep git-cliff cargo-release

SAVE IMAGE --push ghcr.io/blue-build/earthly-lib/cargo-builder

INIT:
FUNCTION
ENV RUSTC_WRAPPER=""
IF [ -z "$EARTHLY_CACHE_PREFIX" ]
DO rust+INIT --keep_fingerprints=true
END

TEST:
FUNCTION
ARG NIGHTLY=false

DO +INIT

IF [ "$NIGHTLY" = true ]
DO rust+CARGO --args="test --features nightly -- --show-output"
ELSE
DO rust+CARGO --args="test -- --show-output"
END

LINT:
FUNCTION
ARG NIGHTLY=false

DO +INIT

IF [ "$NIGHTLY" = true ]
DO rust+CARGO --args="clippy --features nightly -- -D warnings"
ELSE
DO rust+CARGO --args="clippy -- -D warnings"
END

BUILD_RELEASE:
FUNCTION
ARG NIGHTLY=false
ARG BUILD_TARGET

DO +INIT

IF [ -n "$BUILD_TARGET" ]
IF [ "$NIGHTLY" = "true" ]
DO rust+CARGO --args="build --release --features nightly --target $BUILD_TARGET" --output="$BUILD_TARGET/release/[^\./]+"
ELSE
DO rust+CARGO --args="build --release --target $BUILD_TARGET" --output="$BUILD_TARGET/release/[^\./]+"
END
ELSE
IF [ "$NIGHTLY" = "true" ]
DO rust+CARGO --args="build --release --features nightly" --output="release/[^\./]+"
ELSE
DO rust+CARGO --args="build --release" --output="release/[^\./]+"
END
END

SAVE_IMAGE:
FUNCTION
ARG --required IMAGE
ARG TAG
ARG ALPINE=false
ARG NIGHTLY=false
ARG LATEST=false
ARG INSTALLER=false
LET FINAL_TAG=""

IF [ "$NIGHTLY" = "true" ]
SET FINAL_TAG="nightly"
END

IF [ "$ALPINE" = "true" ]
IF [ -n "$FINAL_TAG" ]
SET FINAL_TAG=$(echo -n "alpine-$FINAL_TAG")
ELSE
SET FINAL_TAG="alpine"
END
END

IF [ "$INSTALLER" = "true" ]
IF [ -n "$FINAL_TAG" ]
SET FINAL_TAG=$(echo -n "installer-$FINAL_TAG")
ELSE
SET FINAL_TAG="installer"
END
END


IF [ -n "$TAG" ]
IF [ -n "$FINAL_TAG" ]
SAVE IMAGE --push $IMAGE:$TAG-$FINAL_TAG
ELSE
SAVE IMAGE --push $IMAGE:$TAG
END

IF [ "$LATEST" = "true" ]
IF [ -n "$FINAL_TAG" ]
SAVE IMAGE --push $IMAGE:latest-$FINAL_TAG
ELSE
SAVE IMAGE --push $IMAGE:latest
END
END
ELSE
ARG EARTHLY_GIT_BRANCH
IF [ -n "$FINAL_TAG" ]
SAVE IMAGE --push $IMAGE:$EARTHLY_GIT_BRANCH-$FINAL_TAG
ELSE
SAVE IMAGE --push $IMAGE:$EARTHLY_GIT_BRANCH
END
END

0 comments on commit 3d90c69

Please sign in to comment.