You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
4.8 KiB
Bash

#! /usr/bin/bash
#
# Functions to help working with SKL Oberon.
#
SKLDIR=~/adds/oberon/skl/oberon
SYSDIR=$SKLDIR/system
RELEASEDIR=~/adds/oberon/skl/build
QSKL=~/q/oberon-skl
declare -A commands
# -----------------------------------------------------------------------------
print-help () {
echo "============ now"
egrep '^ *-.*\)' now
}
print-error-mess () {
egrep " $4;" $SKLDIR/system/SKLERR.Mod
}
save-error-position () {
echo "$2" > ~/r/vimerrpos
}
no-such-file () {
echo
echo "########### No such file:"
echo $1
echo
cat ~/r/sklmess |egrep 'pos.*err' > ~/r/vimerr
# sleep 1
# cat ~/r/vimerr
print-error-mess $( cat ~/r/vimerr )
save-error-position $( cat ~/r/vimerr )
exit 1
}
need-file () {
test -e $1 || no-such-file $1
}
# -----------------------------------------------------------------------------
link-all () {
cd $SYSDIR
echo $QSKL/modules
for f in $AFS
do
ln -sf $QSKL/modules/$f.Mod .
echo $f
done
echo
}
# -----------------------------------------------------------------------------
setup () {
cd $SKLDIR
source scripts/setup -o $RELEASEDIR >/dev/null
}
compile () {
echo "------------ compile" $1
setup
cd system
need-file $1
skl-skl-oc $1
echo
}
run () {
echo "------------ run " $1
setup
cd system
export COLUMNS=`tput cols`
export LINES=$( tput lines )
export TODAY=$( date +%F )
skl-oberon $1
}
disas () {
echo "------------ disasm" $1
setup
cd system
disasm $1
}
# -----------------------------------------------------------------------------
dotopic () {
local afs=$1
local cmd=$2
clear
if ! [ "$cmd" ]
then
cmd=${commands[$ITERFILE_CONTENTS]}
fi
if ! [ "$cmd" ]
then
cmd=ssqTests.All
fi
echo "----------- $ITERFILE_CONTENTS < $cmd >"
setup
cd $SYSDIR
fs=""
comp=""
for f in $afs
do
if [ $f.Mod -nt $f.Obj ]
then
comp="yes"
fi
if [ $comp ]
then
fs=$fs" $f"
fi
done
if [ "$fs" ]
then
for f in $fs
do
rm -f $f.Obj $f.Sym
done
skl-skl-oc ` for f in $fs; do printf "%s.Mod " $f; done ` |tee ~/r/sklmess
for f in $fs
do
need-file $f.Obj
done
fi
echo
echo
run $cmd
}
# ============================================================================
run-command () {
local command=$1
shift
case $command in
-link-all) link-all ;; # link all our files into SKL/system
-disas) disas $1 ;; # disassemble Obj-file
-ls-CT) cd $SYSDIR; ls CT*Mod ;; # list all tests
-ls-SKL)cd $SYSDIR; ls SKL*Mod ;; # list all SKL
-ls-Mod)cd $SYSDIR; ls *Mod ;; # list all modules
-err) cd $SYSDIR; egrep " $1;" SKLERR.Mod ;; # print errmess
-errcat)cd $SYSDIR; cat SKLERR.Mod ;; # print all errmess
-sep);;
-dda) egrep '^ *PROCEDURE.*\*' $SYSDIR/$1.Mod ;; # dot documentation of API
-ddmm) cd modules; egrep 'MODULE' * |sort ;; # dot documentation: list modules
-ddmi) cd modules; egrep 'IMPORT' * |sort ;; # dot documentation: list imports
-sep);;
-mo) compile $1 ;; # make obj
-run) run $1 ;; # run command
-all) dotopic "$AFS" $1 ;; # compile all, cmd: $1 | commands | ssqTests.All
*) print-help ;; # print help
esac
}
# -----------------------------------------------------------------------------
AFS='
Strings Chars CTStrings
ssqTypes ssqInks ssqInts
ssqDots ssqFiles ssqItems
Fixpoints
Smaps
ssqCsv
ssqDates
ssqTests
ssqLx
Repls
'
commands[Strings.Mod]=CTStrings.All
commands[Repls.Mod]=Repls.Repl
commands[ssqLx.Mod]=ssqLx.Vr
commands[ssqLx.Mod]=ssqLx.Was
commands[ssqLx.Mod]=ssqLx.Go
# default: ssqTests.All
run-command $@
# ============================================================================
# sts-q 2022-Mrz