Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GiulianoWF opened this issue Jun 10, 2024 · 0 comments
Open

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

GiulianoWF opened this issue Jun 10, 2024 · 0 comments

Comments

@GiulianoWF
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant