From a3485a2987360c577a8f26ca1bba5b6f86796db3 Mon Sep 17 00:00:00 2001
From: Henner Zeller
Date: Sun, 15 Dec 2024 10:21:01 -0800
Subject: [PATCH 1/2] Update flex toolchain to latest.
---
MODULE.bazel | 2 +-
WORKSPACE | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/MODULE.bazel b/MODULE.bazel
index 4062608eb..cf7da38b2 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -41,7 +41,7 @@ use_repo(bison, "bison")
register_toolchains("@bison//:toolchain")
# Register flex rules and toolchain.
-bazel_dep(name = "rules_flex", version = "0.2.1")
+bazel_dep(name = "rules_flex", version = "0.3")
flex = use_extension(
"@rules_flex//flex/extensions:flex_repository_ext.bzl",
diff --git a/WORKSPACE b/WORKSPACE
index 1a020608e..0dd3117b8 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -85,9 +85,9 @@ m4_register_toolchains(version = "1.4.18")
http_archive(
name = "rules_flex",
- sha256 = "8929fedc40909d19a4b42548d0785f796c7677dcef8b5d1600b415e5a4a7749f",
+ sha256 = "99393873d4a1bce44853f1cf0c48a34640583cee3d06f2d3d439e12fb1529036",
# flex 2.6.4
- urls = ["https://github.com/jmillikin/rules_flex/releases/download/v0.2.1/rules_flex-v0.2.1.tar.xz"],
+ urls = ["https://github.com/jmillikin/rules_flex/releases/download/v0.3/rules_flex-v0.3.tar.xz"],
)
load("@rules_flex//flex:flex.bzl", "flex_register_toolchains")
@@ -102,7 +102,7 @@ http_archive(
load("@rules_bison//bison:bison.bzl", "bison_register_toolchains")
-bison_register_toolchains()
+bison_register_toolchains(version = "3.3.2")
# We, but also protobuf needs zlib. Make sure we define it first.
http_archive(
From 8c554d2d562a5f6bbaa47181d6737b336f2bc477 Mon Sep 17 00:00:00 2001
From: Henner Zeller
Date: Sat, 14 Dec 2024 21:21:18 -0800
Subject: [PATCH 2/2] 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.
---
.github/bin/make-compilation-db.sh | 22 +++++++---
.github/workflows/verible-ci.yml | 70 ++++++++++++------------------
WORKSPACE | 12 -----
WORKSPACE.bzlmod | 19 --------
4 files changed, 43 insertions(+), 80 deletions(-)
diff --git a/.github/bin/make-compilation-db.sh b/.github/bin/make-compilation-db.sh
index 32b0b264d..4afd8fbc6 100755
--- a/.github/bin/make-compilation-db.sh
+++ b/.github/bin/make-compilation-db.sh
@@ -16,13 +16,21 @@
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 ...
+if [ ! -e bazel-bin ]; then
+ echo "Before creating compilation DB, need to run bazel build first"
+ exit 1
+fi
-python3 "${COMPDB_SCRIPT}"
+if command -v ${BANT} >/dev/null; then
+ ${BANT} compile-flags > compile_flags.txt
-# 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
+ # 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
diff --git a/.github/workflows/verible-ci.yml b/.github/workflows/verible-ci.yml
index 1ef849bfb..dbfb3cf2a 100644
--- a/.github/workflows/verible-ci.yml
+++ b/.github/workflows/verible-ci.yml
@@ -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/get-time-action@v2.0
@@ -95,11 +106,25 @@ 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 \
+ //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
+ 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::Make Compilation DB"
- .github/bin/make-compilation-db.sh
- wc -l compile_commands.json
+ BANT=bin/bant .github/bin/make-compilation-db.sh
+ cat 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" \
@@ -127,7 +152,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"
@@ -348,45 +373,6 @@ jobs:
with:
path: kythe_output/*.kzip
- MacOsBuildDevTools:
- runs-on: macos-latest
- steps:
-
- - name: Install Dependencies
- run: |
- brew install llvm
- echo "CLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy" >> $GITHUB_ENV
- echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV
-
- - name: Checkout code
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: Create Cache Timestamp
- id: cache_timestamp
- uses: nanzm/get-time-action@v2.0
- with:
- format: 'YYYY-MM-DD-HH-mm-ss'
-
- - name: Mount bazel cache
- uses: actions/cache@v3
- with:
- path: |
- /private/var/tmp/_bazel_runner
- /Users/runner/.cache/clang-tidy
- key: clangtidy_macos_${{ steps.cache_timestamp.outputs.time }}
- restore-keys: clangtidy_macos_
-
- - name: Test Developer tooling scripts
- run: |
- # Just a smoke test to make sure developer scripts run on Mac
- echo "::group::Make Compilation DB"
- .github/bin/make-compilation-db.sh
- echo "::endgroup::"
- # Quick with no checks to be fast (full tidy run in ClangTidy action)
- .github/bin/run-clang-tidy-cached.cc --checks="-*"
-
MacOsBuild:
runs-on: macos-latest
steps:
diff --git a/WORKSPACE b/WORKSPACE
index 0dd3117b8..6861e035c 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -155,15 +155,3 @@ http_archive(
"https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz",
],
)
-
-# 2024-02-06
-http_archive(
- name = "rules_compdb",
- sha256 = "70232adda61e89a4192be43b4719d35316ed7159466d0ab4f3da0ecb1fbf00b2",
- strip_prefix = "bazel-compilation-database-fa872dd80742b3dccd79a711f52f286cbde33676",
- urls = ["https://github.com/grailbio/bazel-compilation-database/archive/fa872dd80742b3dccd79a711f52f286cbde33676.tar.gz"],
-)
-
-load("@rules_compdb//:deps.bzl", "rules_compdb_deps")
-
-rules_compdb_deps()
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
index ce71a6995..e69de29bb 100644
--- a/WORKSPACE.bzlmod
+++ b/WORKSPACE.bzlmod
@@ -1,19 +0,0 @@
-workspace(name = "com_google_verible")
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-#
-# External tools needed
-#
-
-# 2024-02-06
-http_archive(
- name = "rules_compdb",
- sha256 = "70232adda61e89a4192be43b4719d35316ed7159466d0ab4f3da0ecb1fbf00b2",
- strip_prefix = "bazel-compilation-database-fa872dd80742b3dccd79a711f52f286cbde33676",
- urls = ["https://github.com/grailbio/bazel-compilation-database/archive/fa872dd80742b3dccd79a711f52f286cbde33676.tar.gz"],
-)
-
-load("@rules_compdb//:deps.bzl", "rules_compdb_deps")
-
-rules_compdb_deps()