How to use a sub-repo/sub-module in another root module #26953
Unanswered
mikael-s-persson
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have basically the following structure:
In order to build any target in lib_b that refers to
@lib_c
, I need to "use" that repo at the top level MODULE.bazel in "lib_a". I have tried to follow and adapt the examples that instruct to use a module extension for this purpose, but to no avail.I have a repro here: mikael-s-persson/bazelbuild_examples@a908775
It has the following files (pretend
lib_a
andlib_b
are two separately hosted packages (git/http)):In relevant part. In theory, the
lib_b/MODULE.bazel
could contain:But that only works to build
lib_b
targets when it is the root module. Trying to build targets inlib_a
that depend on targets fromlib_b
fails becausethird_party/lib_c
is not a subdirectory oflib_a
, obviously.I tried a bunch of different things (lost count), and some of which I noted in the code I linked to above. Nothing seems to work so far. The best I could manage was to create a
relative_repository
rule that is likelocal_repository
but also takes a parent repository label (e.g.,@lib_b
) and assumes the local path to be relative to where that repo is located from the workspace root, but that fails at thelib_a
level because it can't find that directory, although I can definitely see that it exists where bazel it doesn't (in the build cache folder).Long story short, how do I make this work?
How should
lib_b
uselib_c
such thatlib_b
is also buildable as a dependency, not just as the root module?How can
lib_a
make@lib_c
accessible too?Beta Was this translation helpful? Give feedback.
All reactions