about summary refs log tree commit diff stats
path: root/common/scripts/latex/build.sh
blob: 616a09d9254c25ac781b44307930eae136671dac (plain) (blame)
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
#!/usr/bin/env sh

root="$(git rev-parse --show-toplevel)"

file="$root/%INIT_APPLICATION_NAME.tex"
dst=build

clear=false

for arg in "$@"; do
    case "$arg" in
    "--clear")
        clear=true
        ;;
    --*)
        echo "No such option: '$arg'"
        exit 2
        ;;
    *)
        file="$arg"
        ;;
    esac
done

# find all directories which are not the destination dir or inside it
find "$root" -type d -not -name "$dst" -not -path "./$dst/*" -printf '%P\n' | while IFS= read -r dir; do
    mkdir --parents "$dst/$dir"
done

test "$clear" = true && rm "$dst/${file%tex}out"

latexmk -outdir="$dst" -file-line-error -pdflatex -recorder "$file"