Browse Source

Add z88dk for z80 compilation

master
peter 4 years ago
parent
commit
94f04dff06
  1. 146
      Dockerfile
  2. 7
      disktool/image/d64/d64.go
  3. 29
      disktool/image/dfs/catalog.go
  4. 8
      disktool/image/dfs/disk.go
  5. 11
      disktool/image/dfs/ssd.go
  6. 6
      disktool/image/meta.go
  7. 7
      xvfb-startup.sh

146
Dockerfile

@ -1,36 +1,152 @@
FROM docker.ceres.area51.dev/area51/ubuntu:dev-20.04 AS base
# ==========================================================================================
# Base image for both compilation & the final image
FROM docker.ceres.area51.dev/area51/ubuntu:dev-20.04 AS dev
WORKDIR /work
# ==========================================================================================
# 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 dos2unix libboost-all-dev texinfo texi2html libxml2-dev subversion bison flex zlib1g-dev m4
RUN area51-apt-get install -y \
xvfb libgl1-mesa-dri \
libasound2-dev libpulse-dev libx11-dev libxext-dev \
dos2unix libboost-all-dev texinfo texi2html libxml2-dev subversion bison flex zlib1g-dev m4
# 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 &&\
git clone https://github.com/dasm-assembler/dasm.git
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
# Generate tar balls so we have a src option to correctly comply with GPL etc
RUN mkdir -p /usr/local/src &&\
(for i in $(ls -d *); do echo "Archiving $i"; tar czpf /usr/local/src/${i}.tgz ${i};done)
# 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
# Assemblers
FROM src AS assemblers
# 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/* /usr/local/bin
make && make install && mv -v ~/bin/* /dest/usr/local/bin
# ==========================================================================================
# BeebAsm
RUN cd beebasm/src && make all PLATFORM=linux && cp -p ../beebasm /usr/local/bin/
FROM src AS beebasm
RUN cd beebasm/src && make all PLATFORM=linux && cp -p ../beebasm /dest/usr/local/bin/
# ==========================================================================================
# Dasm
RUN cd dasm/src && make && cp dasm /usr/local/bin/
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
#./build.sh -i /dest/usr/local
# ==========================================================================================
# Emulators
# ==========================================================================================
# beebjit
FROM src AS beebjit
RUN cd beebjit && xvfb-startup ./build.sh && cp -p beebjit /dest/usr/local/bin/
RUN mkdir -p /dest/usr/local/share/beebjit/ &&\
cp -rp beebjit/roms /dest/usr/local/share/beebjit/
# ==========================================================================================
# 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 docker.ceres.area51.dev/mirror/library/golang:alpine 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/
#RUN fail
# Go based tools provided by us
COPY --from=tools /dest/ /dest/
# The final d64
# ==========================================================================================
# The final image
FROM base AS final
WORKDIR /work
COPY --from=src /usr/local/src/ /usr/local/src
COPY --from=assemblers /usr/local/bin/ /usr/local/bin
COPY --from=merge /dest/ /

7
disktool/image/d64/d64.go

@ -36,9 +36,14 @@ var d64Geometry = image.CreateGeometry(1, 35, 256, d64SectorCount)
// NewD64 returns a blank 35 track D64 image
func (d *D64) CreateImage() image.Image {
meta := image.NewMeta()
meta.Set(image.MetaImage, d.Name())
meta.Set(image.MetaFormat, d.Desc())
meta.Set(image.MetaSides, 1)
return &D64Disk{
media: image.CreateMedia(d64Geometry),
meta: image.NewMeta(),
meta: meta,
directoryManager: image.UnsupportedDirectoryManager(),
}
}

29
disktool/image/dfs/catalog.go

@ -82,13 +82,36 @@ func (d *DFSDisk) loadCatalogue() error {
readOnly: true,
})
})
// Update metadata
d.meta.Set(image.MetaLabel, cat.label)
d.meta.Set(image.MetaTotalBlocks, cat.diskSize)
d.updateMeta()
return nil
}
func (d *DFSDisk) updateMeta() {
cat := &d.catalogue
media := d.media
meta := d.meta
meta.Set(image.MetaSectorSize, media.Geometry().SectorSize())
meta.Set(image.MetaTrackCount, media.Geometry().TrackCount())
meta.Set(image.MetaLabel, cat.label)
su := 2 // 2 to include the catalogue
// Increment with the actual number of sectors used for each tile
cat.files.ForEach(func(v interface{}) {
_ = (v).(*File).forEachSector(func(_, _ int) error {
su++
return nil
})
})
meta.Set(image.MetaTotalBlocks, cat.diskSize)
meta.Set(image.MetaUsedBlocks, su)
meta.Set(image.MetaUsedBlockPercent, 100*su/cat.diskSize)
meta.Set(image.MetaFreeBlocks, cat.diskSize-su)
}
// Read a string from an array.
// Valid characters are the printable ASCII characters between &20 and &7E inclusive,
// except . : " # * and space

8
disktool/image/dfs/disk.go

@ -25,11 +25,9 @@ func (s SectorAddress) TrackSectorID() image.TrackSectorID {
func (d *DFSDisk) Load(filename string) error {
d.media.SetFilename(filename)
err := d.media.Load()
/*
if err == nil {
err = d.loadDirectory()
}
*/
if err == nil {
err = d.loadCatalogue()
}
return err
}

11
disktool/image/dfs/ssd.go

@ -42,12 +42,17 @@ func dfsSectorCount(_ image.TrackID) image.SectorID {
// NewD64 returns a blank 35 track D64 image
func (d *SSD) CreateImage() image.Image {
meta := image.NewMeta()
meta.Set(image.MetaImage, d.Name())
meta.Set(image.MetaFormat, d.Desc())
meta.Set(image.MetaSides, 1)
return &DFSDisk{
media: image.CreateMedia(dfs80Geometry),
meta: image.NewMeta(),
media: image.CreateMedia(dfs80Geometry),
meta: meta,
directoryManager: newDirectoryManager(),
catalogue: Catalogue{
files: util.NewList(),
},
directoryManager: newDirectoryManager(),
}
}

6
disktool/image/meta.go

@ -39,11 +39,12 @@ func MetaInt(v interface{}, d int) int {
const (
MetaMountPoint = iota // The mount point, not used by image
MetaFilename // The Image filename
MetaLabel // The Image label
MetaImage // The type of this image, e.g. "d64" - required
MetaFormat // The format of this image, e.g. "1541 C64" - required
MetaSides // Number of sides on the disk
MetaSectorSize // Sector size in bytes
MetaTrackCount // Number of tracks
MetaLabel // The Image label
MetaDiskID // Disk ID
MetaDiskType // Disk Type
MetaDosType // Disk DOS type
@ -59,11 +60,12 @@ const (
var metaLabels = []string{
"Mount point",
"Filename",
"Disk Label",
"Media Type",
"Media Format",
"Sides",
"Sector Size",
"Track Count",
"Disk Label",
"Disk ID",
"Disk Type",
"DOS Type",

7
xvfb-startup.sh

@ -0,0 +1,7 @@
#!/bin/bash
Xvfb :99 -ac -screen 0 "$XVFB_RES" -nolisten tcp $XVFB_ARGS &
XVFB_PROC=$!
sleep 1
export DISPLAY=:99
"$@"
kill $XVFB_PROC
Loading…
Cancel
Save