-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
71 lines (63 loc) · 2.13 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
#!/usr/bin/env bash
# Undupes: Find duplicate files.
# Copyright (C) 2024 Mmanu Chaturvedi <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# SPDX-License-Identifier: AGPL-3.0
# SPDX-FileCopyrightText: 2024 Mmanu Chaturvedi <[email protected]>
set -euo pipefail
SOURCE_DIR=$PWD
BUILD_DIR=${BUILD_DIR:-$PWD/build}
INSTALL_DIR=$PWD/build/install
CUSTOM_TYPE="${CUSTOM_TYPE:-}"
BUILD_TYPE="${BUILD_TYPE:-Release}"
export CC=/usr/bin/gcc-12
export CXX=/usr/bin/g++-12
declare -a ADDITIONAL_CMAKE_FLAGS=()
if [[ $CUSTOM_TYPE = "gprof" ]]; then
BUILD_TYPE=""
ADDITIONAL_CMAKE_FLAGS=(
-DCMAKE_CXX_FLAGS=-pg
-DCMAKE_EXE_LINKER_FLAGS=-pg
-DCMAKE_SHARED_LINKER_FLAGS=-pg
)
elif [[ $CUSTOM_TYPE = "tsan" ]]; then
BUILD_TYPE="DEBUG"
ADDITIONAL_CMAKE_FLAGS=(
-DCMAKE_CXX_FLAGS="-fsanitize=thread"
-DCMAKE_C_FLAGS="-fsanitize=thread"
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread"
-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=thread"
)
elif [[ $CUSTOM_TYPE = "asan" ]]; then
BUILD_TYPE="DEBUG"
ADDITIONAL_CMAKE_FLAGS=(
-DCMAKE_CXX_FLAGS="-fsanitize=address"
-DCMAKE_C_FLAGS="-fsanitize=address"
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address"
)
fi
cmake \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-S "$SOURCE_DIR" \
-B "${BUILD_DIR}" \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
${ADDITIONAL_CMAKE_FLAGS[@]} \
.
cmake --build $PWD/build
cmake --install $PWD/build
ln -f "$BUILD_DIR/compile_commands.json" "${SOURCE_DIR}"