]> mj.ucw.cz Git - moe.git/blobdiff - public/compile
Cleaned up handling of SDIR and SRCN.
[moe.git] / public / compile
old mode 100644 (file)
new mode 100755 (executable)
index b640c89..b10ae9d
@@ -2,18 +2,33 @@
 # (c) 2001 Martin Mares <mj@ucw.cz>
 
 set -e
-[ -n "$MO_PUBLIC" -a -d "$MO_PUBLIC" ] || { echo >&2 "MO_PUBLIC not set, giving up." ; exit 1 ; }
-. $MO_PUBLIC/bin/lib
-. $MO_PUBLIC/config
+[ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
+. $MO_ROOT/bin/lib
+. $MO_ROOT/config
 
-[ -n "$1" ] || die "Usage: compile <problem>"
-PROBLEM=$1
-public-setup
-. $PDIR/config
-locate-source
-if compile ; then
-       mv $TDIR/$PROBLEM .
+[ -n "$1" ] || die "Usage: compile (<problem> | <file> [<options>])"
+if [ "${1%%.*}" == "$1" ] ; then
+       # Compiling problem
+       PROBLEM=$1
+       public-setup
+       . $PDIR/config
+       locate-source
+       if compile ; then
+               mv $TDIR/$PROBLEM .
+       else
+               echo >&2
+               sed <log >&2 '1,/^Compiler output:/d;/^Compiler output files:/,$d;/^Exited /d'
+       fi
 else
-       echo >&2
-       sed <log >&2 '1,/^Compiler output:/d;/^Compiler output files:/,$d;/^Exited /d'
+       SRC=$1
+       [ -f $SRC ] || die "$SRC doesn't exist"
+       EXE=${1%%.*}
+       SRCEXT=${1/*./}
+       shift
+       EXTRA_CFLAGS="$@"
+       CCMD=COMP_$SRCEXT
+       [ -n "${!CCMD}" ] || die "Don't know how to compile $SRC"
+       CCMD="`eval echo ${!CCMD}`"
+       echo "$CCMD"
+       $CCMD
 fi