Can Bazel use multiple WORKSPACE files?

4.4k Views Asked by At

Say I'm using a specific CROSSTOOL + toolchain, such as this one, and I want to compile a 3rd party lib such as abseil using that toolchain. Is it possible to do so without modifying the 3rd party lib's WORKSPACE?

If I must modify the workspace, adding a local_repository() rule for the toolchain repo seems reasonable enough. But in this case, I can't get it to work unless I also copy the new_http_archive() entry (which pulls in the actual toolchain binaries) from the toolchain workspace. Needing to add the local_repository's dependencies seems strange to me - shouldn't they get pulled in?

I can make changes to the toolchain repo but would prefer to not have to patch or otherwise modify 3rd party packages. Changing the compiler doesn't seem like something that should require modifying the package that is to be built.

1

There are 1 best solutions below

1
On BEST ANSWER

Needing to add the local_repository's dependencies seems strange to me - shouldn't they get pulled in?

Unfortunately, WORKSPACE files are not recursive so transitive dependencies do not get pulled in automatically. It's a common pattern to pull in the dependencies of your dependencies using a macro, like the go_rules_dependencies() in rules_go. The Bazel subteam managing external repositories has a roadmap entry addressing this here.