Skip to content

Commit

Permalink
make-compilation-db: trigger relevant dependency fetches in script.
Browse files Browse the repository at this point in the history
Move the burden to make sure all dependencies are prefetched
from the caller of make-compilation-db.sh to the script itself.
  • Loading branch information
hzeller committed Jan 7, 2025
1 parent 0a842c8 commit e0d3535
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
37 changes: 28 additions & 9 deletions .github/bin/make-compilation-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,38 @@
set -u
set -e

BANT=${BANT:-bant}
# Which bazel and bant to use can be chosen by environment variables
BAZEL=${BAZEL:-bazel}
BANT=${BANT:-needs-to-be-compiled-locally}

if [ ! -e bazel-bin ]; then
echo "Before creating compilation DB, run bazel build first to fetch deps."
exit 1
BAZEL_OPTS="-c opt --noshow_progress"
if [ "${BANT}" = "needs-to-be-compiled-locally" ]; then
# Bant not given, compile from bzlmod dep. We need to do that before
# we run other bazel rules below as we change the cxxopt flags. Remember
# the full realpath of the resulting binary to be immune to symbolic-link
# switcharoo by bazel.
${BAZEL} build ${BAZEL_OPTS} --cxxopt=-std=c++20 @bant//bant:bant
BANT=$(realpath bazel-bin/external/bant*/bant/bant)
fi

bazel run --cxxopt=-std=c++20 @bant//bant:bant -- \
-C $(pwd) compile-flags 2>/dev/null > compile_flags.txt
# Bazel-build all targets that generate files, so that they can be
# seen in dependency analysis.
${BAZEL} build ${BAZEL_OPTS} $(${BANT} list-targets | \
egrep "genrule|cc_proto_library|genlex|genyacc" | awk '{print $3}')

# Bant does not see yet the flex dependency inside the toolchain
# Some selected targets to trigger all dependency fetches from MODULE.bazel
# verilog-y-final to create a header, kzip creator to trigger build of any.pb.h
# and some test that triggers fetching nlohmann_json and gtest
${BAZEL} build ${BAZEL_OPTS} //verible/verilog/parser:verilog-y-final \
//verible/verilog/tools/kythe:verible-verilog-kythe-kzip-writer \
//verible/common/lsp:json-rpc-dispatcher_test

# bant does not distinguish the includes per file yet, so instead of
# a compile_commands.json, we can just as well create a simpler
# compile_flags.txt which is easier to digest for all kinds of tools anyway.
${BANT} compile-flags 2>/dev/null > compile_flags.txt

# Bant does not see the flex dependency inside the toolchain yet.
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"
17 changes: 5 additions & 12 deletions .github/workflows/verible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ jobs:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
./llvm.sh 17
./llvm.sh 18
- name: Install other Dependencies
run: |
apt -qq -y install clang-tidy-11 clang-tidy-17 build-essential git wget
apt -qq -y install clang-tidy-11 clang-tidy-18 build-essential git wget
source ./.github/settings.sh
./.github/bin/install-bazel.sh
Expand All @@ -97,24 +97,17 @@ jobs:

- name: Run clang tidy
run: |
echo "::group::Trigger fetch and preparation"
bazel build -c opt :install-binaries
echo "::endgroup::"
echo "::group::Make Compilation DB"
.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.
# 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)
CLANG_TIDY=clang-tidy-17 ./.github/bin/run-clang-tidy-cached.cc \
CLANG_TIDY=clang-tidy-18 ./.github/bin/run-clang-tidy-cached.cc \
|| ( cat verible_clang-tidy.out ; exit 1)
- name: 📤 Upload performance graphs
Expand Down

0 comments on commit e0d3535

Please sign in to comment.