Build many projects

147 views
Skip to first unread message

Tim Richardson

unread,
Jun 10, 2022, 9:51:20 AM6/10/22
to bazel-discuss
I have a directory which contains many projects, i want to build all projects from the root directory, but i dont want to add build files to every project. Is there anyway to have one build file at the root which can list the sub projects and build each one?

Tiago Quelhas

unread,
Jun 10, 2022, 9:58:14 AM6/10/22
to Tim Richardson, bazel-discuss
Packages may contain subdirectories; there's no requirement that every directory in a workspace must have a BUILD file.

So unless I've misunderstood something, you could define the build rules for all of your projects in a single top-level BUILD file.

On Fri, Jun 10, 2022 at 3:51 PM Tim Richardson <t...@rewire.it> wrote:
I have a directory which contains many projects, i want to build all projects from the root directory, but i dont want to add build files to every project. Is there anyway to have one build file at the root which can list the sub projects and build each one?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/7e435ced-14e3-48f5-aaec-dc0c7272039cn%40googlegroups.com.

Tim Richardson

unread,
Jun 10, 2022, 3:36:12 PM6/10/22
to bazel-discuss
How would i build multiple directories in the same way from one build file? Should i be looking at a glob, macro, something else?

Tiago Quelhas

unread,
Jun 11, 2022, 5:20:05 AM6/11/22
to Tim Richardson, bazel-discuss
If each project must be compiled into a separate binary, declaring a separate binary target per project is unavoidable. But you can still glob all of the project's srcs into a single target.

Do keep in mind that putting many srcs in the same target makes it impossible to compile them in parallel, so large projects will benefit from restructuring into smaller libraries.

You might also want to look into tools that automate the creation of BUILD files. For Go there's Gazelle, but I don't know what the space looks like for other languages (perhaps somebody else can comment).


Reply all
Reply to author
Forward
0 new messages