From 4099b45457104040fd057922f4b4b4236a3def93 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 29 Jun 2015 17:31:38 +0200 Subject: [PATCH] MO-P: mo-create-public --- mop/admin/mo-create-public.sh | 25 +++++++++++------------ mop/public/compile | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 13 deletions(-) create mode 100755 mop/public/compile diff --git a/mop/admin/mo-create-public.sh b/mop/admin/mo-create-public.sh index 9e05d02..bd6aed4 100644 --- a/mop/admin/mo-create-public.sh +++ b/mop/admin/mo-create-public.sh @@ -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 index 0000000..6aa55d5 --- /dev/null +++ b/mop/public/compile @@ -0,0 +1,38 @@ +#!/bin/bash +# Compile script for MO-P +# 2015 - Jan Hadrava + +die() { + echo "$@" >&2 + exit 1 +} + +[ -n "$1" ] || die "Usage: compile []" + +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 -- 2.39.5