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

CLion doesn’t sync header files under includes dirs from implementation_deps #5149

Closed
sfc-gh-abalik opened this issue Jul 26, 2023 · 4 comments
Assignees
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: c++ C++ rules integration P3 We're not considering working on this, but happy to review a PR. (No assignee) product: CLion CLion plugin topic: sync Issues related to the sync operation type: bug

Comments

@sfc-gh-abalik
Copy link
Contributor

Description of the bug:

  • Given a cc_library (lib1) that includes another cc_library (lib2) via implementation_deps
  • lib2 exposes lib2.h via includes
cc_library(
    name = "lib2",
    srcs = ["lib2.cc"],
    hdrs = ["include/lib2.h"],
    includes = ["include"],
)

cc_library(
    name = "lib1",
    srcs = ["lib1.cc"],
    hdrs = ["lib1.h"],
    implementation_deps = [
        ":lib2",
    ],
)

cc_binary(
    name = "helloworld",
    srcs = ["main.cc"],
    deps = [
        ":lib1",
    ],
)

CLion will not find lib2.h when syncing files in lib1

# File: lib1.cc

#include "main/lib1.h"
#include "lib2.h"     // => red squiggly here with "'lib2.h' file not found"   

std::string get_string() {
  print_something();  // => function from lib2.h not found  
  return "Hello world";
}

As a result intellisense, go to definition, etc don’t work for lib2.h.

A couple workarounds that fix this

  • Changing from implementation_deps to deps
  • Changing the #include to "include/lib2.h" (e.g. not relying on the include dir)

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Here's a full workspace with the example above. Just open the .bazelproject and look at lib1.cc.
repro.tar.gz

Which Intellij IDE are you using? Please provide the specific version.

CLion 2023.1.2

What programming languages and tools are you using? Please provide specific versions.

C++

What Bazel plugin version are you using?

Bazel for CLion 2023.07.04.0.1-api-version-231

Have you found anything relevant by searching the web?

#3352 seems similar, but for cc_binary

Any other information, logs, or outputs that you want to share?

No response

@sgowroji sgowroji added type: bug product: CLion CLion plugin lang: c++ C++ rules integration topic: sync Issues related to the sync operation awaiting-maintainer Awaiting review from Bazel team on issues labels Jul 26, 2023
@sfc-gh-abalik
Copy link
Contributor Author

I debugged this in the intellij_info_aspect and the problem seems to be that the include paths are not propagated from the implementation_deps to the target here. If I update the aspect to propagate includes from ctx.rule.attr.implementation_deps, then everything works as expected. I can put up a patch for this if it seems like the right fix.

NOTE - For deps this is not needed b/c all include paths are already propagated to downstream targets.

@keertk keertk moved this from Untriaged to Triaged in Bazel IntelliJ Plugin Jul 27, 2023
@tpasternak
Copy link
Contributor

Exactly, so it could be caused because implementation_deps is missing here

"_cc_toolchain", # From cc rules
"_stl", # From cc rules
"malloc", # From cc_binary rules
"_java_toolchain", # From java rules
"deps",
"jars", # from java_import rules

@tpasternak tpasternak added the P3 We're not considering working on this, but happy to review a PR. (No assignee) label Aug 2, 2023
@sfc-gh-abalik
Copy link
Contributor Author

@tpasternak I added a PR for this - #5220. Let me know if this approach makes sense.

@auzhva
Copy link

auzhva commented Oct 20, 2024

Hi,

To up here, it's still relevant. If above code is working, can we consider please adding this to the plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: c++ C++ rules integration P3 We're not considering working on this, but happy to review a PR. (No assignee) product: CLion CLion plugin topic: sync Issues related to the sync operation type: bug
Projects
Development

No branches or pull requests

4 participants