#!/bin/bash # Build and run the direct compiler harness (tests/CompileTest.mod). # # Same two-phase ISO link recipe as tpshell: a single monolithic invocation # trips gm2's pass-3 rollup on a compiler-size program, so generate the module # list first (-fgen-module-list -> /dev/null, rc=1 is expected) and then link # with -fuse-list. set -u D=/home/eric/Projets/Projets-Modula2/MyWork/TP3-comp/shell GM2=/home/eric/bin/Modula2/Gm2/bin/gm2 cd "$D" || exit 9 FLAGS="-fiso" if [ ! -f TextBuf.o ] || [ ! -f Compiler.o ] || [ ! -f Posix.o ] \ || [ TextBuf.mod -nt TextBuf.o ] || [ Compiler.mod -nt Compiler.o ] \ || [ Posix.c -nt Posix.o ] || [ Posix.def -nt Posix.o ]; then echo "building support modules (source newer than object)..." # NB: Posix is a FOR "C" module (Posix.c + Posix.def, no Posix.mod), so it # is not rebuilt here - only TextBuf and Compiler have a .mod to compile. for m in TextBuf Compiler; do $GM2 $FLAGS -c $m.mod >/tmp/ct_c_$m 2>&1 if [ $? -ne 0 ]; then echo "COMPILE_FAIL $m" grep -m5 -E "error:|Please submit" /tmp/ct_c_$m exit 1 fi done echo " support modules rebuilt" fi rm -f tests/ct.lst compiletest $GM2 $FLAGS -fgen-module-list=tests/ct.lst -o /dev/null \ tests/CompileTest.mod TextBuf.o Posix.o Compiler.o >/tmp/ct_p1 2>&1 p1=$? $GM2 $FLAGS -fuse-list=tests/ct.lst -o compiletest \ tests/CompileTest.mod TextBuf.o Posix.o Compiler.o >/tmp/ct_p2 2>&1 p2=$? if [ $p2 -ne 0 ]; then echo "LINK_FAIL p1_rc=$p1 p2_rc=$p2" grep -E "error:|undefined" /tmp/ct_p2 | head -10 exit 1 fi echo "compiletest built (p1_rc=$p1, phase 1 rc=1 is the expected rollup)" FX=${1:-tests/fixtures} ls "$FX"/*.pas 2>/dev/null | ./compiletest