cold-action-79551
10/15/2024, 5:56 PMBUILD
files. Is it preferred to have multiple files or is it better to have a single BUILD
file per project root. It seems to me that it would be nice to have all of the build information somewhat centralized but the tailor
command seems to drop a lot of small BUILD files in various directories...breezy-twilight-65275
10/16/2024, 8:34 AMBULD
files:
> Target generation means that it is technically possible to put everything in a single BUILD file.
> However, we've found that it usually scales much better to use a single BUILD file per directory. Even if you start with using the defaults for everything, projects usually need to change some metadata over time, like adding a timeout
to a test file or adding dependencies
on resources.
> It's useful for metadata to be as fine-grained as feasible, such as by using the overrides
field to only change the files you need to. Fine-grained metadata is key to having smaller cache keys (resulting in more cache hits), and allows you to more accurately reflect the status of your project. We have found that using one BUILD file per directory encourages fine-grained metadata by defining the metadata adjacent to where the code lives.
Of course the desired balance between centralisation and locality of behavior will be project-dependent.
Note that a lot of boilerplate/repetition that might seem overly verbose especially when distributed across many BUILD
files can be avoided by using field default values or backend configurations (there is some overlap).