#!/bin/csh -fb
if ! $?UMPLEROOT then
  setenv UMPLEROOT ~/umple
endif
cd $UMPLEROOT/build
if ($OSTYPE == 'cygwin' || $OSTYPE == 'msys' | $OSTYPE == 'win32') then
  set buildenv="wlocal"
else
  set buildenv="local"
endif
echo Doing FIRST build of Umple at $UMPLEROOT using ant -Dmyenv=$buildenv
echo This resets dependencies and is needed only after installing a fresh repo or
echo or to clean up.
echo This should take 1-2 minutes and does not run tests. Do not interrupt. Then do full build
echo You should always have done 'git pull' before running this and resolved conflicts
set logfile="/tmp/umplebuildlog$$.txt"
ant -Dmyenv=$buildenv first-build | tee $logfile

grep -qi failed $logfile
set failedstatus=$status

grep -qi 'Error ' $logfile
if ($status == 0 || $failedstatus == 0) then
  echo "************************"
  echo Script fbumple ended ABNORMALLY at $UMPLEROOT
  echo The word FAILED or Error was found in the above. First Build was NOT SUCCESSFUL.
  echo Build log is at $logfile
else
  rm $logfile
  echo Script fbumple ended normally at $UMPLEROOT
  echo First build complete. You should now do a full build bumple to ensure tests pass.
endif