forked from XKCP/XKCP
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildForFeature.sh
executable file
·78 lines (66 loc) · 1.39 KB
/
buildForFeature.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
#!/usr/bin/env bash
if [[ $1 == "" ]]; then
echo "Usage: $0 <feature>"
exit 1
fi
macos () {
fileExt="dylib"
newLine="\n"
}
wsl () {
echo "Ubuntu on Windows"
fileExt="so"
newLine="\r\n"
}
cygwin () {
echo Cygwin
fileExt="so"
newLine="\r\n"
}
mingw () {
echo MinGW
fileExt="so"
newLine="\r\n"
}
linux () {
fileExt="so"
newLine="\n"
}
unknown () {
echo "No idea what OS $(uname -s) is, bailing."
fileExt="so"
newLine="\r\n"
}
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) linux;;
Darwin*) macos;;
CYGWIN*) cygwin;;
MINGW*) mingw;;
*) unknown
esac
if [[ $thisCPU == "" ]]; then
thisCPU=$( echo | gcc -march=native -dM -E - | tr -d '#define' | tr $newLine ' ' )
echo "thisCPU not set, using: $thisCPU"
fi
if [[ "$CFLAGS" == "" || "$ASMFLAGS" == "" ]]; then
echo "CFLAGS and ASMFLAGS must be set."
exit 1
fi
unameOut="$(uname -s)"
fileExt="so"
case "${unameOut}" in
Linux*) fileExt="so";;
Darwin*) fileExt="dylib";;
CYGWIN*) fileExt="so";;
MINGW*) fileExt="so";;
*) unknown
esac
build="make $1/libXKCP.$fileExt"
if [[ $thisCPU == *"$1"* ]]; then
echo "Building & testing $1"
$build && make $1/UnitTests && bin/$1/UnitTests -a
else
echo "Building $1"
$build && echo "No $1 feature found on this CPU, skipping tests."
fi