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 Oct 16, 2023
1 parent 01be30f commit e137a0e
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 0 deletions.
28 changes: 28 additions & 0 deletions containers/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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
# Last rev to trunk before tagging 4.3.3
SDCC_REV := 14376

.PHONY: ec-alpine
ec-alpine:
$(PODMAN) build \
--tag system76/$@:latest \
--build-arg=SDCC_REPO="$(SDCC_REPO)" \
--build-arg=SDCC_REV="$(SDCC_REV)" \
--file Containerfile \
$@

.PHONY: ec-debian
ec-debian:
$(PODMAN) build \
--tag system76/$@:latest \
--build-arg=SDCC_REPO="$(SDCC_REPO)" \
--build-arg=SDCC_REV="$(SDCC_REV)" \
--file Containerfile \
$@
58 changes: 58 additions & 0 deletions containers/ec-alpine/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# A container for Small Device C Compiler based on Alpine

ARG CONTAINER_IMAGE="alpine:3.18.4"

FROM ${CONTAINER_IMAGE} as sdcc-build
ARG SDCC_REPO
ARG SDCC_REV
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}/trunk/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
COPY --from=sdcc-build /opt/sdcc /opt/sdcc
ENV SDCC_REV "${SDCC_REV}"
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"]
55 changes: 55 additions & 0 deletions containers/ec-debian/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# A container for Small Device C Compiler based on Debian

ARG CONTAINER_IMAGE="debian:12.2"

FROM ${CONTAINER_IMAGE} as sdcc-build
ARG SDCC_REPO
ARG SDCC_REV
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}/trunk/sdcc \
sdcc

RUN cd sdcc && \
sh ./configure \
--disable-non-free \
--prefix= && \
make -j $(nproc) && \
make install DESTDIR=/opt/sdcc

FROM ${CONTAINER_IMAGE}
COPY --from=sdcc-build /opt/sdcc /opt/sdcc
ENV SDCC_REV "${SDCC_REV}"
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"]
2 changes: 2 additions & 0 deletions scripts/lint/01-spdx-tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ EXCLUDES=(
# Ignore dotfiles
':!:\.*'
':!:**/\.*'
# Ignore container files
':!:**/Containerfile*'
)

needs_tag=()
Expand Down

0 comments on commit e137a0e

Please sign in to comment.