-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·49 lines (41 loc) · 1.32 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
#!/bin/bash
# Parse command-line arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--example)
example_name="$2"
shift # past argument
shift # past value
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
mkdir build-out
# Verify example name
if [[ -z $example_name ]]; then
echo "example name not specified. Usage: ./build.sh --example <http/mqtt>"
exit 1
fi
# Verify example name is valid
if [[ $example_name != "http" && $example_name != "mqtt" ]]; then
echo "Invalid example name. Please choose either 'http' or 'mqtt'."
exit 1
fi
# Run CMake configure and build
if [[ $example_name == "http" ]]; then
echo "Building HTTP example"
cmake -DBUILD_EXAMPLE_WEBSTREAM_RPI_HTTP=ON -DGIT_SUBMODULE_UPDATE=ON -S ./ -B ./build-out
cmake --build build-out --target example-w3bstream-client-rpi-http
cp ./build-out/examples/w3bstream-client-rpi-http/example-w3bstream-client-rpi-http w3bstream-example
fi
if [[ $example_name == "mqtt" ]]; then
echo "Building MQTT example"
cmake -DBUILD_EXAMPLE_WEBSTREAM_RPI_MQTT=ON -DGIT_SUBMODULE_UPDATE=ON -S ./ -B ./build-out
cmake --build build-out --target example-w3bstream-client-rpi-mqtt
cp ./build-out/examples/w3bstream-client-rpi-mqtt/example-w3bstream-client-rpi-mqtt w3bstream-example
fi
exit 0