I have a Bazel project with a WORKSPACE
and many packages. WORKSPACE
file is quite huge, so I wonder if it's possible to break it down in separated files and import them.
Is it possible to split up WORKSPACE file in several files?
Asked Answered
You can extract parts of the WORKSPACE
into .bzl
files, and load()
these symbols for variables and functions into the WORKSPACE
.
load("//foo/bar:file.bzl", "function_for_workspace")
function_for_workspace()
See Loading an extension
for more information.
I have exactly the same issue as @Croatian –
Surveying
The thing I did was making two files: one that'll load the
http_archive
and the other one that'll load the rules. Something like that: repo/thirdparty/gRPC/load.bzl
(load archive) and repo/thirdparty/gRPC/rules.bzl
(grpc rules). And then in my WORSKPACE
, I'd call the load_grpc
rule before the grpc_rules
one. But that's a bit contraining cause you gotta have two files for each thirdparty, and it has some issues with archives that embed other archives (like rules_proto_grpc
that embeds rules_proto
) –
Lowenstern © 2022 - 2024 — McMap. All rights reserved.
load
andhttp_archive
calls to play nice sinceload
statements have to come first but won't resolve if run beforehttp_archive
. – Croatian