-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·78 lines (63 loc) · 1.82 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# shellcheck disable=2011
function log { echo "###" "$@"; }
[[ -n $1 ]] \
&& DIR=$1 \
|| DIR=$(dirname "$(readlink -f "$0")")
log "$DIR"
ls | xargs
mkdir -p release
# naming: $project/$sub_project/$main.tex
FILES=$(find . \
-regex "./[^/]+/[^/]+/[^/]+\.tex" \
-not -path "./TeXplates/*" \
| sort \
| grep -v -E "CutoffModularFlow|AreaTTbar|GravitationalEntropy"
)
log "Files:"
echo "$FILES"
for file in $FILES; do
log "Compiling \`$file\` ..."
pathname=$(dirname "$file")
filename=$(basename "$file")
cd "$pathname" || exit 1
# Process magic comment
tex_program=$(
grep -E "^[ \t]*%[ ]*\!TeX[ ]*TS-program[ ]*=[ ]*" "$filename" \
| cut -d '=' -f2 | xargs
)
[[ -z $tex_program ]] && tex_program=xelatex
{
if [[ $tex_program == pdflatex ]] \
|| [[ $tex_program == xelatex ]] \
|| [[ $tex_program == lualatex ]]; then
latexmk \
"-$tex_program" \
-synctex=15 \
-interaction=nonstopmode \
-shell-escape \
"$filename" \
1>/dev/null
else
eval "$tex_program" \
"$filename" \
1>/dev/null
fi
log "Check & release PDF:"
pdf="$(basename "$filename" .tex).pdf"
if ls "$pdf"; then
# shortened name: $project/$sub_project.tex
target="$DIR/release/$(dirname "$pathname")"
mkdir -p "$target"
# shellcheck disable=2015
[[ $USER == bryan ]] \
&& cp -a -v -f "$pdf" "$target/." \
|| mv -v -f "$pdf" "$target/."
fi
} &
cd "$DIR" || exit 1
done
wait
ls -alF release
cp README.md LICENSE release
TZ='Asia/Shanghai' date +'%F %R UTC+8' > release/TIMESTAMP.txt