Skip to content

Commit e36c791

Browse files
committed
Build compilation DB in a different way.
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.
1 parent 3d821c6 commit e36c791

File tree

4 files changed

+37
-84
lines changed

4 files changed

+37
-84
lines changed

.github/bin/make-compilation-db.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
set -u
1717
set -e
1818

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

21-
readonly COMPDB_SCRIPT="${OUTPUT_BASE}/external/rules_compdb/generate.py"
22-
[ -r "${COMPDB_SCRIPT}" ] || bazel fetch ...
23-
24-
python3 "${COMPDB_SCRIPT}"
25-
26-
# Remove a flags observed in the wild that clang-tidy doesn't understand.
27-
sed -i -e 's/-fno-canonical-system-headers//g; s/DEBUG_PREFIX_MAP_PWD=.//g' \
28-
compile_commands.json
21+
if command -v ${BANT} >/dev/null; then
22+
${BANT} compile-flags > compile_flags.txt
23+
else
24+
echo "To create compilation DB, need to have http://bant.build/ installed."
25+
exit 1
26+
fi

.github/workflows/verible-ci.yml

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ jobs:
8080
source ./.github/settings.sh
8181
./.github/bin/install-bazel.sh
8282
83+
- name: Get Bant
84+
run: |
85+
# TODO: provide this as action where we simply say with version=...
86+
VERSION="v0.1.9"
87+
STATIC_VERSION="bant-${VERSION}-linux-static-x86_64"
88+
wget "https://github.com/hzeller/bant/releases/download/${VERSION}/${STATIC_VERSION}.tar.gz"
89+
tar xvzf "${STATIC_VERSION}.tar.gz"
90+
mkdir -p bin
91+
ln -sf ../"${STATIC_VERSION}/bin/bant" bin/
92+
bin/bant -V
93+
8394
- name: Create Cache Timestamp
8495
id: cache_timestamp
8596
uses: nanzm/get-time-action@v2.0
@@ -92,14 +103,28 @@ jobs:
92103
path: |
93104
/root/.cache/clang-tidy
94105
/root/.cache/bazel
95-
key: clang-tidy-${{ steps.cache_timestamp.outputs.time }}
96-
restore-keys: clang-tidy-
106+
key: clang-tidy-bant-${{ steps.cache_timestamp.outputs.time }}
107+
restore-keys: clang-tidy-bant
108+
109+
- name: Build Project genrules
110+
run: |
111+
# Fetch all dependencies and run genrules for bant to see every file
112+
# that makes it into the compile to build comile DB.f
113+
bazel fetch ...
114+
bazel build \
115+
//verible/common/analysis:command-file-lexer \
116+
//verible/verilog/parser:verilog-lex \
117+
//verible/verilog/parser:verilog-y \
118+
//verible/verilog/parser:verilog-y-final \
119+
//verible/common/analysis:command-file-lexer_test
120+
bazel build $(bin/bant -q genrule-outputs | awk '{print $2}') \
121+
$(bin/bant list-targets | grep cc_proto_library | awk '{print $3}')
97122
98123
- name: Run clang tidy
99124
run: |
100125
echo "::group::Make Compilation DB"
101-
.github/bin/make-compilation-db.sh
102-
wc -l compile_commands.json
126+
BANT=bin/bant .github/bin/make-compilation-db.sh
127+
cat compile_flags.txt
103128
echo "::endgroup::"
104129
# For runtime references, use clang-tidy 11 that still has it, everything else: latest.
105130
CLANG_TIDY=clang-tidy-11 ./.github/bin/run-clang-tidy-cached.cc --checks="-*,google-runtime-references" \
@@ -127,7 +152,7 @@ jobs:
127152
- name: Get Bant
128153
run: |
129154
# TODO: provide this as action where we simply say with version=...
130-
VERSION="v0.1.7"
155+
VERSION="v0.1.9"
131156
STATIC_VERSION="bant-${VERSION}-linux-static-x86_64"
132157
wget "https://github.com/hzeller/bant/releases/download/${VERSION}/${STATIC_VERSION}.tar.gz"
133158
tar xvzf "${STATIC_VERSION}.tar.gz"
@@ -348,45 +373,6 @@ jobs:
348373
with:
349374
path: kythe_output/*.kzip
350375

351-
MacOsBuildDevTools:
352-
runs-on: macos-latest
353-
steps:
354-
355-
- name: Install Dependencies
356-
run: |
357-
brew install llvm
358-
echo "CLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy" >> $GITHUB_ENV
359-
echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV
360-
361-
- name: Checkout code
362-
uses: actions/checkout@v3
363-
with:
364-
fetch-depth: 0
365-
366-
- name: Create Cache Timestamp
367-
id: cache_timestamp
368-
uses: nanzm/get-time-action@v2.0
369-
with:
370-
format: 'YYYY-MM-DD-HH-mm-ss'
371-
372-
- name: Mount bazel cache
373-
uses: actions/cache@v3
374-
with:
375-
path: |
376-
/private/var/tmp/_bazel_runner
377-
/Users/runner/.cache/clang-tidy
378-
key: clangtidy_macos_${{ steps.cache_timestamp.outputs.time }}
379-
restore-keys: clangtidy_macos_
380-
381-
- name: Test Developer tooling scripts
382-
run: |
383-
# Just a smoke test to make sure developer scripts run on Mac
384-
echo "::group::Make Compilation DB"
385-
.github/bin/make-compilation-db.sh
386-
echo "::endgroup::"
387-
# Quick with no checks to be fast (full tidy run in ClangTidy action)
388-
.github/bin/run-clang-tidy-cached.cc --checks="-*"
389-
390376
MacOsBuild:
391377
runs-on: macos-latest
392378
steps:

WORKSPACE

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,3 @@ http_archive(
155155
"https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz",
156156
],
157157
)
158-
159-
# 2024-02-06
160-
http_archive(
161-
name = "rules_compdb",
162-
sha256 = "70232adda61e89a4192be43b4719d35316ed7159466d0ab4f3da0ecb1fbf00b2",
163-
strip_prefix = "bazel-compilation-database-fa872dd80742b3dccd79a711f52f286cbde33676",
164-
urls = ["https://github.com/grailbio/bazel-compilation-database/archive/fa872dd80742b3dccd79a711f52f286cbde33676.tar.gz"],
165-
)
166-
167-
load("@rules_compdb//:deps.bzl", "rules_compdb_deps")
168-
169-
rules_compdb_deps()

WORKSPACE.bzlmod

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +0,0 @@
1-
workspace(name = "com_google_verible")
2-
3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
#
6-
# External tools needed
7-
#
8-
9-
# 2024-02-06
10-
http_archive(
11-
name = "rules_compdb",
12-
sha256 = "70232adda61e89a4192be43b4719d35316ed7159466d0ab4f3da0ecb1fbf00b2",
13-
strip_prefix = "bazel-compilation-database-fa872dd80742b3dccd79a711f52f286cbde33676",
14-
urls = ["https://github.com/grailbio/bazel-compilation-database/archive/fa872dd80742b3dccd79a711f52f286cbde33676.tar.gz"],
15-
)
16-
17-
load("@rules_compdb//:deps.bzl", "rules_compdb_deps")
18-
19-
rules_compdb_deps()

0 commit comments

Comments
 (0)