-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.sh
33 lines (30 loc) · 1.19 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
function compile {
echo "Building" "$1"
cd "$(dirname "$1")"
# for _ in {1..20}; do latexmk -f -xelatex -shell-escape "$(basename "$1")" &> /dev/null; done
for _ in {1..20}; do
cat /dev/null > "$REPOPATH"/latex.log
if ! latexmk -pdf -interaction=nonstopmode -shell-escape "$(basename "$1")" &> "$REPOPATH"/latex.log; then
status="OK"
status="FAILED"
fi
[ "$status" == "FAILED" ] && cat "$REPOPATH"/latex.log && exit 1
done
cd "$REPOPATH"
}
REPOPATH=$(pwd)
for semester_no in {4..7}; do # semester <= 3 are broken, will fix later (never)
SEMESTER="${semester_no}sem"
# if semester is <= 3 then find all .tex files
# if semester is > 3 then find main.tex, final.tex and any .tex files that are deeper than 2 levels
if [ "$semester_no" -le 3 ]; then
find . -wholename "*/$SEMESTER/*.tex" -print0 | while IFS= read -r -d $'\0' file; do
compile "$file"
done
else
find . \( -wholename "*/$SEMESTER/main.tex" -o -wholename "*/$SEMESTER/final.tex" -o -wholename "*/$SEMESTER/*/*.tex" \) -print0 | while IFS= read -r -d $'\0' file; do
compile "$file"
done
fi
done