From 928504b0e6855cfbc6da8a6c18f9c8b59188e5ae Mon Sep 17 00:00:00 2001 From: Leo Ghafari Date: Thu, 22 Jan 2026 10:19:19 +0900 Subject: [PATCH] Add compile commands generation --- .github/workflows/ci.yml | 3 +++ .gitignore | 3 +++ BUILD.bazel | 8 ++++++++ MODULE.bazel | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dd06b9..72d86c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,9 @@ jobs: - name: Test run: bazel test //... + - name: Refresh Compile Commands + run: bazel build //:refresh_compile_commands + # Only for Linux builds - name: Check Clang Tidy if: ${{ runner.os == 'Linux' && !cancelled() }} diff --git a/.gitignore b/.gitignore index fbd407d..9c9f4d3 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ bazel-app bazel-bin bazel-out bazel-testlogs + + +compile_commands.json \ No newline at end of file diff --git a/BUILD.bazel b/BUILD.bazel index 62f8ba9..b0fc813 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,13 @@ package(default_visibility = ["//visibility:public"]) +load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands") +refresh_compile_commands( + name = "refresh_compile_commands", + targets = { + "//...": "", + }, +) + filegroup( name = "clang-format-config", srcs = [".clang-format"], diff --git a/MODULE.bazel b/MODULE.bazel index 43063b8..209f3a5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -31,3 +31,11 @@ llvm.toolchain( ) use_repo(llvm, "llvm_toolchain") register_toolchains("@llvm_toolchain//:all", dev_dependency = True) + + +bazel_dep(name = "hedron_compile_commands", dev_dependency = True) +git_override( + module_name = "hedron_compile_commands", + commit = "0e990032f3c5a866e72615cf67e5ce22186dcb97", + remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git", +) \ No newline at end of file