forked from bloomberg/blazingmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-darwin.sh
More file actions
executable file
·168 lines (142 loc) · 5.26 KB
/
Copy pathbuild-darwin.sh
File metadata and controls
executable file
·168 lines (142 loc) · 5.26 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env bash
# This script builds BlazingMQ and all of its dependencies.
#
# Required tools:
# - Clang
# - git
# - Homebrew
# - Perl
# - Python3
#
# Options:
# -h, --help Show this help and exit
# --install-deps Install required Homebrew packages before building
set -e
set -u
[ -z "$BASH" ] || shopt -s expand_aliases
print_help() {
cat <<'USAGE'
BlazingMQ Build Script
Usage:
bin/$(basename "$0") [OPTIONS]
Options:
-h, --help Show this help and exit
--install-deps Install required Homebrew packages via Homebrew
What it does:
• Optionally installs prerequisites using Homebrew:
brew install cmake flex bison google-benchmark googletest ninja pkg-config zlib
• Clones third-party deps (bde-tools, bde, ntf-core)
• Builds and installs BDE and NTF
• Configures and builds BlazingMQ
Notes:
• Run this script from the root of the BlazingMQ repository.
USAGE
}
INSTALL_DEPS=false
# Parse args (simple, portable long-option handling)
for arg in "$@"; do
case "$arg" in
-h | --help)
print_help
exit 0
;;
--install-deps)
INSTALL_DEPS=true
;;
*)
echo "Unknown option: $arg" >&2
echo "Try '--help' for usage." >&2
exit 2
;;
esac
done
script_path="bin/$(basename "$0")"
if [ ! -f "$script_path" ] || [ "$(realpath "$0")" != "$(realpath "$script_path")" ]; then
echo 'This script must be run from the root of the BlazingMQ repository.'
exit 1
fi
# :: Optionally install prerequisites :::::::::::::::::::::::::::::::::::::::::
REQ_PKGS=(cmake flex bison google-benchmark googletest ninja pkg-config zlib)
if $INSTALL_DEPS; then
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is required for '--install-deps' but was not found on PATH." >&2
echo "Install Homebrew from https://brew.sh/ and re-run with --install-deps." >&2
exit 1
fi
echo "Installing prerequisites via Homebrew..."
brew install "${REQ_PKGS[@]}"
echo "Prerequisites installed."
fi
# :: Set some initial constants :::::::::::::::::::::::::::::::::::::::::::::::
DIR_ROOT="$(pwd)"
DIR_THIRDPARTY="${DIR_ROOT}/thirdparty"
mkdir -p "${DIR_THIRDPARTY}"
DIR_BUILD="${DIR_BUILD:-${DIR_ROOT}/build}"
mkdir -p "${DIR_BUILD}"
DIR_INSTALL="${DIR_INSTALL:-${DIR_ROOT}}"
mkdir -p "${DIR_INSTALL}"
# :: Clone dependencies :::::::::::::::::::::::::::::::::::::::::::::::::::::::
if [ ! -d "${DIR_THIRDPARTY}/bde-tools" ]; then
git clone --depth 1 --branch 4.35.0.0 https://github.com/bloomberg/bde-tools "${DIR_THIRDPARTY}/bde-tools"
fi
if [ ! -d "${DIR_THIRDPARTY}/bde" ]; then
git clone --depth 1 --branch 4.35.0.0 https://github.com/bloomberg/bde.git "${DIR_THIRDPARTY}/bde"
fi
if [ ! -d "${DIR_THIRDPARTY}/ntf-core" ]; then
git clone --depth 1 --branch 2.6.11 https://github.com/bloomberg/ntf-core.git "${DIR_THIRDPARTY}/ntf-core"
fi
# :: Install required packages ::::::::::::::::::::::::::::::::::::::::::::::::
# Build and install BDE
# Refer to https://bloomberg.github.io/bde/library_information/build.html
PATH="${DIR_THIRDPARTY}/bde-tools/bin:$PATH"
if [ ! -e "${DIR_BUILD}/bde/.complete" ]; then
# Build and install BDE
(
# Suppress warnings from BDE build (scoped to this subshell)
# shellcheck disable=SC2030
export CXXFLAGS="-w -fsized-deallocation" CFLAGS="-w"
cd "${DIR_THIRDPARTY}/bde"
eval "$(bbs_build_env -p clang -u opt_64_cpp17 -b "${DIR_BUILD}/bde" -i "${DIR_INSTALL}")"
bbs_build configure --prefix="${DIR_INSTALL}"
bbs_build build --prefix="${DIR_INSTALL}"
bbs_build install --install_dir="/" --prefix="${DIR_INSTALL}"
eval "$(bbs_build_env unset)"
)
touch "${DIR_BUILD}/bde/.complete"
fi
if [ ! -e "${DIR_BUILD}/ntf/.complete" ]; then
# Build and install NTF
(
# Suppress warnings from NTF build (scoped to this subshell)
# shellcheck disable=SC2031
export CXXFLAGS="-w" CFLAGS="-w"
cd "${DIR_THIRDPARTY}/ntf-core"
./configure --prefix "${DIR_INSTALL}" \
--output "${DIR_BUILD}/ntf" \
--toolchain "${DIR_THIRDPARTY}/bde-tools/BdeBuildSystem/toolchains/darwin/clang-default.cmake" \
--generator Ninja \
--without-warnings-as-errors \
--without-usage-examples \
--without-applications \
--with-zlib \
--without-zstd \
--without-lz4 \
--ufid opt_64_cpp17
make -j 16
make install
)
touch "${DIR_BUILD}/ntf/.complete"
fi
# :: Build the BlazingMQ repo :::::::::::::::::::::::::::::::::::::::::::::::::
export DIR_THIRDPARTY DIR_BUILD DIR_INSTALL
cmake --preset darwin-arm64
cmake --build --preset darwin-arm64
echo broker is here: "${DIR_BUILD}/blazingmq/src/applications/bmqbrkr/bmqbrkr.tsk"
echo to run the broker: "${DIR_BUILD}/blazingmq/src/applications/bmqbrkr/run"
echo tool is here: "${DIR_BUILD}/blazingmq/src/applications/bmqtool/bmqtool.tsk"
SELF_HOST_ADDRESS="127.0.0.1 $(hostname)"
if ! (grep -q "$SELF_HOST_ADDRESS" /etc/hosts >/dev/null); then
echo "Warning: self hostname $(hostname) not found in /etc/hosts"
echo "It might be necessary to add it manually to launch bmqbrkr:"
echo "sudo bash -c \"echo \\\"$SELF_HOST_ADDRESS\\\" >> /etc/hosts\""
fi