# The Evaluator -- Compile a Solution # (c) 2001 Martin Mares pstart "Locating source... " if [ -f $SDIR/$PROBLEM.c ] ; then SRCN=$PROBLEM.c LANG=C elif [ -f $SDIR/$PROBLEM.cc ] ; then SRCN=$PROBLEM.cc LANG=CXX elif [ -f $SDIR/$PROBLEM.p ] ; then SRCN=$PROBLEM.p LANG=P else pend "NOT FOUND" echo "Source not found." exit 0 fi box-init echo "Source file: $TDIR/$SRCN copied from $SDIR/$SRCN" cp $SDIR/$SRCN $TDIR/$SRCN if [ -n "$EXTRAS" ] ; then echo "Extras: $EXTRAS" for a in $EXTRAS ; do cp $PDIR/$a $TDIR/ ; done fi for a in $SRCN $EXTRAS ; do cp $TDIR/$a $BOXDIR/ ; done echo "Language: $LANG" SRC=$SRCN EXE=$PROBLEM CCMD=COMP_$LANG CCMD="`eval echo ${!CCMD}`" COMP_SANDBOX_OPTS="`eval echo $COMP_SANDBOX_OPTS`" echo "Compiler command: $CCMD" echo "Compiler sandbox options: $COMP_SANDBOX_OPTS" pend "$SRC ($LANG)" pstart "Compiling... " echo "Pre-compile:" ls -Al $BOXDIR if ! $BOXCMD $COMP_SANDBOX_OPTS -- $CCMD 2>$TDIR/compile.out ; then COMPILE_MSG=`cat $TDIR/compile.out` pend "FAILED: $COMPILE_MSG" echo "$COMPILE_MSG" exit 0 fi cat $TDIR/compile.out if [ ! -f $BOXDIR/$PROBLEM ] ; then pend "FAILED: Missing executable file" echo "Missing executable file" exit 0 fi EXE=$TDIR/$PROBLEM cp -a $BOXDIR/$PROBLEM $EXE echo "Compiled OK." ls -Al $BOXDIR echo "Executable file: $EXE" pend "OK"