#!/bin/sh

# To be run from the code subfolder.

echo "Clean all outputs before we start..."
rm -rf ../solution
rm -rf ../../submission.tar.gz_CHECK
rm ../../submission.tar.gz

echo "Check that compiler binary files exist..."
ls ./lmc
ls ./gqc

echo "Compile the lambdaman.gcc program into solutions folder..."
mkdir -p ../solution
./lmc dotScanner.lm > ../solution/lambdaman.gcc

echo "Compile two of our ghost programs into solutions folder..."
./gqc ghost0.gq > ../solution/ghost0.ghc
./gqc ghost1.gq > ../solution/ghost1.ghc

echo "Prepare a tar file for submission without binaries, hg, or *~ files..."
tar -czf ../../submission.tar.gz --exclude-vcs --exclude='gqc' --exclude='lmc' --exclude='gcc' --exclude='*~' ../

echo "Untar into folder for sanity checks..."
mkdir -p ../../submission.tar.gz_CHECK
tar -xzf ../../submission.tar.gz -C ../../submission.tar.gz_CHECK
ls -haRl ../../submission.tar.gz_CHECK
echo "Does the size look right?"
echo "All the files there?"

echo "Here is the hash:"
sha1sum ../../submission.tar.gz

