39 lines
802 B
Bash
39 lines
802 B
Bash
#!/bin/bash
|
|
|
|
echo 'ninja_dyndep_version = 1'
|
|
|
|
src="$1"
|
|
tgt="${src%%.*}.pdf"
|
|
aux="${src%%.*}.aux"
|
|
log="${src%%.*}.log"
|
|
|
|
# get_tex command
|
|
# returns the argument of \command{...} in the src document
|
|
get_tex() {
|
|
grep "[\]$1" "$src" | sed 's/.*{\(.*\)}.*/\1/'
|
|
}
|
|
|
|
deps=( )
|
|
|
|
if grep -q '\\documentclass{iditacard}' "$src"; then
|
|
deps+=(
|
|
# The class file
|
|
'iditacard.cls'
|
|
|
|
# The artwork
|
|
"images/cards/$(get_tex art).png"
|
|
|
|
# The deckmark
|
|
"images/deck/$(get_tex deck).png"
|
|
)
|
|
fi
|
|
|
|
read -r -a rawimages <<<"$(grep -o '\\includegraphics[^}]*}' "$src" | sed 's/.*{\(.*\)}.*/images\/\1/')"
|
|
deps+=( "${rawimages[@]}" )
|
|
|
|
if [ "${#deps[@]}" -gt 0 ]; then
|
|
echo "build $tgt | $aux $log : dyndep | ${deps[*]}"
|
|
else
|
|
echo "build $tgt | $aux $log : dyndep"
|
|
fi
|