#!/bin/bash
branch=$1
export PATH=$PATH:/usr/lib64/qt4/bin/:/opt/casa/02/bin/
scriptdir="$( cd "$( dirname "$0" )" && pwd )"
echo "Script location: $scriptdir"
echo "Branch: $branch"
echo "Installing casatools"
pip3 install casatools
echo "Cloning CASAViewer"
git clone -q --recursive https://open-bitbucket.nrao.edu/scm/casa/CASAviewer.git
echo "Checking out branch $branch"
cd CASAviewer
git checkout $branch
git submodule update
echo "Getting the latest tag"
sourcedir=`pwd`
version=`python $scriptdir/tagger/lasttag.py -s $sourcedir -b $branch --revisiononly`
echo "Version: $version"
echo "Checking for casatools"
python3 -m casatools --grpc-protopy
echo "Running qmake"
qmake
echo "Running make"
make -j 2
echo "Creating wheel"
make py BUILD=$version
echo "Copying wheel to /wheeldirectory"
cp `find . -name *.whl` /wheeldirectory/