diff --git a/Dockerfile b/Dockerfile index 3753f2877b..9428ed0c09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,46 @@ -FROM debian:bullseye-backports +# First construct an image where the toolchain gets built + +FROM debian:bullseye-backports AS mimiker-toolchain WORKDIR /root +# Install build dependencies for toolchain +RUN apt-get update -q \ + && apt-get upgrade -q -y \ + && apt-get install -q -y --no-install-recommends \ + automake bison ca-certificates curl flex gcc g++ gettext lhasa \ + libtool make patch pkg-config python3 python3-setuptools quilt \ + texinfo xz-utils zip libpython3-dev debhelper fakeroot ninja-build \ + libglib2.0-dev libfdt-dev libpixman-1-dev \ + && rm -rf /var/lib/apt/lists/* +COPY ./toolchain /root/toolchain +# Build toolchain & save .deb packages into /root/deb +RUN cd /root/toolchain/gnu \ + && make -j $(nproc) \ + && cd /root/toolchain/qemu-mimiker \ + && make -j $(nproc) \ + && mkdir /root/deb \ + && find /root/toolchain -iname '*.deb' -exec mv -t /root/deb {} + \ + && rm -rf /root/toolchain + +# Now construct an image for end users and Mimiker continuous integration +FROM debian:bullseye-backports AS mimiker-ci -RUN apt-get -q update && apt-get upgrade -y -RUN apt-get install -y --no-install-recommends \ +WORKDIR /root +COPY requirements.txt . +COPY --from=mimiker-toolchain /root/deb /root/deb +RUN apt-get update -q \ + && apt-get upgrade -q -y \ + && apt-get install -q -y --no-install-recommends \ git make cpio curl universal-ctags cscope socat patch gperf quilt \ bmake byacc python3-pip clang clang-format device-tree-compiler tmux \ - libfdt1 libpython3.9 libsdl2-2.0-0 libglib2.0-0 libpixman-1-0 -# patch & quilt required by lua and programs in contrib/ + libfdt1 libpython3.9 libsdl2-2.0-0 libglib2.0-0 libpixman-1-0 \ + && rm -rf /var/lib/apt/lists/* \ + && pip3 install setuptools wheel \ + && pip3 install -r requirements.txt \ + && dpkg -i --force-all /root/deb/*.deb \ + && apt-get update -q \ + && apt-get install -q -y -f \ + && rm -rf /var/lib/apt/lists/* /root/deb /root/requirements.txt +# patch & quilt required by programs in contrib/ # gperf required by libterminfo # socat & tmux required by launch -COPY requirements.txt . -RUN pip3 install setuptools wheel && pip3 install -r requirements.txt -RUN curl -O https://mimiker.ii.uni.wroc.pl/download/mipsel-mimiker-elf_1.5.3_amd64.deb && \ - dpkg -i mipsel-mimiker-elf_1.5.3_amd64.deb && rm -f mipsel-mimiker-elf_1.5.3_amd64.deb -RUN curl -O https://mimiker.ii.uni.wroc.pl/download/aarch64-mimiker-elf_1.5.3_amd64.deb && \ - dpkg -i aarch64-mimiker-elf_1.5.3_amd64.deb && rm -f aarch64-mimiker-elf_1.5.3_amd64.deb -RUN curl -O https://mimiker.ii.uni.wroc.pl/download/qemu-mimiker_6.1.0+mimiker1_amd64.deb && \ - dpkg -i qemu-mimiker_6.1.0+mimiker1_amd64.deb && rm -f qemu-mimiker_6.1.0+mimiker1_amd64.deb diff --git a/toolchain/Dockerfile b/toolchain/Dockerfile deleted file mode 100644 index 4722bc5b5a..0000000000 --- a/toolchain/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM debian:buster - -WORKDIR /root - -RUN apt-get -q update && apt-get upgrade -y -RUN apt-get install -y --no-install-recommends \ - automake bison ca-certificates curl flex gcc g++ gettext lhasa \ - libtool make patch pkg-config python3 python3-setuptools quilt \ - texinfo xz-utils zip libpython3-dev debhelper - -COPY . . diff --git a/toolchain/gnu/config.mk b/toolchain/gnu/config.mk index 929436b228..327bd7b013 100644 --- a/toolchain/gnu/config.mk +++ b/toolchain/gnu/config.mk @@ -14,7 +14,7 @@ BINUTILS = binutils-2.37 GCC = gcc-11.2.0 GDB = gdb-11.1 -ISL-URL = "http://isl.gforge.inria.fr/$(ISL).tar.xz" +ISL-URL = "https://mirror.sobukus.de/files/src/isl/$(ISL).tar.xz" MPFR-URL = "ftp://ftp.gnu.org/gnu/mpfr/$(MPFR).tar.xz" GMP-URL = "https://gmplib.org/download/gmp/$(GMP).tar.xz" MPC-URL = "https://ftp.gnu.org/gnu/mpc/$(MPC).tar.gz" diff --git a/wiki/docs/_Sidebar.md b/wiki/docs/_Sidebar.md index fdb482603a..bd6b4daa42 100644 --- a/wiki/docs/_Sidebar.md +++ b/wiki/docs/_Sidebar.md @@ -5,4 +5,4 @@ - [Commenting](https://github.com/cahirwpz/mimiker/wiki/commenting) - [Onboarding](https://github.com/cahirwpz/mimiker/wiki/onboarding) - [Test infrastructure](https://github.com/cahirwpz/mimiker/wiki/tests) - +- [Toolchain](https://github.com/cahirwpz/mimiker/wiki/toolchain) diff --git a/wiki/docs/toolchain.md b/wiki/docs/toolchain.md new file mode 100644 index 0000000000..46b1d2568f --- /dev/null +++ b/wiki/docs/toolchain.md @@ -0,0 +1,41 @@ +# Toolchain + +## Local environment + +### Container image + +You can use container image used by our CI system. + +To build latest version of container run: +- `git clone git@github.com:cahirwpz/mimiker.git && cd mimiker` +- `podman build -t mimiker .` +- `podman container run -it --rm --workdir /root/mimiker --hostname mimiker -v /home/user/mimiker:/root/mimiker mimiker /bin/bash` + +after last command you are in shell inside container, you can install your +favourite set of packages or just build Mimiker with the following command: +- `make` + +All changes are synchronized between local directory `/home/user/mimiker` and +`/root/mimiker` inside container, so you can edit source files using your +favourite editor. + +It is not required but it is recommended to use podman in rootless mode. You can +use also docker as drop-in replacement, but then you are on your own with file +permissions inside `/home/user/mimiker` directory. + +Note: building container is *SLOW* and IO *INTENSIVE* process. + +### Old-style local toolchain + +If you don't want to use containers you can still build binaries by hand & +create packages - currently we support only .deb package format and latest +Debian stable distribution. + +For gnu toolchain - C compiler and set of tools required for build & debug - you +need to invoke `make` command inside `toolchain/gnu` directory. + +For qemu - emulator used for local development - run `make` command inside +`toolchain/qemu-mimiker` directory. + +That's all - if you have problems look into `Dockerfile` in top directory. It +contains list of packages & commands required to prepare toolchain.