-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotest.sh
executable file
·111 lines (102 loc) · 2.97 KB
/
dotest.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
DoTestGCC() {
if ! command -v gcc &> /dev/null; then
echo "GCC not found (command \`gcc')"
else
echo "Doing test using GCC"
gcc test.c source/mtnlog.c -iquote include -g -o test -std=gnu99 -Wall -Wextra && ./test
fi
}
DoTestClang() {
if ! command -v clang &> /dev/null; then
echo "Clang not found (command \`clang')"
else
echo "Doing test using Clang"
clang test.c source/mtnlog.c -iquote include -g -o test && ./test
fi
}
DoTestTCC() {
if ! command -v tcc &> /dev/null; then
echo "TCC not found (command \`tcc')"
else
echo "Doing test using TinyCC"
tcc test.c source/mtnlog.c -Iinclude -g -o test && ./test
fi
}
DoTestMinGW32() {
if ! command -v i686-w64-mingw32-gcc &> /dev/null; then
echo "32-bit MinGW not found (command \`i686-w64-mingw32-gcc')"
else
echo "Doing test using 32-bit MinGW"
if ! command -v wine &> /dev/null; then
echo "Wine not found (command \`wine')"
else
i686-w64-mingw32-gcc test.c source/mtnlog.c -iquote include -DWIN32_LEAN_AND_MEAN -g -o test && wine test.exe
fi
fi
}
DoTestMinGW64() {
if ! command -v x86_64-w64-mingw32-gcc &> /dev/null; then
echo "64-bit MinGW not found (command \`x86_64-w64-mingw32-gcc')"
else
echo "Doing test using 64-bit MinGW"
if ! command -v wine &> /dev/null; then
echo "Wine not found (command \`wine')"
else
x86_64-w64-mingw32-gcc test.c source/mtnlog.c -iquote include -DWIN32_LEAN_AND_MEAN -g -o test && wine64 test.exe
fi
fi
}
DoTestICX() {
if ! command -v icx &> /dev/null; then
echo "Intel compiler not found (command \`icx')"
else
echo "Doing test using Intel compiler"
icx -Iinclude test.c source/mtnlog.c -Rno-debug-disables-optimization -g -o test && ./test
fi
}
DoTestAll() {
echo "Doing test using every compiler"
DoTestGCC
DoTestClang
DoTestTCC
DoTestMinGW32
DoTestMinGW64
DoTestICX
}
PrintHelp() {
echo "Usage: $0 <compiler>"
echo " $0 help"
echo "Valid compilers are 'gcc', 'clang', 'tcc', 'tinycc' (alias of 'tcc'), 'mingw' (test using both 'mingw32' and 'mingw64'), 'mingw32', 'mingw64', 'intel', 'icx' (alias of 'intel'), 'all'"
echo "'all' tests using all compilers"
}
if [ "$1" == "" ]; then
DoTestGCC
elif [ "$1" == "gcc" ]; then
DoTestGCC
elif [ "$1" == "clang" ]; then
DoTestClang
elif [ "$1" == "tcc" ]; then
DoTestTCC
elif [ "$1" == "tinycc" ]; then
DoTestTCC
elif [ "$1" == "mingw" ]; then
DoTestMinGW32
DoTestMinGW64
elif [ "$1" == "mingw32" ]; then
DoTestMinGW32
elif [ "$1" == "mingw64" ]; then
DoTestMinGW64
elif [ "$1" == "intel" ]; then
DoTestICX
elif [ "$1" == "icx" ]; then
DoTestICX
elif [ "$1" == "all" ]; then
DoTestAll
elif [ "$1" == "help" ]; then
PrintHelp
else
echo "Unknown compiler '$1'"
PrintHelp
exit 1
fi