-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathm.sh
executable file
·117 lines (116 loc) · 3.5 KB
/
m.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
112
113
114
115
116
117
#!/bin/sh
cd "$(dirname "$0")"
GENERATOR="Unix Makefiles"
set -ex
case "$1" in
"x")
# cross compiling, SYSROOT need to be set
rm -rf "xbuild" && mkdir "xbuild"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_PREFIX_PATH="${SYSROOT}" \
-DCMAKE_FIND_ROOT_PATH="${SYSROOT}" \
-S "." -B "xbuild"
cmake --build "xbuild" --parallel
ls -lh "xbuild/src/kcptun-libev"
;;
"xs")
# cross compile statically linked executable
rm -rf "xbuild" && mkdir "xbuild"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXE_LINKER_FLAGS="-static" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_PREFIX_PATH="${SYSROOT}" \
-DCMAKE_FIND_ROOT_PATH="${SYSROOT}" \
-DLINK_STATIC_LIBS=TRUE \
-S "." -B "xbuild"
cmake --build "xbuild" --parallel
ls -lh "xbuild/src/kcptun-libev"
;;
"r")
# rebuild release
rm -rf "build" && mkdir "build"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-S "." -B "build"
cmake --build "build" --parallel
ls -lh "build/src/kcptun-libev"
;;
"s")
# rebuild statically linked executable
rm -rf "build" && mkdir "build"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXE_LINKER_FLAGS="-static" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DLINK_STATIC_LIBS=TRUE \
-S "." -B "build"
cmake --build "build" --parallel
ls -lh "build/src/kcptun-libev"
;;
"p")
# rebuild for profiling/benchmarking
rm -rf "build" && mkdir "build"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-S "." -B "build"
cmake --build "build" --parallel
objdump -drwS "build/src/kcptun-libev" >"build/src/kcptun-libev.S"
ls -lh "build/src/kcptun-libev"
;;
"posix")
# force POSIX APIs
rm -rf "build" && mkdir "build"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DPOSIX=1 \
-S "." -B "build"
cmake --build "build" --parallel
ls -lh "build/src/kcptun-libev"
;;
"clang")
# rebuild with Linux clang/lld
rm -rf "build" && mkdir "build"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXE_LINKER_FLAGS="--rtlib=compiler-rt -fuse-ld=lld" \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-S "." -B "build"
cmake --build "build" --parallel
# llvm-objdump -drwS "build/src/kcptun-libev" >"build/src/kcptun-libev.S"
ls -lh "build/src/kcptun-libev"
;;
"msys2")
# set SYSROOT for finding dependencies
rm -rf "build" && mkdir "build"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_FIND_ROOT_PATH="${SYSROOT}" \
-DLINK_STATIC_LIBS=TRUE \
-S "." -B "build"
cmake --build "build" --parallel
ls -lh "build/src/kcptun-libev"
;;
"c")
# clean artifacts
rm -rf build xbuild
;;
*)
# default to debug builds
mkdir -p "build"
cmake -G "${GENERATOR}" \
-DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-S "." -B "build"
ln -sf build/compile_commands.json compile_commands.json
cmake --build "build" --parallel
ls -lh "build/src/kcptun-libev"
;;
esac