-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·73 lines (60 loc) · 2.09 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·73 lines (60 loc) · 2.09 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
RPL4_DIR="$SCRIPT_DIR"
BUILD_DIR=build
BUILD_TYPE=Release
JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)"
BUILD_EXAMPLES=ON
RPL4_LOG_LEVEL=OFF
usage() {
cat <<EOF
Usage: $(basename "$0") [options]
Options:
-b DIR Build directory (default: build)
-t TYPE CMake build type (Release/Debug) (default: ${BUILD_TYPE})
-j N Parallel jobs (default: autodetect)
-e 0|1 Enable building examples (default: 1)
-l LEVEL RPL4 log level (DEBUG, INFO, WARNING, ERROR, FATAL, OFF) (default: ${RPL4_LOG_LEVEL})
-c Clean build directory (rm -rf DIR)
-h Show this help
Example:
./build_all.sh -b build -t Debug -j 8 -e 1 -l INFO
This script configures and builds the project from the repository root.
It enables building the `example/` directory when -e 1 is passed (default).
EOF
}
while getopts ":b:t:j:e:l:ch" opt; do
case ${opt} in
b) BUILD_DIR=${OPTARG} ;;
t) BUILD_TYPE=${OPTARG} ;;
j) JOBS=${OPTARG} ;;
e) if [[ "${OPTARG}" == "0" ]]; then BUILD_EXAMPLES=OFF; else BUILD_EXAMPLES=ON; fi ;;
l) RPL4_LOG_LEVEL=${OPTARG} ;;
c) CLEAN=1 ;;
h) usage; exit 0 ;;
:) echo "Option -${OPTARG} requires an argument."; usage; exit 1 ;;
\?) echo "Invalid option: -${OPTARG}"; usage; exit 1 ;;
esac
done
if [[ "${CLEAN:-0}" == "1" ]]; then
echo "Cleaning build directory: ${BUILD_DIR}"
rm -rf "${RPL4_DIR}/${BUILD_DIR}"
exit 0
fi
echo "Repository root: ${RPL4_DIR}"
echo "Build dir: ${BUILD_DIR}"
echo "Build type: ${BUILD_TYPE}"
echo "Parallel jobs: ${JOBS}"
echo "Build examples: ${BUILD_EXAMPLES}"
echo "RPL4_LOG_LEVEL: ${RPL4_LOG_LEVEL}"
mkdir -p "${RPL4_DIR}/${BUILD_DIR}"
cd "${RPL4_DIR}/${BUILD_DIR}"
cmake -DRPL4_BUILD_EXAMPLE=${BUILD_EXAMPLES} \
-DRPL4_LOG_LEVEL=${RPL4_LOG_LEVEL} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
..
echo "Starting build..."
# Use cmake --build for portability; pass -j for Makefile generators
cmake --build . -- -j ${JOBS}
echo "Build finished. Artifacts are in: ${RPL4_DIR}/${BUILD_DIR}"