Open cvrebert opened 3 years ago
Strong upvote here. For things like FlatBuffers (or I think even protobuf) that generate one file per table/struct, this is a big issue. The best options I can think of ATM are to write a custom rule and declare the output as a directory using ctx.actions.declare_directory
, write a linter rule enforcing 1 struct per file with a matching name (which many devs are opposed to when there are several small dependent structs that aren't meant to be used separately) or as mentioned, write a custom build script that generates BUILD code, which is rather an ugly hack IMO and invites someone to build a meta-build system by creating space 'above' bazel.
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.
I have re-skimmed the docs. This issue still seems relevant.
I not-infrequently see internal questions about reading files in Starlark or (equivalently) defining targets (e.g. generating library targets or generating tests) based on (non-BUILD/bzl) files. FWICT, the Bazel docs currently don't address this directly. Thus, similar questions get asked and answered, wasting effort. Since these questions are about somewhat obscure corners of Starlark, they don't always get a swift answer. And the quality/detail of example code in the answers varies. Hence these suggestions.
open()
/file()
functions..bzl
file instead; possibly writing a Starlark rule to generate the previous data file.I have no opinion on whether (parts of) these answers belong in an actual "FAQs" page.
Have you found anything relevant by searching the web?