Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create compilation DB using bant from bzlmod. #2317

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .github/bin/make-compilation-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ set -e
BANT=${BANT:-bant}

if [ ! -e bazel-bin ]; then
echo "Before creating compilation DB, need to run bazel build first"
echo "Before creating compilation DB, run bazel build first to fetch deps."
exit 1
fi

if command -v ${BANT} >/dev/null; then
${BANT} compile-flags > compile_flags.txt
bazel run --cxxopt=-std=c++20 @bant//bant:bant -- \
-C $(pwd) compile-flags 2>/dev/null > compile_flags.txt

# Bant does not see yet the flex dependency inside the toolchain
for d in bazel-out/../../../external/*flex*/src/FlexLexer.h ; do
echo "-I$(dirname $d)" >> compile_flags.txt
done
else
echo "To create compilation DB, need to have http://bant.build/ installed or provided in BANT environment variable."
exit 1
fi
# Bant does not see yet the flex dependency inside the toolchain
for d in bazel-out/../../../external/*flex*/src/FlexLexer.h ; do
echo "-I$(dirname $d)" >> compile_flags.txt
done

echo "Now, re-run original build to make all artifacts visible to clang-tidy"
36 changes: 10 additions & 26 deletions .github/workflows/verible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ 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 @@ -106,26 +95,21 @@ jobs:
key: clang-tidy2-${{ steps.cache_timestamp.outputs.time }}
restore-keys: clang-tidy2-

- 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.
bazel build \
//verible/common/analysis:command-file-lexer \
//verible/verilog/parser:verilog-lex \
//verible/verilog/parser:verilog-y \
//verible/verilog/parser:verilog-y-final \
//verible/common/analysis:command-file-lexer_test \
//verible/common/lsp:lsp-text-buffer
bazel build $(bin/bant -q genrule-outputs | awk '{print $2}') \
$(bin/bant list-targets | grep cc_proto_library | awk '{print $3}')

- name: Run clang tidy
run: |
echo "::group::Trigger fetch and preparation"
bazel build -c opt :install-binaries
echo "::endgroup::"

echo "::group::Make Compilation DB"
BANT=bin/bant .github/bin/make-compilation-db.sh
.github/bin/make-compilation-db.sh
cat compile_flags.txt
echo "::endgroup::"

echo "::group::Re-etablish links"
bazel build -c opt :install-binaries
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" \
|| ( cat verible_clang-tidy.out ; exit 1)
Expand Down
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ single_version_override(
bazel_dep(name = "protobuf", version = "24.4")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_proto", version = "6.0.0-rc2")

# To build compilation DB and run build-cleaning
bazel_dep(name = "bant", version = "0.1.11", dev_dependency = True)
Loading