Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to use a sub-repo/sub-module in another root module#26953

Unanswered
mikael-s-persson asked this question inQ&A
Discussion options

I have basically the following structure:

  • "lib_a" is a bazel module that depends on "lib_b" (remote, e.g., git repo)
  • "lib_b is a bazel module that depends on "lib_c"
  • "lib_c is a bazel module contained within a sub-folder of "lib_b", i.e., in "third_party/lib_c"

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 (pretendlib_a andlib_b are two separately hosted packages (git/http)):

./lib_b/deps.bzl./lib_b/BUILD.bazel./lib_b/MODULE.bazel./lib_b/third_party/lib_c/BUILD.bazel./lib_b/third_party/lib_c/MODULE.bazel./lib_a/BUILD.bazel./lib_a/MODULE.bazel

In relevant part. In theory, thelib_b/MODULE.bazel could contain:

local_repository(    name = "lib_c",    path = "third_party/lib_c",)

But that only works to buildlib_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 arelative_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 shouldlib_b uselib_c such thatlib_b is also buildable as a dependency, not just as the root module?
How canlib_a make@lib_c accessible too?

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@mikael-s-persson

[8]ページ先頭

©2009-2025 Movatter.jp