use Cwd 'abs_path';
use File::Basename;
$osname = $^O;
$appname=$ARGV[0];
$branch=$ARGV[1];
$wheeldirectory=$ARGV[2];
if (! defined $appname) {
print("Must provide an application/repository name\n");
exit 1;
}
if (! defined $branch) {
print("Must provide a branch\n");
exit 1;
}
if (! defined $wheeldirectory) {
print("wheeldirectory not provided. Using default /wheeldirectory\n");
$wheeldirectory="/wheeldirectory";
}
$ENV{'PATH'} = $ENV{'PATH'}.':/usr/lib64/qt4/bin/:/opt/casa/02/bin/';
if ( $osname eq "darwin" ) {
$ENV{'PATH'} = $ENV{'PATH'} . ':/opt/casa/03/libexec/qt4/bin:/opt/casa/03/bin:/opt/casa/02/libexec/qt4/bin:/opt/casa/02/bin'
}
print("$ENV{'PATH'}\n");
$scriptdir=dirname(abs_path($0));
print("Script location: $scriptdir\n");
print("Cloning $appname\n");
system"git clone -q --recursive https://open-bitbucket.nrao.edu/scm/casa/$appname.git";
print("Checking out branch $branch");
system("cd $appname && git checkout $branch && git submodule update --recursive");
print("Branch: $branch\n");
print("Running qmake\n");
system("cd $appname && qmake");
print("Running make\n");
system("cd $appname && make -j 2");
print("Creating wheel\n");
system("cd $appname && make py");
print("Copying wheel to $wheeldirectory");
system("cp `find . -name *.whl` $wheeldirectory");