Add the ledger schema, class router, lint codes, ingest/build pipeline, and three work-tree examples: align derivation, superfig delegation, and supertensor delegation.
62 lines
1.9 KiB
Bash
Executable File
62 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Lint, project the ledger, compile notes. Overfull is logged, not fatal.
|
|
# ./scripts/build.sh --work <dir>
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
WORK=""
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--work|--out) WORK="$2"; shift 2 ;;
|
|
*) echo "usage: build.sh --work DIR" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
[[ -n "$WORK" ]] || { echo "usage: build.sh --work DIR" >&2; exit 2; }
|
|
WORK="$(cd "$WORK" && pwd)"
|
|
NOTES="$WORK/notes"
|
|
[[ -f "$WORK/ledger.yaml" ]] || { echo "no ledger.yaml in $WORK" >&2; exit 2; }
|
|
[[ -f "$NOTES/notes.tex" ]] || { echo "no notes/notes.tex in $WORK" >&2; exit 2; }
|
|
|
|
echo "==> lint"
|
|
"$ROOT/scripts/python" "$ROOT/scripts/lint.py" --work "$WORK"
|
|
|
|
echo "==> render ledger"
|
|
"$ROOT/scripts/python" "$ROOT/scripts/render_ledger.py" --work "$WORK"
|
|
|
|
mkdir -p "$WORK/out"
|
|
echo "==> xelatex"
|
|
(
|
|
cd "$NOTES"
|
|
export TEXINPUTS="$ROOT/assets:$NOTES:"
|
|
xelatex -halt-on-error -interaction=nonstopmode notes.tex >/dev/null
|
|
xelatex -halt-on-error -interaction=nonstopmode notes.tex >/dev/null
|
|
)
|
|
|
|
LOG="$NOTES/notes.log"
|
|
status=0
|
|
if grep -q "Missing character" "$LOG"; then
|
|
echo "!! missing glyphs:" >&2
|
|
grep -m5 "Missing character" "$LOG" >&2
|
|
status=1
|
|
fi
|
|
if grep -qE "LaTeX Warning: (Reference|Citation|There were undefined references|Label\(s\) may have changed)" "$LOG"; then
|
|
if grep -q "undefined" "$LOG"; then
|
|
echo "!! undefined references:" >&2
|
|
grep -m5 "undefined" "$LOG" >&2 || true
|
|
status=1
|
|
fi
|
|
fi
|
|
if grep -q "multiply-defined" "$LOG"; then
|
|
echo "!! multiply-defined labels:" >&2
|
|
grep -m5 "multiply-defined" "$LOG" >&2
|
|
status=1
|
|
fi
|
|
if grep -qE "^(Overfull|Underfull) \\\\[hv]box" "$LOG"; then
|
|
echo "==> overfull/underfull (recorded, not fatal)"
|
|
grep -m5 -E "^(Overfull|Underfull) \\\\[hv]box" "$LOG" || true
|
|
fi
|
|
|
|
cp -f "$NOTES/notes.pdf" "$WORK/out/notes.pdf"
|
|
echo "==> $WORK/out/notes.pdf"
|
|
exit $status
|