bazel-contrib / bazel-contrib/rules_foreign_cc
LSP unable to access headers from cmake dependencies
- Dominant language
- Starlark
- Stars
- 737
- Forks
- 270
- PR merge metrics
- No merged PRs in 30d
Description
Hello! I have an issue where I am using a
`cmake` rule like so:
```
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
filegroup(
name = "all",
srcs = glob(["**"]),
)
cmake(
name = "foo",
lib_source = ":all",
out_static_libs = ["foo.a"],
generate_args = ["-G Ninja"],
targets = ["foo"],
install = True,
visibility = ["//visibility:public"],
)
```
This builds fine and during the build I'm able to access the headers from foo.
The problem is later my LSP is looking in `bazel-out/k8-fastbuild/bin/external/foo~/foo/include` for the headers
Inside that folder I see broken links like this:
```
ls -la bazel-out/k8-fastbuild/bin/external/foo~/foo/include/foo/foo.h
lrwxrwxrwx 1 tyler tyler 121 Feb 25 17:27 bazel-out/k8-fastbuild/bin/external/foo~/foo/include/foo/foo.h -> /home/tyler/.cache/bazel/_bazel_tyler/HASHSNIPPED/execroot/_main/external/foo~/include/foo/foo.h
```
Is there something I'm doing wrong in the `cmake` rule?
Finally, My rough understanding is that I need to somehow get the headers out of `/home/tyler/.cache/bazel/_bazel_tyler/HASHSNIPPED/execroot/_main/external` and into `/home/tyler/.cache/bazel/_bazel_tyler/HASHSNIPPED/external`
Contributor guide
Research direction
Start with the `cmake` rule from `@rules_foreign_cc//foreign_cc:defs.bzl` and reproduce the `foo` target using the provided `filegroup` and Ninja settings. Inspect the generated headers and their links under `bazel-out/k8-fastbuild/bin/external/foo~/foo/include` and compare them with the reported cache paths. Done means the LSP can resolve headers from the CMake dependency without broken links.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- build-system, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100