You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
5.9 KiB
160 lines
5.9 KiB
# ========================================================================================== |
|
# Base image for both compilation & the final image |
|
FROM docker.ceres.area51.dev/area51/ubuntu:dev-20.04 AS dev |
|
|
|
WORKDIR /work |
|
|
|
# ========================================================================================== |
|
# Base image for go builds - this just ensures we are pulled first |
|
FROM docker.ceres.area51.dev/mirror/library/golang:alpine AS goDev |
|
|
|
# ========================================================================================== |
|
# Container containing X11 |
|
FROM dev AS base |
|
# Install dependencies. First set are for X11, the rest are for emulators: |
|
# x11 xvfb libgl1-mesa-dri |
|
# beebjit libasound2-dev libpulse-dev libx11-dev libxext-dev |
|
# z88dk libboost-all-dev texinfo texi2html libxml2-dev zlib1g-dev |
|
RUN area51-apt-get install -y \ |
|
xvfb libgl1-mesa-dri \ |
|
libasound2-dev libpulse-dev libx11-dev libxext-dev \ |
|
libboost-all-dev texinfo texi2html libxml2-dev zlib1g-dev |
|
|
|
# xvfb settings |
|
COPY xvfb-startup.sh /usr/local/bin/xvfb-startup |
|
RUN sed -i 's/\r$//' /usr/local/bin/xvfb-startup |
|
ARG RESOLUTION="1920x1080x24" |
|
ENV XVFB_RES="${RESOLUTION}" |
|
ARG XARGS="" |
|
ENV XVFB_ARGS="${XARGS}" |
|
|
|
# ========================================================================================== |
|
# Retrieve all sources |
|
FROM base AS src |
|
RUN curl -s https://nexus.ceres.area51.dev/repository/archives/8bit/assemblers/asmx-2.0b5.zip --output /usr/local/src/asmx-2.0b5.zip |
|
RUN git clone https://github.com/stardot/beebasm.git |
|
RUN git clone https://github.com/dasm-assembler/dasm.git |
|
RUN git clone https://github.com/scarybeasts/beebjit.git |
|
|
|
# Z88dk needs subprojects & sdcc checked out, patch applied then we then comment out those steps from the Makefile |
|
RUN git clone --recursive https://github.com/z88dk/z88dk |
|
RUN export Z88DK_PATH=$(pwd)/z88dk &&\ |
|
export SDCC_VERSION=$(grep -Po 'SDCC_VERSION\W+=\W+\K(.+)' ${Z88DK_PATH}/Makefile) &&\ |
|
export SDCC_PATH=${Z88DK_PATH}/$(grep -Po 'SDCC_PATH\W+=\W+\$\(Z88DK_PATH\)\/\K(.+)' ${Z88DK_PATH}/Makefile) &&\ |
|
svn checkout \ |
|
-r ${SDCC_VERSION} \ |
|
https://svn.code.sf.net/p/sdcc/code/trunk/sdcc \ |
|
-q ${SDCC_PATH} &&\ |
|
patch -d ${SDCC_PATH} -p0 < ${Z88DK_PATH}/src/zsdcc/sdcc-z88dk.patch &&\ |
|
sed -r \ |
|
-e '/^\W+svn checkout/ s/^#*/#/g' \ |
|
-e '/^\W+patch -d/ s/^#*/#/g' \ |
|
-i ${Z88DK_PATH}/Makefile |
|
|
|
|
|
# Destination directories for installation |
|
RUN mkdir -p /dest/usr/local/bin /dest/usr/local/share /dest/usr/local/src |
|
|
|
# Generate tar balls so we have a src option to correctly comply with GPL etc |
|
RUN (for i in $(ls -d *); do echo "Archiving $i"; tar czpf /dest/usr/local/src/${i}.tgz ${i};done) |
|
|
|
# ========================================================================================== |
|
# Assemblers & Compilers |
|
# ========================================================================================== |
|
# Asmx |
|
# The sed removes the target arch setting which is for a mac |
|
FROM src AS asmx |
|
RUN mkdir asmx && cd asmx && unzip /usr/local/src/asmx-2.0b5.zip &&\ |
|
sed -i -e "s/TARGET_ARCH/#TARGET_ARCH/g" src/Makefile &&\ |
|
make && make install && mv -v ~/bin/* /dest/usr/local/bin |
|
|
|
# ========================================================================================== |
|
# BeebAsm |
|
FROM src AS beebasm |
|
RUN cd beebasm/src && make all PLATFORM=linux && cp -p ../beebasm /dest/usr/local/bin/ |
|
|
|
# ========================================================================================== |
|
# Dasm |
|
FROM src AS dasm |
|
RUN cd dasm/src && make && cp dasm /dest/usr/local/bin/ |
|
|
|
# ========================================================================================== |
|
# Z88dk |
|
FROM src AS z88dk |
|
RUN cd z88dk && chmod 777 build.sh &&\ |
|
export BUILD_SDCC=1 &&\ |
|
export DESTDIR=/dest/usr/local &&\ |
|
make bin/z88dk-appmake bin/z88dk-copt bin/z88dk-zcpp \ |
|
bin/z88dk-ucpp bin/sccz80 bin/z88dk-z80asm \ |
|
bin/zcc bin/z88dk-zpragma bin/z88dk-zx7 \ |
|
bin/z88dk-z80nm bin/z88dk-zobjcopy \ |
|
bin/z88dk-ticks bin/z88dk-z80svg \ |
|
bin/z88dk-font2pv1000 bin/z88dk-basck \ |
|
bin/z88dk-lib bin/z88dk-zx0 &&\ |
|
make install |
|
|
|
# ========================================================================================== |
|
# Emulators |
|
# ========================================================================================== |
|
# beebjit |
|
FROM src AS beebjit |
|
ARG arch |
|
# Beebjit does not build on arm32v7 so don't build on that platform |
|
RUN if [ "${arch}" != "arm32v7" ]; then (\ |
|
cd beebjit &&\ |
|
xvfb-startup ./build.sh &&\ |
|
cp -p beebjit /dest/usr/local/bin/ &&\ |
|
mkdir -p /dest/usr/local/share/beebjit/ &&\ |
|
cp -rp roms /dest/usr/local/share/beebjit/ \ |
|
);fi |
|
|
|
# ========================================================================================== |
|
# Our own tools built by GO |
|
# |
|
# Split into multiple stages: module downloads, src extraction, tests then compilation. |
|
# Done this way so development doesn't cause a download for every minor change |
|
FROM goDev AS goBuild |
|
WORKDIR /work |
|
COPY go.mod . |
|
RUN go mod download |
|
|
|
FROM goBuild AS goSrc |
|
ADD disktool/ disktool/ |
|
|
|
#FROM goSrc AS goTest |
|
#RUN CGO_ENABLED=0 go test -v ./util |
|
|
|
FROM goSrc AS tools |
|
ARG arch |
|
ARG goos |
|
ARG goarch |
|
ARG goarm |
|
WORKDIR /work |
|
|
|
RUN CGO_ENABLED=0 GOOS=${goos} GOARCH=${goarch} GOARM=${goarm} go build \ |
|
-o /dest/usr/local/bin/disktool ./disktool/bin |
|
|
|
# ========================================================================================== |
|
# This brings everything built into a single layer |
|
FROM base AS merge |
|
|
|
# The src tar balls |
|
COPY --from=src /dest/ /dest/ |
|
|
|
# Assembers & Compilers |
|
COPY --from=asmx /dest/ /dest/ |
|
COPY --from=beebasm /dest/ /dest/ |
|
COPY --from=dasm /dest/ /dest/ |
|
COPY --from=z88dk /dest/ /dest/ |
|
|
|
# Emulators |
|
COPY --from=beebjit /dest/ /dest/ |
|
|
|
# Go based tools provided by us |
|
COPY --from=tools /dest/ /dest/ |
|
|
|
# ========================================================================================== |
|
# The final image |
|
FROM base AS final |
|
WORKDIR /work |
|
COPY --from=merge /dest/ /
|
|
|