Bazel plugin¶
The Bazel plugin can be used with projects that use Bazel.
After a successful build, this plugin copies bazel-bin artifacts into
$CRAFT_PART_INSTALL.
Keys¶
This plugin provides the following unique keys.
bazel-parameters¶
Type: list of strings
Options to pass to bazel build.
bazel-targets¶
Type: list of strings
Default: ["//..."]
Targets to pass to bazel build. By default, all targets are built.
Dependencies¶
The plugin requires Bazel. By default, the plugin installs Bazel through
build-packages, via the bazel-bootstrap package.
You can provide your own Bazel installation by adding a part called bazel-deps
with the installation path and adding after: [bazel-deps] to the
Bazel plugin part. Doing this will cause the plugin to skip the
installation of bazel-bootstrap.
The project must also have a BUILD file that defines the targets to
be built. This file is a configuration for Bazel that tells it
what to build and how.
How it works¶
During the build step, the plugin performs the following actions:
Call
bazel buildwith any parameters defined inbazel-parametersfor the targets defined inbazel-targets.Copy the
bazel-bincontents into$CRAFT_PART_INSTALL.
Example¶
The following snippet declares a part using the bazel plugin, the source referred to
in the part contains a BUILD file at the root and defines the targets to be
built. An alternate build parameter is set using bazel-parameters:
parts:
bazel-part:
source: .
plugin: bazel
bazel-targets:
- //:hello
bazel-parameters:
- --compilation_mode=fastbuild