hedronvision / bazel-compile-commands-extractor

Goal: Enable awesome tooling for Bazel users of the C language family.
Other
696 stars 112 forks source link

Can't exclude headers - probably user error #224

Open PSmithsonp4 opened 1 month ago

PSmithsonp4 commented 1 month ago

Hi,

I doubt this is a bug. I'm very new to Bazel and have probably done something wrong.

I've got a "hello world" project with just one source file - main.cc. I edited MODULE.bazel as per the instructions and now I get a compile_commands.json when I do _bazel run @hedron_compile_commands//:refreshall. I'd like that file to only contain "main.cc" but there's 178 header files. I'm trying to use exclude_headers but I must have done something wrong. This is my BUILD file -

load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")

refresh_compile_commands(
    name = "refresh_compile_commands",
    exclude_headers = "all",
)

cc_binary(
    name = "main",
    srcs = ["main.cc"],
)

I do _bazel run @hedron_compile_commands//:refreshall again. I still have 179 files in the compile_commands.json so I've obviously done something wrong. The instructions recommend adding //BUILD but I don't know what that means exactly or if I needed to do it.

Thanks