2023-10-10 22:00:32 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
run_dir=$(pwd)
|
|
|
|
target="output"
|
|
|
|
|
|
|
|
rm -drf "${target}"
|
|
|
|
rm -f "output.zip"
|
|
|
|
|
|
|
|
function build() {
|
|
|
|
local doc_dir="$(dirname "${1}")"
|
|
|
|
local main_file="$(basename "${1}")"
|
|
|
|
local job_name="$(basename "${doc_dir}")"
|
|
|
|
|
|
|
|
echo "|> Building ${job_name}..."
|
|
|
|
cd "${doc_dir}"
|
|
|
|
|
2023-10-10 22:21:42 -07:00
|
|
|
|
|
|
|
# Build handout
|
|
|
|
echo "\\def\\argNoSolutions{1}\\input{main.tex}" | \
|
|
|
|
tectonic \
|
|
|
|
--outfmt pdf \
|
|
|
|
--chatter minimal \
|
|
|
|
-
|
|
|
|
|
|
|
|
stat=$?
|
|
|
|
|
|
|
|
if [[ $stat == 0 ]]; then
|
|
|
|
mv texput.pdf "${OUTPUT}/${job_name}.pdf"
|
|
|
|
else
|
|
|
|
rm -f texput.pdf
|
|
|
|
echo "|> Handout build failed"
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Build solutions
|
|
|
|
echo "\\def\\argYesSolutions{1}\\input{main.tex}" | \
|
|
|
|
tectonic \
|
|
|
|
--outfmt pdf \
|
|
|
|
--chatter minimal \
|
|
|
|
-
|
2023-10-10 22:00:32 -07:00
|
|
|
|
|
|
|
stat=$?
|
|
|
|
|
|
|
|
if [[ $stat == 0 ]]; then
|
2023-10-10 22:21:42 -07:00
|
|
|
mv texput.pdf "${OUTPUT}/${job_name}.sols.pdf"
|
2023-10-10 22:00:32 -07:00
|
|
|
echo ""
|
|
|
|
else
|
2023-10-10 22:21:42 -07:00
|
|
|
rm -f texput.pdf
|
|
|
|
echo "|> Solution build failed"
|
2023-10-10 22:00:32 -07:00
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "${run_dir}"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-10 22:21:42 -07:00
|
|
|
|
|
|
|
|
2023-10-10 22:00:32 -07:00
|
|
|
for d in ./Advanced/*/ ; do
|
|
|
|
doc_dir=$(realpath "${d}")
|
|
|
|
OUTPUT="${run_dir}/${target}/Advanced"
|
|
|
|
mkdir -p "${OUTPUT}"
|
|
|
|
|
|
|
|
build "${doc_dir}/main.tex"
|
|
|
|
done
|
|
|
|
|
2023-10-10 22:21:42 -07:00
|
|
|
|
2023-10-10 22:00:32 -07:00
|
|
|
for d in ./Intermediate/*/ ; do
|
|
|
|
doc_dir=$(realpath "${d}")
|
|
|
|
OUTPUT="${run_dir}/${target}/Intermediate"
|
|
|
|
mkdir -p "${OUTPUT}"
|
|
|
|
|
|
|
|
build "${doc_dir}/main.tex"
|
|
|
|
done
|
|
|
|
|
2023-10-10 22:21:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-10 22:11:31 -07:00
|
|
|
cd "${target}"
|
|
|
|
zip -FSr ../output.zip .
|