-
Notifications
You must be signed in to change notification settings - Fork 0
/
x.sh
executable file
·94 lines (74 loc) · 1.36 KB
/
x.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
SRC="$1"
shift
OUT="${SRC%.*}"
EXT="${SRC##*.}"
INPUT="${SRC%.*}.in"
FLAG="$@"
case ${EXT} in
swift)
swiftc ${SRC}
if [[ -f "${INPUT}" ]]; then
./${OUT} < ${INPUT}
else
./${OUT}
fi
if [[ "${FLAG}" != *"--no-clean"* ]]; then
rm -f ${OUT}
fi
;;
c)
gcc -Wall -Werror -std=c11 -o ${OUT} ${SRC}
if [[ -f "${INPUT}" ]]; then
./${OUT} < ${INPUT}
else
./${OUT}
fi
if [[ "${FLAG}" != *"--no-clean"* ]]; then
rm -f ${OUT}
fi
;;
cpp | c++ | cxx)
g++ -Wall -Werror -std=c++2a -o ${OUT} ${SRC}
if [[ -f "${INPUT}" ]]; then
./${OUT} < ${INPUT}
else
./${OUT}
fi
if [[ "${FLAG}" != *"--no-clean"* ]]; then
rm -f ${OUT}
fi
;;
java)
javac ${SRC}
if [[ -f "${INPUT}" ]]; then
java -cp . ${OUT} < ${INPUT}
else
java -cp . ${OUT}
fi
if [[ "${FLAG}" != *"--no-clean"* ]]; then
rm -f "${OUT}.class"
fi
;;
rs)
rustc -O ${SRC}
if [[ -f "${INPUT}" ]]; then
./${OUT} < ${INPUT}
else
./${OUT}
fi
if [[ "${FLAG}" != *"--no-clean"* ]]; then
rm -f ${OUT}
fi
;;
py)
if [[ -f "${INPUT}" ]]; then
python3 ${SRC} < ${INPUT}
else
python3 ${SRC}
fi
;;
*)
echo "Unsupported file type: ${EXTENSION}"
;;
esac