This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Bzlenv

Setup bazel environment

Rules to create a bazel environment which functions similar to venv

  • Adds bazel-built tools to ${PATH}
  • Exposes each executable under its configured tools dictionary key, independently of the underlying binary’s filename, and retains its runfiles
  • Exports .env

Create env and activate:

. "$(bazel run //tools/bzlenv)"

Activate existing env:

. .bzlenv/bin/activate

Deactivate env:

bzlenv_deactivate

1 - Bzl

Bazel code

1.1 - al_bzlenv_binary

al_bzlenv_binary

load("@com_alwaldend_src//tools/bzlenv/rules:al_bzlenv_binary.bzl", "al_bzlenv_binary")

al_bzlenv_binary(name, activate, tools)

Dev shell binary

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
activateActivation scriptLabeloptional"@com_alwaldend_src//tools/bzlenv/internal/scripts:activate"
toolsTools, keys are tool names, values are tool labelsDictionary: String -> Labeloptional{}