diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..1ae16b787 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,15 @@ +{ + "name": "System76 EC", + "build": { + "dockerfile": "../tools/containers/ec/Containerfile" + }, + "customizations": { + "vscode": { + "settings": {}, + "extensions": [ + "EditorConfig.EditorConfig", + "rust-lang.rust-analyzer" + ] + } + } +} diff --git a/.editorconfig b/.editorconfig index cfbf1d18a..56729651a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,5 +16,5 @@ trim_trailing_whitespace = false [{Makefile,*.mk}] indent_style = tab -[*.yml] +[*.{json,yaml,yml}] indent_size = 2 diff --git a/tools/containers/Makefile b/tools/containers/Makefile index 389726595..6f5ecc3e8 100644 --- a/tools/containers/Makefile +++ b/tools/containers/Makefile @@ -11,11 +11,35 @@ MAKEFLAGS += --silent endif PODMAN := $(shell command -v podman) -CONTAINER_TAG := $(shell git describe --always --abbrev=12) + +.PHONY: all +all: sdcc ec + +# SDCC toolchain container + +SDCC_REPO := https://svn.code.sf.net/p/sdcc/code +SDCC_REV := 14648 +SDCC_VERSION := 4.4.0 + +.PHONY: sdcc +sdcc: + $(PODMAN) build \ + --tag system76/$@:$(SDCC_VERSION) \ + --build-arg=SDCC_REPO="$(SDCC_REPO)" \ + --build-arg=SDCC_REV="$(SDCC_REV)" \ + --build-arg=SDCC_VERSION="$(SDCC_VERSION)" \ + --file Containerfile \ + $@ + +# EC development container + +DEVCONTAINER_TAG := $(shell git describe --always --abbrev=12) +RUST_TOOLCHAIN := 1.85.0 .PHONY: ec ec: $(PODMAN) build \ - --tag system76/$@:$(CONTAINER_TAG) \ + --tag system76/$@:$(DEVCONTAINER_TAG) \ + --build-arg=RUST_TOOLCHAIN="$(RUST_TOOLCHAIN)" \ --file Containerfile \ $@ diff --git a/tools/containers/ec/Containerfile b/tools/containers/ec/Containerfile index 6e1c3f975..fe18cc79a 100644 --- a/tools/containers/ec/Containerfile +++ b/tools/containers/ec/Containerfile @@ -1,87 +1,12 @@ # SPDX-License-Identifier: CC0-1.0 # SPDX-FileCopyrightText: NONE -# A container for 8051 development using Small Device C Compiler. -# SDCC: https://sdcc.sourceforge.net/ +# A container for System76 EC development. -# NOTE: The repository is specified in the image name to make it explicit -# which source is being trusted to provide the image. -ARG CONTAINER_IMAGE="docker.io/library/debian:trixie-20250520-slim" +ARG CONTAINER_IMAGE="localhost/system76/sdcc:4.4.0" -ARG SDCC_REPO="https://svn.code.sf.net/p/sdcc/code" -ARG SDCC_REV="14648" -ARG SDCC_VERSION="4.4.0" - -ARG RUST_TOOLCHAIN="1.85.0" - -# Build SDCC toolchain -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 \ - 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 - -# EC development environment FROM ${CONTAINER_IMAGE} -ARG SDCC_REV -ARG SDCC_VERSION ARG RUST_TOOLCHAIN -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 \ @@ -104,7 +29,6 @@ RUN apt-get --quiet update \ # a comma separated list as an argument with a space. # Ref: https://github.com/rust-lang/rustup/issues/4073 RUN rustup toolchain install \ - --no-self-update \ --target x86_64-unknown-linux-gnu,x86_64-unknown-uefi \ --profile minimal \ --component=clippy,rustfmt \ diff --git a/tools/containers/sdcc/Containerfile b/tools/containers/sdcc/Containerfile new file mode 100644 index 000000000..7820c84bb --- /dev/null +++ b/tools/containers/sdcc/Containerfile @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: NONE + +# A container for the Small Device C Compiler. +# SDCC: https://sdcc.sourceforge.net/ + +ARG CONTAINER_IMAGE="docker.io/library/debian:trixie-20251208-slim" + +# Build the SDCC toolchain. +FROM ${CONTAINER_IMAGE} as sdcc-build +ARG SDCC_REPO +ARG SDCC_REV +ARG SDCC_VERSION +WORKDIR /tmp + +# Install compile-time dependencies. +# NOTE: SDCC 4.4.0 does not build with the default GCC (gcc-14). +RUN apt-get update \ + && apt-get install --no-install-recommends --assume-yes \ + automake \ + bison \ + ca-certificates \ + flex \ + g++-13 \ + gcc-13 \ + gputils \ + libboost-dev \ + make \ + subversion \ + zlib1g-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 50 \ + && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 50 + +RUN svn checkout \ + --depth infinity \ + --revision ${SDCC_REV} \ + ${SDCC_REPO}/tags/sdcc-${SDCC_VERSION}/sdcc \ + sdcc + +RUN cd sdcc \ + && sh ./configure \ + --disable-non-free \ + --prefix= \ + && make --jobs=4 \ + && 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" + +# Install run-time dependencies. +RUN apt-get update \ + && apt-get install --no-install-recommends --assume-yes \ + libc6 \ + libstdc++6 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*