From f6378987834ecb7f1340174aad174c770d336f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 9 Aug 2024 20:52:24 +0000 Subject: [PATCH] refactor: move kernel build into independent Docker layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- Dockerfile | 14 ++++++++++++-- toolchain.sh | 10 +--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 651507e..f67541c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,14 @@ -FROM rust:bookworm AS builder +FROM --platform=$BUILDPLATFORM rust:bookworm AS kernel +ADD --link https://github.com/hermit-os/kernel.git#hermit-c /kernel +WORKDIR /kernel +RUN cargo xtask build \ + --artifact-dir . \ + --arch x86_64 \ + --release \ + --no-default-features \ + --features pci,smp,acpi,newlib,tcp,dhcpv4 + +FROM buildpack-deps:bookworm AS builder RUN set -eux; \ apt-get update; \ @@ -15,9 +25,9 @@ RUN set -eux; \ WORKDIR /root +COPY --link --from=kernel /kernel/libhermit.a ./kernel/libhermit.a ADD --link https://github.com/hermit-os/binutils.git binutils ADD --link https://github.com/hermit-os/gcc.git gcc -ADD --link https://github.com/hermit-os/kernel.git#hermit-c kernel ADD --link https://github.com/hermit-os/newlib.git newlib ADD --link https://github.com/hermit-os/pthread-embedded.git pte ADD --link ./toolchain.sh ./toolchain.sh diff --git a/toolchain.sh b/toolchain.sh index 06bd187..c6ebdac 100755 --- a/toolchain.sh +++ b/toolchain.sh @@ -68,15 +68,7 @@ make install-gcc cd - fi -cd kernel -cargo xtask build \ - --artifact-dir . \ - --arch x86_64 \ - --release \ - --no-default-features \ - --features pci,smp,acpi,newlib,tcp,dhcpv4 -export LDFLAGS_FOR_TARGET=-L$PWD -cd - +export LDFLAGS_FOR_TARGET=-L/root/kernel if [ ! -d "tmp/newlib" ]; then mkdir -p tmp/newlib