23 lines
628 B
Bash
23 lines
628 B
Bash
#!/bin/bash
|
|
|
|
echo 'ninja_dyndep_version = 1'
|
|
|
|
src="$1"
|
|
dst="$2"
|
|
tgt="${dst%%.*}.pdf"
|
|
|
|
temp="$(mktemp -p .)"
|
|
trap 'rm -rf ${temp} ${temp}.*' EXIT INT
|
|
|
|
cp "$src" "$temp.tex"
|
|
xelatex -recorder --shell-escape "$temp.tex" >/dev/null
|
|
|
|
deps="$(awk -v "temp=$temp" -v "repl=${src%%.*}" '/INPUT \./ {gsub(temp,repl,$2); print $2}' < "$temp.fls" | sort | uniq | tr '\n' ' ')"
|
|
outs="$(awk -v "temp=${temp#*/}" -v "repl=${dst%%.*}" '/OUTPUT / {gsub(temp,repl,$2); print $2}' < "$temp.fls" | sort | uniq | tr '\n' ' ')"
|
|
|
|
echo -n "build $tgt"
|
|
[ -z "$outs" ] || echo -n " | $outs"
|
|
echo -n " : dyndep"
|
|
[ -z "$deps" ] || echo -n " | $deps"
|
|
echo
|