aboutsummaryrefslogtreecommitdiff
path: root/src/tools/automap.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/automap.sh')
-rwxr-xr-xsrc/tools/automap.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tools/automap.sh b/src/tools/automap.sh
index ff559ac..b4aceb7 100755
--- a/src/tools/automap.sh
+++ b/src/tools/automap.sh
@@ -35,8 +35,18 @@ lay() { # $1 = genome slot, or empty for the preset's own
$CC -O1 -w -fwrapv src/tools/zc0.c -I"$O/map" -Isrc/core -o "$ZC0"
$CC -O1 -w -fwrapv src/tools/mkgenome.c -I"$O/map" -o "$O/.mkgenome"
}
+# the files after the map's own. a run-only image gets line tables for its program (so a fault
+# prints a backtrace): zc0 reads the comment //:lines NAME as "from here on, file NAME, count
+# its lines from the next one". the files under src/ are the runtime's and have none.
+feed() {
+ local f
+ for f in "$@"; do
+ if [ "$P" = run ]; then case "$f" in src/*) ;; *) printf '\n//:lines %s\n' "$f" ;; esac; fi
+ cat "$f"
+ done
+}
build() {
- if [ -f "$O/map/compiler.zc" ]; then cat "$O/map/rt.zc" src/core/core.zc "$O/map/compiler.zc" "$@"; else cat "$O/map/rt.zc" src/core/core.zc "$@"; fi | "$ZC0" > "$O/image.bin"
+ if [ -f "$O/map/compiler.zc" ]; then { cat "$O/map/rt.zc" src/core/core.zc "$O/map/compiler.zc"; feed "$@"; }; else { cat "$O/map/rt.zc" src/core/core.zc; feed "$@"; }; fi | "$ZC0" > "$O/image.bin"
"$O/.mkgenome" < "$O/image.bin" > "$O/genome.bin"
}
# with DOCS=1 the genome is made again with zc0 built for docs (ZC0DOCS), so the
@@ -44,7 +54,7 @@ build() {
# docofs(). the image is the same code either way; the docs are stored after it.
docs() {
$CC -O1 -w -fwrapv -DZC0DOCS src/tools/zc0.c -I"$O/map" -Isrc/core -o "$O/.zc0docs"
- if [ -f "$O/map/compiler.zc" ]; then cat "$O/map/rt.zc" src/core/core.zc "$O/map/compiler.zc" "$@"; else cat "$O/map/rt.zc" src/core/core.zc "$@"; fi | "$O/.zc0docs" > "$O/image.bin"
+ if [ -f "$O/map/compiler.zc" ]; then { cat "$O/map/rt.zc" src/core/core.zc "$O/map/compiler.zc"; feed "$@"; }; else { cat "$O/map/rt.zc" src/core/core.zc; feed "$@"; }; fi | "$O/.zc0docs" > "$O/image.bin"
"$O/.mkgenome" < "$O/image.bin" > "$O/genome.bin"
}
len() { echo $(( $(wc -c < "$1") / 8 )); }