#!/bin/bash

srcfile=$1
if [[ $# -eq 0 ]]
then
  echo "$0: Requires input filename"
  exit 1
elif [[ ! ${srcfile} =~ \.u$ ]]
then
  echo "$0: Unit test file must end in .u"
  exit 1
elif [[ ! -f ${srcfile} ]]
then
  echo "$0: File must exist"
  exit 1
fi
ofile=${srcfile/%\.u/.o}

set -o pipefail
unci-translate $1 | g++ -xc++ --std=c++11 -g -Wall -Wfatal-errors -c -o${ofile} -
