build_tpshell.sh 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # TP3 tpshell - two-phase ISO build, exactly the proven CocoGm2 recipe.
  3. # Phase 1: -fgen-module-list=modules.lst (generates the import closure list)
  4. # Phase 2: -fuse-list=modules.lst (links using that list)
  5. # This avoids gm2's whole-program pass-3 identifier cap on compiler-size programs.
  6. set -u
  7. D=/home/eric/Projets/Projets-Modula2/MyWork/TP3-comp/shell
  8. GM2=/home/eric/bin/Modula2/Gm2/bin/gm2
  9. cd "$D" || exit 9
  10. FLAGS="-fiso"
  11. echo "== compiling each module (isolated -c) =="
  12. for m in Shell Term Posix TextBuf Editor Compiler Runtime ; do
  13. $GM2 $FLAGS -c $m.mod >/tmp/tp_c_$m 2>&1 \
  14. || { echo "COMPILE_FAIL $m"; grep -m3 "error:" /tmp/tp_c_$m; exit 1; }
  15. done
  16. echo "ok: Shell Term Posix TextBuf Editor Compiler Runtime"
  17. echo "== Phase 1: generate module list =="
  18. rm -f modules.lst
  19. $GM2 $FLAGS -fgen-module-list=modules.lst -o /dev/null \
  20. Shell.mod Term.o Posix.o TextBuf.o Editor.o Compiler.o Runtime.o >/tmp/tp_p1 2>&1
  21. echo "p1_rc=$? list: $(tr '\n' ' ' < modules.lst)"
  22. echo "== Phase 2: link with the list =="
  23. rm -f tpshell
  24. $GM2 $FLAGS -fuse-list=modules.lst -o tpshell \
  25. Shell.mod Term.o Posix.o TextBuf.o Editor.o Compiler.o Runtime.o >/tmp/tp_p2 2>&1
  26. echo "p2_rc=$?"
  27. grep -cE "error:|undefined" /tmp/tp_p2
  28. ls -l tpshell 2>/dev/null | awk '{print "tpshell bytes:",$5}'