Don't add so many unneeded iquote & isystem for every library
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the problem / feature request:
The seemingly unneeded spam of `iquote`s and/or `isystem`s for every lib breaks `clangd` auto-adding includes and is spammy for users to try to read compile commands on the occasions they need to.
Here's a dead simple BUILD file for [fmt](https://github.com/fmtlib/fmt):
```
cc_library(
name = "fmt",
srcs = glob(["src/*.cc"]),
hdrs = glob(["include/fmt/*.h"]),
includes = ["include"],
visibility = ["//visibility:public"],
)
```
Every library which depends on this gets the following isystem and iquotes for it:
```
-iquote external/fmt
-iquote bazel-out/k8-fastbuild/genfiles/external/fmt
-iquote bazel-out/k8-fastbuild/bin/external/fmt
-isystem external/fmt/include
-isystem bazel-out/k8-fastbuild/genfiles/external/fmt/include
-isystem bazel-out/k8-fastbuild/bin/external/fmt/include
```
We can reason that if we were doing this by hand we'd add 1 `isystem` include path for the `include` directory in `fmt` and nothing else, but here we see 6 different paths. What are these all for?
The trouble with this is that the new `clangd` (9.0) is able to auto-add `#include`s depending on what you use in code, and it does that based on the `compile_commands.json`. All the `-iquotes` are leading it to include not-the-intended-path (it should use ``, for example).
### Feature requests: what underlying problem are you trying to solve with this feature?
- Make compile commands more concise and less spammy
- Make clangd auto-add-includes work
### What operating system are you running Bazel on?
Ubuntu 14.04
### What's the output of `bazel info release`?
release 0.22.0
Contributor guide
Research direction
Reproduce the fmt BUILD file and inspect the generated compile_commands.json, focusing on how its iquote and isystem entries are assembled. Done means the compile commands contain fewer redundant paths and clangd chooses for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100