-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sh
executable file
·101 lines (83 loc) · 2.29 KB
/
build.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
#!/bin/bash
thisfile=$(readlink --canonicalize "$0")
thisdir=$(dirname "$thisfile")
script_name=$(basename "$0")
DEFAULT_BUILD_TYPE="Release"
usage() {
cat <<EOF
Usage:
$script_name [--fail-on-doc-failure] [--njobs-override <nr>] <build_type>
$script_name --help Display this help
<build_type> 'Debug' or 'Release'; default: $DEFAULT_BUILD_TYPE
EOF
}
FAIL_ON_DOC_FAILURE=""
BUILD_TYPE="$DEFAULT_BUILD_TYPE"
NJOBS_OVERRIDE=""
while [[ "$#" -gt 0 ]]; do
case "$1" in
--help|-h)
usage
exit 0
;;
--fail-on-doc-failure)
FAIL_ON_DOC_FAILURE="yeah"
shift
;;
--njobs-override)
shift
NJOBS_OVERRIDE="$1"
shift
;;
--*|-*)
echo -e "\e[31mUnknown option: \e[1m$1\e[0m" >&2
usage >&2
exit 2
;;
Debug|Release)
if [[ "$#" -gt 1 ]]; then
echo -e "\e[31mRelease type (\e[1m$1\e[22m) must be the last argument\e[0m" >&2
usage >&2
exit 2
fi
BUILD_TYPE="$1"
shift
;;
esac
done
if ! [[ "$NJOBS_OVERRIDE" =~ ^[0-9]*$ ]] ; then
>&2 echo "--njobs-override must be a number"
exit 1
fi
if ! make -C "$thisdir/man"; then
if [[ -z "$FAIL_ON_DOC_FAILURE" ]]; then
echo -e "\e[33mIgnoring failed man page builds; run \e[1m$script_name\e[22m with the \e[1m--fail-on-doc-failure\e[22m option to make such failures fatal.\e[0m"
else
echo -e "\e[31mMaking the man pages failed; dying now in obedience of the \e[1m--fail-on-doc-failure\e[22m option.\e[0m"
exit 3
fi
fi
BUILD_DIR="FlashMQBuild$BUILD_TYPE"
set -eu
if [[ -e "$BUILD_DIR" ]]; then
>&2 echo "$BUILD_DIR already exists. You can run 'make' in it, if you want.
"
else
mkdir "$BUILD_DIR"
fi
nprocs=4
if _nprocs=$(nproc); then
nprocs="$_nprocs"
fi
if [[ -n "$NJOBS_OVERRIDE" ]]; then
nprocs="$NJOBS_OVERRIDE"
fi
cd "$BUILD_DIR"
cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" "$thisdir"
make -j "$nprocs"
cpack
FLASHMQ_VERSION=$(./flashmq --version | grep -Ei 'Flashmq.*version.*' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+[^ ]*')
if command -v linuxdeploy-x86_64.AppImage &> /dev/null; then
linuxdeploy-x86_64.AppImage --create-desktop-file --icon-file "../flashmq.png" --appdir "AppImageDir" --executable "flashmq" --output appimage
mv flashmq-*.AppImage "flashmq-${FLASHMQ_VERSION}-linux-amd64.AppImage"
fi