Add a new bazel_file source plugin
Adds a new bazel_file source plugin and adapt the bazel element plugin to be able to use it. Plugin users are expected to explicitly add a source for each resource bazel needs. This is in contrast to the old bazel_source plugin which determines the projects sources automatically by parsing a repository_resolved_file.
Please see CodethinkLabs/bazel-resources/bst-build-bazel!5 (merged) as an example of a buildstream project being ported to use the new plugin. Specifically:
- Building a real bazel project: https://gitlab.com/CodethinkLabs/bazel-resources/bst-build-bazel/-/blob/6569ba5649867ef33b811d1cc06fa086de7099c8/elements/bazel.bst
- Building a simple bazel project
- WORKSPACE: https://gitlab.com/CodethinkLabs/bazel-resources/bst-build-bazel/-/blob/6569ba5649867ef33b811d1cc06fa086de7099c8/elements/bazel-example-workspace.bst
- BZLMOD: https://gitlab.com/CodethinkLabs/bazel-resources/bst-build-bazel/-/blob/6569ba5649867ef33b811d1cc06fa086de7099c8/elements/bazel-example.bst
Why a new plugin
- The existing source plugin relies on a resolved repository file which cannot be reproducibly generated. The new plugin requires users to curate a list of sources in their element file. Future tooling (a hypothetical bazel-to-bst program) may help automating this. Specifying the sources within the element rather than relying on a separate resolved repository file brings bazel elements inline with other element types.
- Due to reliance on a repository file the existing source plugin only supports
repository_rules that look like
http_archive
. The new plugin supports any repository_rules that uses repository_ctx.download (or similar) to download files (which represents a vast majority of repository rules). - The existing plugin uses a distribution directory, the new plugin uses a repository cache. Distribution directories are deprecated and does not support different downloads that share the base name of their URL.
Edited by Harry Sarson