Skip to content

Commit

Permalink
Add Containerfiles for SDCC
Browse files Browse the repository at this point in the history
Provide minimal builds of 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 Mar 1, 2024
1 parent 2174b45 commit 515cc4f
Show file tree
Hide file tree
Showing 3 changed files with 201 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 \
$@
85 changes: 85 additions & 0 deletions containers/ec-alpine/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# 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

# Only the MCS-51 port is needed.
RUN cd sdcc && \
sh ./configure \
--disable-z80-port \
--disable-z180-port \
--disable-r2k-port \
--disable-r2ka-port \
--disable-r3ka-port \
--disable-sm83-port \
--disable-tlcs90-port \
--disable-ez80_z80-port \
--disable-z80n-port \
--disable-ds390-port \
--disable-ds400-port \
--disable-pic14-port \
--disable-pic16-port \
--disable-hc08-port \
--disable-s08-port \
--disable-stm8-port \
--disable-pdk13-port \
--disable-pdk14-port \
--disable-pdk15-port \
--disable-mos6502-port \
--disable-ucsim \
--disable-sdcdb \
--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"]
86 changes: 86 additions & 0 deletions containers/ec-debian/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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

# Only the MCS-51 port is needed.
RUN cd sdcc && \
sh ./configure \
--disable-z80-port \
--disable-z180-port \
--disable-r2k-port \
--disable-r2ka-port \
--disable-r3ka-port \
--disable-sm83-port \
--disable-tlcs90-port \
--disable-ez80_z80-port \
--disable-z80n-port \
--disable-ds390-port \
--disable-ds400-port \
--disable-pic14-port \
--disable-pic16-port \
--disable-hc08-port \
--disable-s08-port \
--disable-stm8-port \
--disable-pdk13-port \
--disable-pdk14-port \
--disable-pdk15-port \
--disable-mos6502-port \
--disable-ucsim \
--disable-sdcdb \
--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 515cc4f

Please sign in to comment.