Skip to content

Includes point to bazel-out instead of project source code. #195

Open
@GiulianoWF

Description

@GiulianoWF

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions