Skip to content

Commit

Permalink
Add Containerfiles for SDCC
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
crawfxrd committed Feb 23, 2024
1 parent ef4eeae commit 41beb57
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
30 changes: 30 additions & 0 deletions containers/Makefile
Original file line number Diff line number Diff line change
@@ -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 \
$@
65 changes: 65 additions & 0 deletions containers/ec-alpine/Containerfile
Original file line number Diff line number Diff line change
@@ -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"]
66 changes: 66 additions & 0 deletions containers/ec-debian/Containerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 41beb57

Please sign in to comment.