#!/usr/bin/env bash

GIT_REF=$1
OUTPUT_PATH=$(realpath "$2")

# Checkout in a temp directory so not to clutter anything out
cd "$(mktemp -d)" || exit
git clone ssh://git@git.joshuacoles.me:2222/joshuacoles/compb-dla-model.git .
git checkout "$GIT_REF"

# Clean and then build
make clean && make all

# Copy final executable to the specified output
cp ./run "$OUTPUT_PATH"
