]> mj.ucw.cz Git - moe.git/commitdiff
MO-P: mo-create-public
authorroot <root@ceoi01.(none)>
Mon, 29 Jun 2015 15:31:38 +0000 (17:31 +0200)
committerroot <root@ceoi01.(none)>
Mon, 29 Jun 2015 15:31:38 +0000 (17:31 +0200)
mop/admin/mo-create-public.sh
mop/public/compile [new file with mode: 0755]

index 9e05d02abab2b8c08b62e5181bfee1cef3a4878d..bd6aed4fd1dcb67791544b7942fa40feeeeff8bb 100644 (file)
@@ -7,28 +7,27 @@ set -e
 
 echo "Populating $MO_ROOT/public"
 H=`pwd`
+M=`pwd`/../mop
 cd $MO_ROOT/public
-rm -rf bin lib cf
 
+rm -rf cf
 mkdir cf
-for a in eval mop ; do
+for a in mop ; do
        sed '/^\(TEST_USER\|MO_ROOT\)=/s/^/#/' <$H/cf/$a >cf/$a
 done
 
+rm -rf bin
 mkdir bin
-cp -aL $H/bin/{check,submit,compile,status,box,iwrapper} bin/
+cp -aL $M/public/compile bin/
 
-mkdir lib
-cp -aL $H/lib/libeval.sh lib/
+rm -rf lib
 
-if [ -n "$REMOTE_SUBMIT" ] ; then
-       cp -aL $H/bin/{contest,remote-submit,remote-status} bin/
-       cp -aL $H/lib/perl5 lib/
-fi
+rm -rf templater
+cp -aL $M/project/templater.pl bin/
+chmod +x bin/templater.pl
+cp -aL $M/project/templater templater
 
 mkdir -p problems
 
-if [ `id -u` == 0 ] ; then
-       chown -R $EVAL_USER.$EVAL_GROUP .
-       chmod 755 .
-fi
+chown -R root.root .
+chmod -R go=rwX .
diff --git a/mop/public/compile b/mop/public/compile
new file mode 100755 (executable)
index 0000000..6aa55d5
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+# Compile script for MO-P
+# 2015 - Jan Hadrava <had@kam.mff.cuni.cz>
+
+die() {
+       echo "$@" >&2
+       exit 1
+}
+
+[ -n "$1" ] || die "Usage:  compile <source-file> [<options>]"
+
+if [ "${1%.*}" == "$1" ]; then
+       die "Source file must have suffix. Can not compile."
+else
+       src="$1"
+       [ -f "$src" ] || die "File \"$src\" doesn't exist"
+       bin="${1%.*}"
+       ext="${1##*.}"
+
+       shift
+
+       cflags="$@"
+
+       case "$ext" in
+               c)
+                       comm="gcc -static -DEVAL -O2 -std=gnu11 $cflags $src -o ${bin} -lm" ;;
+               cpp)
+                       comm="g++ -static -DEVAL -O2 -std=gnu++11 $cflags $src -o ${bin}" ;;
+               pas)
+                       comm="fpc $cflags -XS -dEVAL -O2 -o${bin} $src";;
+               *)
+                       die "Unknown suffix \"$ext\"."
+       esac
+
+       echo -e '\e[0;32m'"Compiling..."'\e[0m' >&2
+       echo -e '\e[0;33m'"$comm"'\e[0m' >&2
+       $comm && echo -e '\e[0;32m'"Done."'\e[0m' >&2 || die -e '\e[0;31m'"Compilation failed!"'\e[0m'
+fi