From 41beb573da749e81484b9eb2e25d575bccd873d4 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Fri, 23 Feb 2024 15:06:55 -0700 Subject: [PATCH] Add Containerfiles for SDCC Provide SDCC in Alpine- and Debian-based containers. They can be used to build EC if it was cloned standalone with podman, e.g.: make -C containers ec-alpine podman run -it --rm -v $PWD:/workspace:Z system76/ec-alpine:latest make BOARD=system76/oryp8 Signed-off-by: Tim Crawford --- containers/Makefile | 30 ++++++++++++++ containers/ec-alpine/Containerfile | 65 +++++++++++++++++++++++++++++ containers/ec-debian/Containerfile | 66 ++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 containers/Makefile create mode 100644 containers/ec-alpine/Containerfile create mode 100644 containers/ec-debian/Containerfile diff --git a/containers/Makefile b/containers/Makefile new file mode 100644 index 000000000..607e07630 --- /dev/null +++ b/containers/Makefile @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-3.0-only + +# Disable built-in rules and variables +MAKEFLAGS += -rR + +PODMAN := $(shell command -v podman) + +SDCC_REPO := https://svn.code.sf.net/p/sdcc/code +SDCC_REV := 14648 +SDCC_VERSION := 4.4.0 + +.PHONY: ec-alpine +ec-alpine: + $(PODMAN) build \ + --tag system76/$@:latest \ + --build-arg=SDCC_REPO="$(SDCC_REPO)" \ + --build-arg=SDCC_REV="$(SDCC_REV)" \ + --build-arg=SDCC_VERSION="$(SDCC_VERSION)" \ + --file Containerfile \ + $@ + +.PHONY: ec-debian +ec-debian: + $(PODMAN) build \ + --tag system76/$@:latest \ + --build-arg=SDCC_REPO="$(SDCC_REPO)" \ + --build-arg=SDCC_REV="$(SDCC_REV)" \ + --build-arg=SDCC_VERSION="$(SDCC_VERSION)" \ + --file Containerfile \ + $@ diff --git a/containers/ec-alpine/Containerfile b/containers/ec-alpine/Containerfile new file mode 100644 index 000000000..285d00c38 --- /dev/null +++ b/containers/ec-alpine/Containerfile @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: NONE + +# A container for Small Device C Compiler based on Alpine +# SDCC: https://sdcc.sourceforge.net/ + +ARG CONTAINER_IMAGE="alpine:3.19.1" + +FROM ${CONTAINER_IMAGE} as sdcc-build +ARG SDCC_REPO +ARG SDCC_REV +ARG SDCC_VERSION +WORKDIR /tmp + +RUN apk update && \ + apk add --no-cache \ + autoconf \ + automake \ + bison \ + boost-dev \ + ca-certificates \ + flex \ + g++ \ + gcc \ + make \ + subversion \ + zlib-dev + +RUN svn checkout \ + --depth infinity \ + --revision ${SDCC_REV} \ + ${SDCC_REPO}/tags/sdcc-${SDCC_VERSION}/sdcc \ + sdcc + +# PIC requires gputils, which is not available on Alpine +RUN cd sdcc && \ + sh ./configure \ + --disable-pic14-port \ + --disable-pic16-port \ + --disable-non-free \ + --prefix= && \ + make -j $(nproc) && \ + make install DESTDIR=/opt/sdcc + +FROM ${CONTAINER_IMAGE} +ARG SDCC_REV +ARG SDCC_VERSION +COPY --from=sdcc-build /opt/sdcc /opt/sdcc +ENV SDCC_REV "${SDCC_REV}" +ENV SDCC_VERSION "${SDCC_VERSION}" +ENV SDCC_PATH "/opt/sdcc" +ENV PATH "${SDCC_PATH}/bin:$PATH" + +# NOTE: Using SDCC requires libstdc++ installed +RUN apk update && \ + apk add --no-cache \ + bash \ + binutils \ + git \ + libstdc++ \ + make \ + xxd + +WORKDIR /workspace +CMD ["bash"] diff --git a/containers/ec-debian/Containerfile b/containers/ec-debian/Containerfile new file mode 100644 index 000000000..7afc969cb --- /dev/null +++ b/containers/ec-debian/Containerfile @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: NONE + +# A container for Small Device C Compiler based on Debian +# SDCC: https://sdcc.sourceforge.net/ + +ARG CONTAINER_IMAGE="debian:12.5" + +FROM ${CONTAINER_IMAGE} as sdcc-build +ARG SDCC_REPO +ARG SDCC_REV +ARG SDCC_VERSION +WORKDIR /tmp + +RUN apt-get --quiet update && \ + apt-get --quiet install --no-install-recommends --assume-yes \ + autoconf \ + automake \ + bison \ + ca-certificates \ + flex \ + g++ \ + gcc \ + gputils \ + libboost-dev \ + make \ + subversion \ + zlib1g-dev \ + && apt-get clean + +RUN svn checkout \ + --depth infinity \ + --revision ${SDCC_REV} \ + ${SDCC_REPO}/tags/sdcc-${SDCC_VERSION}/sdcc \ + sdcc + +# PIC requires gputils, which is not available on Alpine +RUN cd sdcc && \ + sh ./configure \ + --disable-pic14-port \ + --disable-pic16-port \ + --disable-non-free \ + --prefix= && \ + make -j $(nproc) && \ + make install DESTDIR=/opt/sdcc + +FROM ${CONTAINER_IMAGE} +ARG SDCC_REV +ARG SDCC_VERSION +COPY --from=sdcc-build /opt/sdcc /opt/sdcc +ENV SDCC_REV "${SDCC_REV}" +ENV SDCC_VERSION "${SDCC_VERSION}" +ENV SDCC_PATH "/opt/sdcc" +ENV PATH "${SDCC_PATH}/bin:$PATH" + +RUN apt-get --quiet update && \ + apt-get --quiet install --no-install-recommends --assume-yes \ + bash \ + binutils \ + git \ + make \ + xxd \ + && apt-get clean + +WORKDIR /workspace +CMD ["bash"]