bazel-compile-commands-extractor
                                
                                 bazel-compile-commands-extractor copied to clipboard
                                
                                    bazel-compile-commands-extractor copied to clipboard
                            
                            
                            
                        Includes point to bazel-out instead of project source code.
I am setting up a Bazel build system and integrating clangd into my development workflow. My project structure is as follows:
 | main.cc
 | BUILD
 |-base_types
   | BUILD
   | type-string.hpp
 |-units
   |-external-channel
     | external-channel.hpp
My BUILD file for the main executable looks like this:
cc_binary(
   name = "my_project",
   srcs = ["main.cc"],
   deps = [
       "//base_types:base_types",
       "//units/external_codebase:external_codebase",
       "@libssh//:libssh",
   ],
)
The problem I am encountering is that when I try to follow the links in the includes using clangd, I get redirected to the bazel-out directory instead of the actual project files.
The generated compile-commands.json includes the following flags:
[
 {
   "directory": "...",
   "command": "...",
   "file": "...",
   "arguments": [
     ...
     "-Ibazel-out/k8-fastbuild/bin/base_types/_virtual_includes/base_types",
     "-Ibazel-out/k8-fastbuild/bin/units/external_codebase/_virtual_includes/external_codebase",
     "-isystem",
     "bazel-out/k8-fastbuild/bin/external/libssh/libssh/include",
     ...
   ]
 }
]
I would expect the include paths to point to the actual files in my project, like this:
[
 {
   "directory": "...",
   "command": "...",
   "file": "...",
   "arguments": [
     ...
     "-Ibase_types",
     "-Iunits/external_codebase",
     "-isystem",
     "bazel-out/k8-fastbuild/bin/external/libssh/libssh/include",
     ...
   ]
 }
]
Question: Is there a way to configure Bazel or clangd to get the includes to point to the actual project files instead of the bazel-out directory? Or am I missing something in my setup?