entrypoint.sh (905B)
1 #!/bin/sh 2 3 # copy out the main.ml file into the temp dir because otherwise 4 # the build command will leave behind a few artifacts, but I'd rather 5 # have the user code directory be read only. 6 7 cp code/main* /tmp 8 cd /tmp 9 10 if [ -e "main.ml" ]; then 11 ocamlopt nums.cmxa str.cmxa -unsafe main.ml -o /tmp/submission.out 12 fi 13 14 if [ -e "main.cpp" ]; then 15 g++ -static -O2 -std=c++23 main.cpp -o /tmp/submission.out 16 fi 17 18 if [ -e "main.c" ]; then 19 gcc -std=c11 -static -fno-asm -lm -O2 main.c -o /tmp/submission.out 20 fi 21 22 if [ -e "main.py" ]; then 23 echo '#!/usr/bin/env python3' > /tmp/submission.out 24 cat main.py >> /tmp/submission.out 25 fi 26 27 chmod +x /tmp/submission.out 28 29 # ./code:/code ./inputs:/inputs ./outputs:/outputs 30 31 INPUTS=$(ls /inputs) 32 33 for INPUT in $INPUTS; do 34 BASE=${INPUT%.*} 35 cat /inputs/$INPUT | timeout 2 /tmp/submission.out > /outputs/$BASE.out 36 echo $? > /outputs/$BASE.code 37 done