modflash: improved error handling when building, small fix in `Makefile`

This commit is contained in:
Ivan Tatarinov 2021-04-17 23:01:32 +03:00
parent 394b0f1f0a
commit bb11a95534
3 changed files with 21 additions and 17 deletions

View File

@ -3,13 +3,13 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Supported environments:
# * GNU/Linux
# * Windows NT (using MinGW/MSYS/Cygwin/WSL)
# * GNU on Linux, FreeBSD etc.
# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL)
include ../sdk/common.mk
.PHONY: all
all: | FLASHempty.ZX1 $(ADDITEM) ./addroms.sh ./addcores.sh roms.txt cores.txt
all: | FLASHempty.ZX1 ./addroms.sh ./addcores.sh roms.txt cores.txt
cp FLASHempty.ZX1 FLASH.ZX1
./addroms.sh
./addcores.sh

View File

@ -7,24 +7,26 @@
i=2
Error() {
echo "ERROR: Exit status $1. Stopped." >&2
exit $1
}
AddCore() {
local f=${3%.*}.tap
echo "Adding core $i: \"$2\" ($3)..."
GenRom $1 "$2" $3 $f || Error $?
AddItem CORE$i $f || Error $?
GenRom $1 "$2" $3 $f
AddItem CORE$i $f
rm -f $f
let i+=1
}
OnError() {
local err=$?
echo "ERROR: Exit status $err. Stopped." >&2
exit $err
}
OnExit() {
rm -f addcores.tmp
}
trap OnError ERR
trap OnExit EXIT
awk -F \; '/^[^#]+/{print "AddCore " $1 " " $2 " " gensub(/\\/, "/", "g", $3)}' cores.txt >addcores.tmp

View File

@ -7,26 +7,28 @@
i=0
Error() {
echo "ERROR: Exit status $1. Stopped." >&2
exit $1
}
AddROM() {
local n=`stat --printf "%s" $3`
local i1=$((i+n/16384-1))
local f=${3%.*}.tap
echo "Adding ROM in slots $i-$i1: \"$2\" ($3)..."
GenRom $1 "$2" $3 $f || Error $?
AddItem ROM $i $f || Error $?
GenRom $1 "$2" $3 $f
AddItem ROM $i $f
rm -f $f
let i=i1+1
}
OnError() {
local err=$?
echo "ERROR: Exit status $err. Stopped." >&2
exit $err
}
OnExit() {
rm -f addroms.tmp
}
trap OnError ERR
trap OnExit EXIT
awk -F \; '/^[^#]+/{print "AddROM " $1 " " $2 " " gensub(/\\/, "/", "g", $3)}' roms.txt >addroms.tmp