build.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. # Builds the TopSpeed-V3 sidecar front-end (TSM2) from
  3. # compiler/src/TopSpeed-V3-M2.atg.
  4. #
  5. # The sidecar is a *grammar* deliverable: it parses the historical
  6. # TopSpeed/JPI V3 dialect (pragmas, H/C/B literals, ::=, address
  7. # constructors, CLASS/IS/VIRTUAL, manifest constants, tagless variant
  8. # records, ...). It reuses the V3 frontend frame (scanner/parser/
  9. # compiler .frm) and the V3 SymTab/QbeGen/FileIO modules, so it tracks
  10. # the V3 API -- a small drift patch is applied here if a call site has
  11. # moved on (see the sed lines below).
  12. #
  13. # Output: build/TSM2 (build/ is git-ignored)
  14. set -e
  15. cd "$(dirname "$0")"
  16. ROOT=../..
  17. SRC="$ROOT/compiler/src"
  18. CR="${CR:-$HOME/Projets/Projets-Modula2/MyWork/CocoGm2/CR}"
  19. B=build
  20. rm -rf "$B"; mkdir -p "$B"
  21. cp "$SRC/TopSpeed-V3-M2.atg" "$B/M2.atg"
  22. # The sidecar uses its OWN scanner frame: it adds TopSpeed conditional
  23. # compilation ((*%T cond*) / (*%F cond*) / (*%E*)). V3's own scanner
  24. # (compiler/src/scanner.frm) is left untouched.
  25. cp "$(pwd)/scanner.frm" "$B/scanner.frm"
  26. cp "$SRC/parser.frm" "$SRC/compiler.frm" "$B/"
  27. cp "$SRC/SymTab.def" "$SRC/SymTab.mod" "$SRC/QbeGen.def" "$SRC/QbeGen.mod" \
  28. "$SRC/FileIO.def" "$SRC/FileIO.mod" "$B/"
  29. cd "$B"
  30. echo "=== CR ==="; CRFRAMES="$(pwd)" "$CR" -m -C M2.atg
  31. echo "=== compile ==="
  32. for m in FileIO SymTab QbeGen M2S M2P M2; do
  33. gm2 -fiso -I . -c "$m.mod"
  34. done
  35. echo "=== link ==="
  36. gm2 -fiso -I . -fgen-module-list=modules.lst -o /dev/null \
  37. M2S.o M2P.o FileIO.o SymTab.o QbeGen.o M2.mod
  38. gm2 -fiso -I . -fuse-list=modules.lst -o TSM2 \
  39. M2S.o M2P.o FileIO.o SymTab.o QbeGen.o M2.mod
  40. echo "=== build/TSM2 built ==="