You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using bazel with bzlmod build my c++ project. I found that bazel add -iquote external/xxx-lib~versionfor all my deps.
From some [discussion](RobotLocomotion/drake#8197), I found that if the lib use hdrs to publish headers, then bazel will add a -iquote to the libs root path.
This seems a bit redundant to me, the other headers in the libs root path should be invisible to the outside world.
Headers in srcs must only be directly included from the files in hdrs and srcs of the library itself.
(To be honest, it seems to me that Headers in srcs should only be directly included by files in srcs.)
Of course I could use #include "src/util/util.h" to circumvent this problem in this example.
But when the number of my dependencies increases rapidly, I still need to care about file path conflicts between this repo and other dependencies, which is obviously not elegant enough.
I don’t know if I missed some key documents. Is there any way to solve this problem?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using bazel with bzlmod build my c++ project. I found that bazel add
-iquote external/xxx-lib~version
for all my deps.From some [discussion](RobotLocomotion/drake#8197), I found that if the lib use hdrs to publish headers, then bazel will add a
-iquote
to the libs root path.This seems a bit redundant to me, the other headers in the libs root path should be invisible to the outside world.
I have write an example to explain this
For my lib
For my bin
The output of my binary is
It is not difficult to find the reason from the compilation command given by bazel.
-iquote external/bazel_remote_test~20231204.1-test-iquote
is before than-Isrc
.so compiler will find the
util/util.h
in the external folder.But from the https://bazel.build/reference/be/c-cpp#hdrs
(To be honest, it seems to me that Headers in
srcs
should only be directly included by files in srcs.)Of course I could use
#include "src/util/util.h"
to circumvent this problem in this example.But when the number of my dependencies increases rapidly, I still need to care about file path conflicts between this repo and other dependencies, which is obviously not elegant enough.
I don’t know if I missed some key documents. Is there any way to solve this problem?
Beta Was this translation helpful? Give feedback.
All reactions