#!/usr/bin/env bash
set -eu
OWD=$PWD
INTERMEDIATE_DIR=$OWD/intermediate
export WEB_PUBLIC_DIRECTORY=$OWD/public
HT_LATEX_INTERMEDIATE_DIR=$INTERMEDIATE_DIR/htlatex
PDF_LATEX_INTERMEDIATE_DIR=$INTERMEDIATE_DIR/pdflatex
mkdir -p $HT_LATEX_INTERMEDIATE_DIR
mkdir -p $PDF_LATEX_INTERMEDIATE_DIR
clang src/generate.c -o $INTERMEDIATE_DIR/generate -std=gnu2x -g
rm -rf  || true
cd src/resume
make4ht resume.tex $HT_LATEX_INTERMEDIATE_DIR -d $WEB_PUBLIC_DIRECTORY/resume
pdflatex resume.tex
cp resume.pdf $WEB_PUBLIC_DIRECTORY/resume
cd $OWD
$INTERMEDIATE_DIR/generate
cp -r pdf $WEB_PUBLIC_DIRECTORY/pdf
