You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.3 KiB
130 lines
3.3 KiB
#!/bin/bash
|
|
. util/util.sh
|
|
|
|
TOGGLEFILE=util/toggle.tex
|
|
CHAPTERFILE=util/chapter.tex
|
|
ALLCHAPTERFILE=util/allchapter.tex
|
|
FILENAMEPREFIX=questionnaire
|
|
SINK=/dev/null
|
|
|
|
VALID_ARGS="abdh"
|
|
BURST=0
|
|
DEBUG=0
|
|
ANNOTATE=0
|
|
|
|
printUsage() {
|
|
printf "A shell wrapper for this questionnaire using latexmk.\n"
|
|
printf "Currently this wrapper supports compiling of the whole script and a burst mode,\nas well as three different <version>s: 'blank', solution, spacing and all which will compile all three in one run.\n\n"
|
|
printf "Usage: ./compile <flags> <version> \n"
|
|
printf "Flags:\n"
|
|
printf " -b Compile in burst mode, i.e. each chapter into a individual file.\n"
|
|
printf " -d Print LuaLaTeX output to terminal.\n"
|
|
printf " -a Annotate all questions and solutions with their base filename.\n"
|
|
printf " -h Print this help message and exit.\n"
|
|
|
|
}
|
|
|
|
|
|
while getopts $VALID_ARGS op
|
|
do
|
|
case ${op} in
|
|
b) BURST=1
|
|
;;
|
|
d) DEBUG=1
|
|
;;
|
|
a) ANNOTATE=1
|
|
;;
|
|
h) printUsage
|
|
info "Exiting..."
|
|
exit
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
set_chapter() {
|
|
printf "$1\n" > $CHAPTERFILE
|
|
}
|
|
|
|
do_annotate() {
|
|
echo "\\annotatetrue" >> $TOGGLEFILE
|
|
}
|
|
|
|
rename() {
|
|
filename="$FILENAMEPREFIX"
|
|
while [ $# -gt 0 ]
|
|
do
|
|
filename="${filename}_$1"
|
|
shift
|
|
done
|
|
cp main.pdf $filename.pdf
|
|
}
|
|
|
|
compile_file() {
|
|
local mode=$1
|
|
local chapter=$2
|
|
if [ $mode = "solution" ]
|
|
then
|
|
echo "\solutiontrue" > $TOGGLEFILE
|
|
[ $ANNOTATE -eq 1 ] && do_annotate
|
|
[ "$#" -eq 1 ] && info "Compiling questionnaire with solutions." || info "Compiling chapter $chapter with solutions."
|
|
[ $DEBUG -eq 1 ] && make pdf || make pdf >> $SINK 2>&1
|
|
rename "with_solutions" $chapter
|
|
elif [ $mode = "spacing" ]
|
|
then
|
|
echo "\spacingtrue" > $TOGGLEFILE
|
|
[ $ANNOTATE -eq 1 ] && do_annotate
|
|
[ "$#" -eq 1 ] && info "Compiling questionnaire with space for your solutions." || info "Compiling chapter $chapter with space for your solutions."
|
|
[ $DEBUG -eq 1 ] && make pdf || make pdf >> $SINK 2>&1
|
|
rename "with_spacing" $chapter
|
|
fi
|
|
}
|
|
|
|
compile_simple_file() {
|
|
[ "$#" -eq 0 ] && info "Compiling whole questionnaire." || info "Compiling chapter $1 from the questionnaire."
|
|
echo "" > $TOGGLEFILE
|
|
[ $ANNOTATE -eq 1 ] && do_annotate
|
|
[ $DEBUG -eq 1 ] && make all || make all >> $SINK 2>&1
|
|
rename $1
|
|
}
|
|
|
|
compile_wrapper() {
|
|
[ $BURST -eq 1 ] && local chapter=$1 && shift
|
|
|
|
option_processed=0
|
|
for arg in "$@"
|
|
do
|
|
[ $arg = "solution" ] && compile_file solution $chapter && option_processed=1
|
|
[ $arg = "spacing" ] && compile_file spacing $chapter && option_processed=1
|
|
[ $arg = "normal" ] && compile_simple_file $chapter && option_processed=1
|
|
[ $arg = "all" ] && compile_simple_file $chapter && compile_file spacing $chapter && compile_file solution $chapter && option_processed=1
|
|
done
|
|
[ $option_processed -eq 0 ] && compile_simple_file $chapter
|
|
}
|
|
|
|
compile_chapter() {
|
|
#for chapter in smtzthree proplogic satsolver ndpred predlogic ndpred smt bdd eqchecking symbenc temporal
|
|
for chapter in smtzthree eqchecking
|
|
do
|
|
set_chapter "\\chapter${chapter}true"
|
|
compile_wrapper "$chapter" "$@"
|
|
done
|
|
}
|
|
|
|
compile_complete() {
|
|
cp $ALLCHAPTERFILE $CHAPTERFILE
|
|
compile_wrapper "$@"
|
|
}
|
|
|
|
main() {
|
|
if [ $BURST -eq 1 ]
|
|
then
|
|
rm -f main.pdf
|
|
compile_chapter "$@"
|
|
else
|
|
compile_complete "$@"
|
|
fi
|
|
}
|
|
|
|
main "$@"
|
|
ls -altr *pdf
|