Have multiple repositories from a single http_archive

108 views
Skip to first unread message

Geoffrey Martin-Noble

unread,
Jul 1, 2021, 8:10:02 AM7/1/21
to bazel-...@googlegroups.com
I recently added Bazel BUILD files to the llvm-project. Since this build system is not supported by the community in general, it's located in a side directory and users can use a custom repository rule to overlay the build files on top of the source. This is pretty easy to set up as a dep with submodules (example), but with http_archive I haven't figured out a way to avoid having to fetch and unpack the same http_archive twice (example). Caching should mean only the unpacking part gets repeated I think, but it still seems undesirable. Is there a way to have a local_repsitory rule that points to an existing http_archive or something like that? I know I could write a custom starlark rule to do whatever I want, but there's a chicken and egg problem here because I want this to be something that's usable by people using this repository as a dependency.

Part of the fiddliness here is that the custom rule has to be very careful when finding all of its paths. There's some weird hackery I employed to get paths relative to various things by passing in labels pointing to various WORKSPACE files (the label and path resolution in repository rules is super confusing). But it means, for instance, that I can't just load `llvm_configure` from llvm-project-raw because then it can't find the overlay_directories.py script.

Can anyone offer advice on how to achieve this?
Reply all
Reply to author
Forward
0 new messages