A command to run during the build, for example, a call to a compiler that takes artifacts as inputs and produces other artifacts as outputs. Includes metadata like the command line arguments, action key, environment variables, and declared input/output artifacts.
See also: Rules documentation
An on-disk cache that stores a mapping of executed actions to the outputs they created. The cache key is known as the action key. A core component for Bazel’s incrementality model. The cache is stored in the output base directory and thus survives Bazel server restarts.
An in-memory graph of actions and the artifacts that these actions read and generate. The graph might include artifacts that exist as source files (for example, in the file system) as well as generated intermediate/final artifacts that are not mentioned in BUILD files. Produced during the analysis phase and used during the execution phase.
Action graph query (aquery)
A query tool that can query over build actions. This provides the ability to analyze how build rules translate into the actual work builds do.
The cache key of an action. Computed based on action metadata, which might include the command to be execution in the action, compiler flags, library locations, or system headers, depending on the action. Enables Bazel to cache or invalidate individual actions deterministically.
The second phase of a build. Processes the target graph specified in BUILD files to produce an in-memory action graph that determines the order of actions to run during the execution phase. This is the phase in which rule implementations are evaluated.
A source file or a generated file. Can also be a directory of files, known as “tree artifacts”. Tree artifacts are black boxes to Bazel: Bazel does not treat the files in tree artifacts as individual artifacts and thus cannot reference them directly as action inputs / outputs. An artifact can be an input to multiple actions, but must only be generated by at most one action.
A mechanism for rules to create additional actions in their
dependencies. For example, if target A depends on B, one can apply an aspect on
A that traverses up a dependency edge to B, and runs additional actions in B
to generate and collect additional output files. These additional actions are
cached and reused between targets requiring the same aspect. Created with the
aspect() Starlark Build API function. Can be used, for example, to generate
metadata for IDEs, and create actions for linting.
See also: Aspects documentation
An aspect composition mechanism, where aspects can be applied on other aspects.
For an aspect A to inspect aspect B, aspect A must declare the providers it
needs from aspect B (with the
required_aspect_providers attribute), and aspect
B must declare the providers it returns (with the
provides attribute). For
example, this can be used by IDE aspects to generate files using information
also generated by aspects, like the
Bazel’s configuration file used to change the default values for startup
flags and command flags, and to define common
groups of options that can then be set together on the Bazel command line using
--config flag. Bazel can combine settings from multiple bazelrc files
(systemwide, per-workspace, per-user, or from a custom location), and a
bazelrc file may also import settings from other bazelrcs.
The Google-internal version of Bazel. Google’s main build system for its mono-repository.
A BUILD file is the main configuration file that tells Bazel what software outputs to build, what their dependencies are, and how to build them. Bazel takes a BUILD file as input and uses the file to create a graph of dependencies and to derive the actions that must be completed to build intermediate and final software outputs. A BUILD file marks a directory and any sub-directories not containing a BUILD file as a package, and can contain targets created by rules. The file can also be named BUILD.bazel.
See BUILD File. Takes precedence over a
BUILD file in the same
A file that defines rules, macros, and constants written in Starlark. These can then be imported into BUILD files using the load() function.
The dependency graph that Bazel constructs and traverses to perform a build. Includes nodes like targets, configured targets, actions, and artifacts. A build is considered complete when all artifacts on which a set of requested targets depend are verified as up-to-date.
A Starlark-defined piece of configuration. Transitions can set build settings to change a subgraph’s configuration. If exposed to the user as a command-line flag, also known as a build flag.
A build that doesn’t use the results of earlier builds. This is generally slower than an incremental build but commonly considered to be more correct. Bazel guarantees both clean and incremental builds are always correct.
bazel command-line client automatically starts a background server on the
local machine to execute Bazel commands. The server persists across
commands but automatically stops after a period of inactivity (or explicitly via
bazel shutdown). Splitting Bazel into a server and client helps amortize JVM
startup time and supports faster incremental builds
because the action graph remains in memory across commands.
Used on the command line to invoke different Bazel functions, like
bazel run, and
A set of flags specific to a command. Command flags are specified
after the command (
bazel build <command flags>). Flags can be applicable to
one or more commands. For example,
--configure is a flag exclusively for the
bazel sync command, but
--keep_going is applicable to
test and more. Flags are often used for configuration
purposes, so changes in flag values can cause Bazel to invalidate in-memory
graphs and restart the analysis phase.
Information outside of rule definitions that impacts how rules generate actions. Every build has at least one configuration specifying the target platform, action environment variables, and command-line build flags. Transitions may create additional configurations, e.g. for host tools or cross-compilation.
See also: Configurations
The process of only including the pieces of configuration a
target actually needs. For example, if you build Java binary
//:j with C++
//:c, it’s wasteful to include the value of
--javacopt in the
//:c because changing
--javacopt unnecessarily breaks C++
Configured query (cquery)
A query tool that queries over configured
targets (after the analysis phase
completes). This means
select() and build flags (e.g.
--platforms) are accurately reflected in the results.
See also: cquery documentation
The result of evaluating a target with a
configuration. The analysis phase produces
this by combining the build’s options with the targets that need to be built.
For example, if
//:foo builds for two different architectures in the same
build, it has two configured targets:
<//:foo, x86> and
A build is correct when its output faithfully reflects the state of its transitive inputs. To achieve correct builds, Bazel strives to be hermetic, reproducible, and making build analysis and action execution deterministic.
A directed edge between two targets. A target
//:foo has a target
dependency on target
//:foo’s attribute values contain a
//:foo has an action dependency on
//:bar if an
//:foo depends on an input artifact created by an
A data structure for collecting data on transitive dependencies. Optimized so that merging depsets is time and space efficient, because it’s common to have very large depsets (e.g. hundreds of thousands of files). Implemented to recursively refer to other depsets for space efficiency reasons. Rule implementations should not “flatten” depsets by converting them to lists unless the rule is at the top level of the build graph. Flattening large depsets incurs huge memory consumption. Also known as nested sets in Bazel’s internal implementation.
See also: Depset documentation
A local on-disk blob store for the remote caching feature. Can be used in conjunction with an actual remote blob store.
A read-only directory containing files that Bazel would otherwise fetch from the internet using repository rules. Enables builds to run fully offline.
An execution strategy that selects between local and remote execution based on various heuristics, and uses the execution results of the faster successful method. Certain actions are executed faster locally (for example, linking) and others are faster remotely (for example, highly parallelizable compilation). A dynamic execution strategy can provide the best possible incremental and clean build times.
The third phase of a build. Executes the actions in the action graph created during the analysis phase. These actions invoke executables (compilers, scripts) to read and write artifacts. Spawn strategies control how these actions are executed: locally, remotely, dynamically, sandboxed, docker, and so on.
A directory in the workspace’s output base
directory where local actions are executed in
non-sandboxed builds. The directory contents are mostly symlinks
of input artifacts from the workspace. The execution root also
contains symlinks to external repositories as other inputs and the
directory to store outputs. Prepared during the loading phase
by creating a symlink forest of the directories that represent the transitive
closure of packages on which a build depends. Accessible with
execution_root on the command line.
A build is hermetic if there are no external influences on its build and test operations, which helps to make sure that results are deterministic and correct. For example, hermetic builds typically disallow network access to actions, restrict access to declared inputs, use fixed timestamps and timezones, restrict access to environment variables, and use fixed seeds for random number generators
An incremental build reuses the results of earlier builds to reduce build time and resource usage. Dependency checking and caching aim to produce correct results for this type of build. An incremental build is the opposite of a clean build.
An identifier for a target. A fully-qualified label such as
//path/to/package:target consists of
// to mark the workspace root
path/to/package as the directory that contains the BUILD
file declaring the target, and
:target as the name of the target
declared in the aforementioned BUILD file. May also be prefixed with
@my_repository//<..> to indicate that the target is declared in an ]external
The first phase of a build where Bazel parses
BUILD, and .bzl
files to create packages. Macros and certain
glob() are evaluated in this phase. Interleaved with the second
phase of the build, the analysis phase, to build up a target
A mechanism to compose multiple rule target declarations together under a single Starlark function. Enables reusing common rule declaration patterns across BUILD files. Expanded to the underlying rule target declarations during the loading phase.
See also: Macro documentation
A short, human-readable string selected by a rule author to quickly understand
what an action in the rule is doing. Mnemonics can be used as
identifiers for spawn strategy selections. Some examples of action mnemonics
Javac from Java rules,
CppCompile from C++ rules, and
AndroidManifestMerger from Android rules.
Rules that are built into Bazel and implemented in Java. Such rules
.bzl files as functions in the native module (for
native.java_library). User-defined rules
(non-native) are created using Starlark.
A workspace-specific directory to store Bazel output files. Used to separate outputs from the workspace’s source tree. Located in the output user root.
A group of files that is expected to be built when Bazel finishes building a
target. Rules put their usual outputs in the “default output group”
.jar file of a
targets). The default output group is the output group whose
artifacts are built when a target is requested on the command line.
Rules can define more named output groups that can be explicitly specified in
BUILD files (
filegroup rule) or the command line
Output user root
A user-specific directory to store Bazel’s outputs. The directory name is derived from the user’s system username. Prevents output file collisions if multiple users are building the same project on the system at the same time. Contains subdirectories corresponding to build outputs of individual workspaces, also known as output bases.
The set of targets defined by a BUILD file. A package’s name is the BUILD file’s path relative to the workspace root. A package can contain subpackages, or subdirectories containing BUILD files, thus forming a package hierarchy.
A target representing a set of packages. Often used in visibility attribute values.
A “machine type” involved in a build. This includes the machine Bazel runs on (the “host” platform), the machines build tools execute on (“exec” platforms), and the machines targets are built for (“target platforms”).
A set of information passed from a rule target to other rule targets. Usually contains information like: compiler options, transitive source files, transitive output files, and build metadata. Frequently used in conjunction with depsets.
See also: Provider documentation
The process of analyzing a build graph to understand target properties and dependency structures. Bazel supports three query variants: query, cquery, and aquery.
A query tool that operates over the build’s post-loading
phase target graph. This is relatively fast,
but can’t analyze the effects of
select(), build flags,
artifacts, or build actions.
See also: Query how-to, Query reference
A shared content-addressable cache of files downloaded by Bazel for builds,
shareable across workspaces. Enables offline builds after the
initial download. Commonly used to cache files downloaded through repository
http_archive and repository rule APIs like
repository_ctx.download. Files are cached only if their SHA-256 checksums are
specified for the download.
The property of a build or test that a set of inputs to the build or test will always produce the same set of outputs every time, regardless of time, method, or environment. Note that this does not necessarily imply that the outputs are correct or the desired outputs.
A function implementation that registers a series of actions to be
performed on input artifacts to produce a set of output artifacts.
Rules can read values from attributes as inputs (e.g. deps, testonly, name).
Rule targets also produce and pass along information that may be useful to other
rule targets in the form of providers (e.g.
See also: Rules documentation
The runtime dependencies of an executable target. Most commonly, the executable is the executable output of a test rule, and the runfiles are runtime data dependencies of the test. Before the invocation of the executable (during bazel test), Bazel prepares the tree of runfiles alongside the test executable according to their source directory structure.
See also: Runfiles documentation
A technique to isolate a running action inside a restricted and temporary execution root, helping to ensure that it doesn’t read undeclared inputs or write undeclared outputs. Sandboxing greatly improves hermeticity, but usually has a performance cost, and requires support from the operating system. The performance cost depends on the platform. On Linux, it’s not significant, but on macOS it can make sandboxing unusable.
The core parallel, functional, and incremental evaluation framework of Bazel. https://bazel.build/designs/skyframe.html
A feature to embed additional information into Bazel-built
artifacts. For example, this can be used for source control, build
time and other workspace or environment-related information for release builds.
Enable through the
--workspace_status_command flag and rules that
support the stamp attribute.
The extension language for writing rules and macros. A
restricted subset of Python (syntactically and grammatically) aimed for the
purpose of configuration, and for better performance. Uses the
file extension. BUILD files use an even more
restricted version of Starlark (e.g. no
def function definitions). Formerly
known as Skylark.
See also: Starlark language documentation
The set of flags specified between
bazel and the command,
for example, bazel
--host_jvm_debug build. These flags modify the
configuration of the Bazel server, so any modification to
startup flags causes a server restart. Startup flags are not specific to any
A buildable unit. Can be a rule target, file target, or a package
group. Rule targets are instantiated from rule declarations in
BUILD files. Depending on the rule implementation, rule targets
can also be testable or runnable. Every file used in BUILD files is a file
target. Targets can depend on other targets via attributes (most commonly but
deps). A configured target is a pair of
target and build configuration.
An in-memory graph of targets and their dependencies. Produced during the loading phase and used as an input to the analysis phase.
A way to specify a group of targets on the command line. Commonly
used patterns are
:all (all rule targets),
:* (all rule + file targets),
... (current package and all subpackages recursively). Can be used
in combination, for example,
//...:* means all rule and file targets in all
packages recursively from the root of the workspace.
Rule targets instantiated from test rules, and therefore contains a test executable. A return code of zero from the completion of the executable indicates test success. The exact contract between Bazel and tests (e.g. test environment variables, test result collection methods) is specified in the Test Encyclopedia.
A set of tools to build outputs for a language. Typically, a toolchain includes compilers, linkers, interpreters or/and linters. A toolchain can also vary by platform, that is, a Unix compiler toolchain’s components may differ for the Windows variant, even though the toolchain is for the same language. Selecting the right toolchain for the platform is known as toolchain resolution.
A build target is top-level if it’s requested on the Bazel command
line. For example, if
//:foo depends on
bazel build //:foo is
called, then for this build,
//:foo is top-level, and
top-level, although both targets will need to be built. An important difference
between top-level and non-top-level targets is that command
flags set on the Bazel command line (or via
.bazelrc) will set the configuration for top-level
targets, but might be modified by a transition for non-top-level
A mapping of configuration state from one value to another. Enables targets in the build graph to have different configurations, even if they were instantiated from the same rule. A common usage of transitions is with split transitions, where certain parts of the target graph is forked with distinct configurations for each fork. For example, one can build an Android APK with native binaries compiled for ARM and x86 using split transitions in a single build.
See also: User-defined transitions
Defines whether a target can be depended upon by other targets. By default, target visibility is private. That is, the target can only be depended upon by other targets in the same package. Can be made visible to specific packages or be completely public.
See also: Visibility documentation
A directory containing a
WORKSPACE file and source code for the software you
want to build. Labels that start with
// are relative to the workspace
Defines a directory to be a workspace. The file can be empty, although it usually contains external repository declarations to fetch additional dependencies from the network or local filesystem.
We welcome contributions to this glossary.
The definitions should strive to be crisp, concise, and easy to understand.
- Use the simplest words possible. Try to avoid technical jargon.
- Use the simplest grammar possible. Try not to string too many concepts into a sentence.
- Make the last word of each sentence count.
- Make each adjective really count.
- Avoid adverbs.
- Keep definitions as self-contained as possible.
- Calibrate a word’s value by considering what would be lost without it.
- Hit core concepts foremost. Avoid pedantry.
- Enlightening the reader is more important than being thorough.
- Links can provide deeper dives, for those who want it.