Skip to content

Commit

Permalink
Attempt to build compilation DB in a different way.
Browse files Browse the repository at this point in the history
The rules_compdb approach is not maintained anymore and does
not work for newer bazel or modules bazel.
The hedronvision way of creating a compilation DB was not
working (#2261), so using `bant` now in this approach.
  • Loading branch information
hzeller committed Dec 15, 2024
1 parent 3d821c6 commit 1813282
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
15 changes: 6 additions & 9 deletions .github/bin/make-compilation-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
set -u
set -e

readonly OUTPUT_BASE="$(bazel info output_base)"
BANT=${BANT:-bant}

readonly COMPDB_SCRIPT="${OUTPUT_BASE}/external/rules_compdb/generate.py"
[ -r "${COMPDB_SCRIPT}" ] || bazel fetch ...

python3 "${COMPDB_SCRIPT}"

# Remove a flags observed in the wild that clang-tidy doesn't understand.
sed -i -e 's/-fno-canonical-system-headers//g; s/DEBUG_PREFIX_MAP_PWD=.//g' \
compile_commands.json
if command -v ${BANT} >/dev/null; then
${BANT} compile-flags > compile_flags.txt
else
echo "To create compilation DB, need to have http://bant.build/ installed."
fi
29 changes: 26 additions & 3 deletions .github/workflows/verible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ jobs:
source ./.github/settings.sh
./.github/bin/install-bazel.sh
- name: Get Bant
run: |
# TODO: provide this as action where we simply say with version=...
VERSION="v0.1.9"
STATIC_VERSION="bant-${VERSION}-linux-static-x86_64"
wget "https://github.com/hzeller/bant/releases/download/${VERSION}/${STATIC_VERSION}.tar.gz"
tar xvzf "${STATIC_VERSION}.tar.gz"
mkdir -p bin
ln -sf ../"${STATIC_VERSION}/bin/bant" bin/
bin/bant -V
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/[email protected]
Expand All @@ -95,11 +106,23 @@ jobs:
key: clang-tidy-${{ steps.cache_timestamp.outputs.time }}
restore-keys: clang-tidy-

- name: Build Project genrules
run: |
# Fetch all dependencies and run genrules for bant to see every file
# that makes it into the compile to build comile DB.f
bazel fetch ...
bazel build $(bin/bant -q genrule-outputs | awk '{print $2}') \
$(bin/bant list-targets | grep cc_proto_library | awk '{print $3}') \
//verible/common/analysis:command-file-lexer \
//verible/verilog/parser:verilog-lex \
//verible/verilog/parser:verilog-y \
//verible/verilog/parser:verilog-y-final
- name: Run clang tidy
run: |
echo "::group::Make Compilation DB"
.github/bin/make-compilation-db.sh
wc -l compile_commands.json
BANT=bin/bant .github/bin/make-compilation-db.sh
wc -l compile_flags.txt
echo "::endgroup::"
# For runtime references, use clang-tidy 11 that still has it, everything else: latest.
CLANG_TIDY=clang-tidy-11 ./.github/bin/run-clang-tidy-cached.cc --checks="-*,google-runtime-references" \
Expand Down Expand Up @@ -127,7 +150,7 @@ jobs:
- name: Get Bant
run: |
# TODO: provide this as action where we simply say with version=...
VERSION="v0.1.7"
VERSION="v0.1.9"
STATIC_VERSION="bant-${VERSION}-linux-static-x86_64"
wget "https://github.com/hzeller/bant/releases/download/${VERSION}/${STATIC_VERSION}.tar.gz"
tar xvzf "${STATIC_VERSION}.tar.gz"
Expand Down

0 comments on commit 1813282

Please sign in to comment.