Hi. I'm trying to work with some external dependencies, and I want to make sure that I correctly understand what's going on. I apologise if these questions betray my ignorance or reveal the terribly unsystematic nature of my reading of the Bazel documentation.
Concretely, I'm trying to build some code that depends on
imgui, which in turn depends on
glfw. So, I need to declare dependencies on both of them in my WORKSPACE.bazel:
and
Neither dependency uses Bazel, so I added build overlays under //third_party/{glfw,imgui}. As I understand it, when, say, imgui, is built, the source is fetched and the file //third_party/imgui:imgui.BUILD.bazel is copied to the root of the source. If I need to depend on imgui, I use the label @imgui rather that //third_party/imgui since the build file under third_party is not actually visible. Is that right? Now, I wanted things to be a little bit prettier in my code so I added another build file //third_party/imgui:BUILD.bazel that aliases the imgui build rule so that I can use the label //third_party/imgui in my code:
alias(
name = "imgui",
actual = "@imgui",
)
All good so far.
Question 1: I need to add a dependency on glfw to imgui. I found that I could only do that via @imgui rather than //third_party/imgui. //third_party/imgui works in the code that I'm writing though. It is a minor nit, but I wonder why the discrepancy?
Question 2: Is there a way to only have one build file and still reference imgui as //third_party/imgui without the use of the alias rule?
Thanks, and happy New Year!