-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcompile.sh
executable file
·50 lines (46 loc) · 1.36 KB
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
MAXMEM_MB=10
FILENAME=$1
cd "data/$FILENAME"
#set to MAXMEM_MB per process in KB. won't affect processes launched on other nodes (e.g. MPI)
ulimit -v 51200
#ulimit -t 3
#ulimit -t -v
BOOL=true;
case "$2" in
0)
OUT="function"
COMPILE="gcc -pedantic-errors -Wfatal-errors -Werror -Wall -Wextra -Wno-missing-field-initializers -Wwrite-strings -Wno-deprecated -Wno-unused -Wno-variadic-macros -fmessage-length=0 -fstrict-aliasing -fstack-protector-all -Winvalid-pch -D_FORITFY_SOURCE=2 -fPIE -o $OUT"
EXT="c"
RUN="./$OUT"
;;
1)
OUT="function"
COMPILE="g++ -std=c++98 -pedantic-errors -Werror -Wall -Wextra -Wno-missing-field-initializers -Wwrite-strings -Wno-deprecated -Wno-unused -Wno-non-virtual-dtor -Wno-variadic-macros -fmessage-length=0 -ftemplate-depth-128 -fno-merge-constants -fno-nonansi-builtins -fno-gnu-keywords -fno-elide-constructors -fstrict-aliasing -fstack-protector-all -Winvalid-pch -D_FORITFY_SOURCE=2 -fPIE -o $OUT"
EXT="cpp"
RUN="./$OUT"
;;
2)
COMPILE="./../filter_java"
BOOL=false
;;
3)
OUT="function"
COMPILE="gcc -o $OUT"
EXT="s"
RUN="./$OUT"
;;
esac
FILEOUT=file.$EXT
cp $FILENAME.prog $FILEOUT
$COMPILE $FILEOUT &> $FILENAME.comp
if [ -f $OUT ];
then
timeout 5s ../../secure $FILENAME &> $FILENAME.out
val=$?
if [[ "$val" = "124" ]];
then
echo "Runtime exceeded maximum limit (5 seconds)" > $FILENAME.out
fi
fi
rm $FILEOUT