-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·106 lines (91 loc) · 3.7 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·106 lines (91 loc) · 3.7 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ---------------------------------------------------------------------------
# Parse arguments
# ---------------------------------------------------------------------------
MODE=""
for arg in "$@"; do
case "$arg" in
--debug) MODE="debug" ;;
*) echo "Usage: ./build.sh [--debug]"
echo " (default) RelWithDebInfo build (build/)"
echo " --debug Debug build with ASAN (build/debug_asan)"
echo ""
echo "For Qt dialog engine: ./install_qt6.sh, then export CMAKE_PREFIX_PATH"
exit 1 ;;
esac
done
# ---------------------------------------------------------------------------
# ccache (use if available)
# ---------------------------------------------------------------------------
CMAKE_CCACHE_ARGS=()
if command -v ccache &>/dev/null; then
CMAKE_CCACHE_ARGS+=("-DCMAKE_C_COMPILER_LAUNCHER=ccache" "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
echo "--- Using ccache ---"
fi
# ---------------------------------------------------------------------------
# Local Qt install (from install_qt6.sh) — enables the Qt dialog engine
# ---------------------------------------------------------------------------
QT_LOCAL_DIR="${SCRIPT_DIR}/.qt/6.8.3/gcc_64"
CMAKE_QT_ARGS=()
if [[ -d "$QT_LOCAL_DIR" ]]; then
CMAKE_QT_ARGS+=("-DCMAKE_PREFIX_PATH=${QT_LOCAL_DIR}")
echo "--- Using local Qt at ${QT_LOCAL_DIR} ---"
fi
# ---------------------------------------------------------------------------
# Build helper
# ---------------------------------------------------------------------------
build_config() {
local build_dir="$1"
local build_type="$2"
local sanitizer="${3:-}" # "asan" or "" (passed before cmake args)
shift 2
[[ -n "$sanitizer" ]] && shift
local extra_args=("$@")
echo ""
echo "=== Building: ${build_dir} (${build_type}) ==="
echo ""
local conan_extra=()
if [[ "$sanitizer" == "asan" ]]; then
conan_extra+=(
"-c" "tools.build:cxxflags=['-fsanitize=address', '-fno-omit-frame-pointer']"
"-c" "tools.build:cflags=['-fsanitize=address', '-fno-omit-frame-pointer']"
"-c" "tools.build:sharedlinkflags=['-fsanitize=address']"
"-c" "tools.build:exelinkflags=['-fsanitize=address']"
)
fi
conan install "$SCRIPT_DIR" --output-folder="$build_dir" --build=missing \
-s build_type="$build_type" -s compiler.cppstd=20 \
-o "plotjuggler_sdk/*:with_tests=True" \
"${conan_extra[@]+"${conan_extra[@]}"}"
# Install dependencies from subdirectory conanfiles (e.g. pj_ported_plugins)
for sub_conan in "$SCRIPT_DIR"/pj_ported_plugins/conanfile.txt; do
if [[ -f "$sub_conan" ]]; then
echo "--- Installing deps from $(dirname "$sub_conan") ---"
conan install "$(dirname "$sub_conan")" --output-folder="$build_dir" --build=missing \
-s build_type="$build_type" -s compiler.cppstd=20 \
"${conan_extra[@]+"${conan_extra[@]}"}"
fi
done
cmake -S "$SCRIPT_DIR" -B "$build_dir" \
-DCMAKE_TOOLCHAIN_FILE="$build_dir/conan_toolchain.cmake" \
-DCMAKE_BUILD_TYPE="$build_type" \
"${CMAKE_CCACHE_ARGS[@]+"${CMAKE_CCACHE_ARGS[@]}"}" \
"${CMAKE_QT_ARGS[@]+"${CMAKE_QT_ARGS[@]}"}" \
"${extra_args[@]+"${extra_args[@]}"}"
cmake --build "$build_dir" -j "$(nproc)"
}
# ---------------------------------------------------------------------------
# Execute builds
# ---------------------------------------------------------------------------
case "${MODE}" in
debug)
build_config "${SCRIPT_DIR}/build/debug_asan" Debug asan \
-DPJ_ASSERT_THROWS=ON \
-DPJ_ENABLE_SANITIZERS=ON
;;
*)
build_config "${SCRIPT_DIR}/build" RelWithDebInfo
;;
esac