forked from cs6771/comp6771
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_compile_commands.sh
More file actions
executable file
·25 lines (21 loc) · 1.07 KB
/
gen_compile_commands.sh
File metadata and controls
executable file
·25 lines (21 loc) · 1.07 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
#!/bin/bash
set -e
RELEASE_VERSION=0.3.4
DIRECTORY=./bazel-compilation-database-${RELEASE_VERSION}
OPTS="--show_progress --show_loading_progress"
# download compilation database generator if necessary
if [ ! -d "$DIRECTORY" ]; then
curl -L https://github.com/grailbio/bazel-compilation-database/archive/${RELEASE_VERSION}.tar.gz | tar -xz
fi
# generate the compilation database
if command -v clang >/dev/null 2>&1; then
# clang is most useful (clang-tools, clangd etc.) so default to that compiler's flags
CC=clang ./bazel-compilation-database-${RELEASE_VERSION}/generate.sh ${OPTS}
else
# clang is not installed; just in case, though, we'll
# ignore GCC specific warnings so clang-tidy and such can run
./bazel-compilation-database-${RELEASE_VERSION}/generate.sh ${OPTS} --copt=-Wno-unknown-warning-option
# remove -fno-canonical-system-headers, as this is unrecognised by clang-tools
# could replace with -no-canonical-prefixes for clang support, but seems to work regardless
sed -i -E 's/\s+-fno-canonical-system-headers\b//g' compile_commands.json
fi