#!/bin/bash

# Written by Erik Hansson, eriha172
#            Linköping University
# Supported OS: MacOS

# Usage: ./run ProjectFile
#
# Pre-conditions:
# * PWD must be the project directory
# * qmake must be in the path

PLATFORM=`uname`

if [ $# == 0 ]; then
    echo No file specified
    exit
elif [[ $PLATFORM != "Darwin"  ]]; then
    echo Only Mac OS is supported at the moment
    exit
fi

FILE=$1

mkdir build

# Building the project
cd build
qmake ../$FILE.pro
make

# Running on Mac
if [[ $PLATFORM == "Darwin" ]]; then
    ./$FILE.app/Contents/MacOS/$FILE
fi;

# Removing the executable files
cd ..
rm -r build
