Skip to content

Commit

Permalink
Switch to hedronvision/bazel-compile-commands for compilation db.
Browse files Browse the repository at this point in the history
The grailbio/bazel-compilation-database only works for non-bzlmod
while hedronvision works for old and new bazel.

It is slower and more invasive (creating unwanted links and adds
things to .git), so mostly reluctant change for now.
  • Loading branch information
hzeller committed Sep 28, 2024
1 parent d7bc159 commit 4bb35f6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 33 deletions.
14 changes: 1 addition & 13 deletions .github/bin/make-compilation-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -u
set -e

readonly OUTPUT_BASE="$(bazel info output_base)"

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
bazel run @hedron_compile_commands//:refresh_all
8 changes: 8 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ bazel_dep(name = "re2", version = "2023-09-01", repo_name="com_googlesource_code
bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name="com_google_googletest")
bazel_dep(name = "protobuf", version = "26.0", repo_name="com_google_protobuf")
bazel_dep(name = "zlib", version = "1.3.1")

# Make compilation DB
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93",
)
24 changes: 15 additions & 9 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Legacy workspace for bazel5. Will go away.
workspace(name = "com_google_verible")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Expand Down Expand Up @@ -177,14 +178,19 @@ http_archive(
],
)

# 2024-02-06
# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
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"],
name = "hedron_compile_commands",
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93.tar.gz",
strip_prefix = "bazel-compile-commands-extractor-1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93",
sha256 = "044b148b111e17cee61d8c3aaeed42069f7325460382340afca4919f8265094c",
)

load("@rules_compdb//:deps.bzl", "rules_compdb_deps")

rules_compdb_deps()
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")
hedron_compile_commands_setup()
load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive")
hedron_compile_commands_setup_transitive()
load("@hedron_compile_commands//:workspace_setup_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive")
hedron_compile_commands_setup_transitive_transitive()
load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive")
hedron_compile_commands_setup_transitive_transitive_transitive()
11 changes: 0 additions & 11 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,3 @@ load("@com_github_google_rules_install//:setup.bzl", "install_rules_setup")

install_rules_setup()

# 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()

0 comments on commit 4bb35f6

Please sign in to comment.