Closed ormandi closed 7 months ago
Btw, after rereading what I wrote and poking around my codebase a bit, I realized that the culprit is probably the presence of foreign cc rules here, since I have other third party dependencies (e.g. gtest
(https://github.com/google/googletest) and absl
(https://github.com/abseil/abseil-cpp)) where the underlying build happens using Bazel (and not foreign cc rules) since those are Bazel-based libraries at the first place.
I.e. comparing the example of third_party_lib
library mentioned in my original post, and e.g. my absl
third party dependency; the only difference is that the third_party_lib
uses foreign_cc_rule
's make
whereas absl
does not since it comes with Bazel BUILD
files; and yet VSCode can find the absl
headers, but not the headers corresponding to third_party_lib
.
Also this makes a lot of sense, since I assume foreign cc rule does not exhibit compile commands as those build steps are really described within the underlying build system of the third party package (e.g. make
). Would this be the case?
If so, my follow-up question is this: Is there a workaround here? I.e. is there a way to e.g. manually provide some kind of "fake" build commands for foreign rule cc-based targets to make these targets accessible by VSCode?
I've just found: https://github.com/hedronvision/bazel-compile-commands-extractor/blob/main/ImplementationReadme.md Pretty cool that you're offering these insights.
Ah, no bug here.. Apologies, it is my bad.
Upon finally finding Clangds output on processing compile_commands.json
, I've noticed lines like: bazel-out/darwin-fastbuild/bin/external/third_party_lib/include
. Too bad I usually run everything with -c opt
(unless I actually debug something) due to a bunch of benchmark being present in the codebase requiring optimized code. Of course, -c opt
writes into bazel-out/darwin-opt/...
... So, the mentioned header file was missing under fastbuild.
After building without -c opt
fixed the everything. I may call this out somewhere visible.
Context:
I have a Bazel repository that:
http_archive(...)
, https://bazel.build/rules/lib/repo/http#http_archive)make(...)
, https://bazelbuild.github.io/rules_foreign_cc/0.6.0/make.html)Still I'm getting
Bazel lists no applicable compile commands @third_party_repo//:third_party_lib
error message, and the corresponding headers are not found even I also add test targets (binaries) depending on the third party library.Example output:
Obviously I use things from
third_party_lib
insome_test
.What hapeens?
But in VSCode I'm getting the the "usual"
'third_paty.hpp' file not found clang(pp_file_not_found)
andUse of undeclared identifier 'third_paty_scope' clang(undeclared_var_use)
erros.What is the expectation?
VSCode should know about
third_paty.hpp
andthird_paty_scope
and should not yield error.Notes
cc_import
depending onmake
to put the make output into aCcBuildContext
) potential issue.Any idea how to fix this?