-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·74 lines (68 loc) · 1.75 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
72
73
74
# Default values for CMake flags
CXX_COMPILER="/usr/bin/g++"
ENABLE_STACK_INFO="OFF"
ENABLE_GCOV="OFF"
ENABLE_ASAN="OFF" # Ensure this is defined
GENERATE_COMPILE_COMMANDS="OFF"
ENABLE_PGO_USE="OFF"
ENABLE_PGO_GENERATE="OFF"
# Process command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--clang)
echo "Enabling clang"
CXX_COMPILER="/usr/bin/clang++"
shift
;;
--stack-info)
ENABLE_STACK_INFO="ON"
shift
;;
--asan)
ENABLE_ASAN="ON"
shift
;;
--gcov)
ENABLE_GCOV="ON"
shift
;;
--compile-commands)
GENERATE_COMPILE_COMMANDS="ON"
shift
;;
--pgo-use)
ENABLE_PGO_USE="ON"
shift
;;
--pgo-gen)
ENABLE_PGO_GENERATE="ON"
shift
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
# Create build directory
mkdir -p build
cd build
# Run CMake with specified flags
cmake -D CMAKE_CXX_COMPILER="$CXX_COMPILER" \
-D ENABLE_STACK_INFO="$ENABLE_STACK_INFO" \
-D ENABLE_GCOV="$ENABLE_GCOV" \
-D ENABLE_ASAN="$ENABLE_ASAN" \
-D ENABLE_PGO_USE="$ENABLE_PGO_USE" \
-D ENABLE_PGO_GENERATE="$ENABLE_PGO_GENERATE" \
-D CMAKE_BUILD_TYPE=Release \
$( [ "$GENERATE_COMPILE_COMMANDS" = "ON" ] && echo "-DCMAKE_EXPORT_COMPILE_COMMANDS=1" ) \
..
#-G Ninja \
# Build the project
cmake --build .
#make
# Optionally, symlink compile_commands.json to the project root
if [ "$GENERATE_COMPILE_COMMANDS" = "ON" ]; then
ln -sf "$PWD/compile_commands.json" ../compile_commands.json
fi
cd ..