Skip to content

Commit

Permalink
fix(rust): create install rust function
Browse files Browse the repository at this point in the history
Signed-off-by: bkioshn <[email protected]>
  • Loading branch information
bkioshn committed Nov 4, 2024
1 parent 6414b31 commit a29cc10
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion earthly/rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,40 @@ IMPORT ../../utilities/scripts AS scripts
# cspell: words TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT USERPLATFORM USEROS USERARCH USERVARIANT
# cspell: words findutils fileset pkgconfig wasip

# TODO(bkioshn): https://github.com/input-output-hk/catalyst-ci/issues/322
# Installing Rust
# Code reference from [rust1.81.0-slim-bookworm](https://github.com/rust-lang/docker-rust/blob/63f877a36f8ba9d9b4b35cd49df3327264510886/stable/bookworm/slim/Dockerfile)
INSTALL_RUST:
FUNCTION

ARG TARGETARCH

ENV RUSTUP_HOME=/usr/local/rustup
ENV CARGO_HOME=/usr/local/cargo
ENV PATH=/usr/local/cargo/bin:$PATH
ENV RUST_VERSION=1.81.0

IF [ "$TARGETARCH" = "amd64" ]
LET PLATFORM = "x86_64-unknown-linux-gnu"
LET RUSTUP_SHA = "6aeece6993e902708983b209d04c0d1dbb14ebb405ddb87def578d41f920f56d"
ELSE IF [ "$TARGETARCH" = "arm64" ]
LET PLATFORM = "aarch64-unknown-linux-gnu"
LET RUSTUP_SHA = "1cffbf51e63e634c746f741de50649bbbcbd9dbe1de363c9ecef64e278dba2b2"
ELSE
RUN echo >&2 "unsupported architecture: ${TARGETARCH}"; exit 1
END

LET URL = "https://static.rust-lang.org/rustup/archive/1.27.1/${PLATFORM}/rustup-init"
RUN wget $URL && echo "${RUSTUP_SHA} *rustup-init" | sha256sum -c - \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host $PLATFORM \
&& rm rustup-init \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
&& rustup --version \
&& cargo --version \
&& rustc --version \
&& rm -rf /var/lib/apt/lists/*

# rust-base : Base Rustup build container.
# Not called directly, used by other targets.
rust-base:
Expand Down Expand Up @@ -134,7 +168,6 @@ rust-base-plus-tools:
DO +COPY_TOOL --tool="cargo-sweep"
DO +COPY_TOOL --tool="cargo-component"
DO +COPY_TOOL --tool="wasm-pack"
DO +COPY_TOOL --tool="flutter-rust-bridge-codegen" --bin="flutter_rust_bridge_codegen"

# installer - fully setup our Rust caching.
installer:
Expand Down

0 comments on commit a29cc10

Please sign in to comment.