51 lines
1.3 KiB
Bash
51 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
|
|
# TODO: there should be some way to use -recorder to get list of dependencies
|
|
# somehow, though I'd hate to regenerate the whole PDF just to make dependencies
|
|
# note that the snapshot package is even better
|
|
|
|
# NOTE: next thing to try is the create temporary document with
|
|
# \RequirePackage{snapshot} appended to the top, then run xelatex normally and
|
|
# process the output *.dep (or *.log) file to extract the necessary
|
|
# requirements. It may be possible to use additional xelatex flags to reduce
|
|
# unnecessary work
|
|
|
|
echo 'ninja_dyndep_version = 1'
|
|
|
|
src="$1"
|
|
dst="$2"
|
|
tgt="${dst%%.*}.pdf"
|
|
aux="${dst%%.*}.aux"
|
|
log="${dst%%.*}.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/card/$(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
|