blob: 5f3720070a94518121bb4c5fdd257930e43114dd [file] [log] [blame] [view]
Jingwen Chena7f52532020-02-19 07:53:26 -08001---
2layout: documentation
3title: Bazel Glossary
4---
5
6# Bazel Glossary
7
jingwen3decf6d2020-02-20 15:12:36 -08008### Action
Jingwen Chena7f52532020-02-19 07:53:26 -08009
10A command to run during the build, for example, a call to a compiler that takes
11[artifacts](#artifact) as inputs and produces other artifacts as outputs.
12Includes metadata like the command line arguments, action key, environment
13variables, and declared input/output artifacts.
14
laurentlb41fe8762020-02-20 12:04:30 -080015**See also:** [Rules documentation](skylark/rules.html#actions)
16
jingwen3decf6d2020-02-20 15:12:36 -080017### Action cache
Jingwen Chena7f52532020-02-19 07:53:26 -080018
19An on-disk cache that stores a mapping of executed [actions](#action) to the
20outputs they created. The cache key is known as the [action key](#action-key). A
21core component for Bazel's incrementality model. The cache is stored in the
22output base directory and thus survives Bazel server restarts.
23
jingwen3decf6d2020-02-20 15:12:36 -080024### Action graph
Jingwen Chena7f52532020-02-19 07:53:26 -080025
26An in-memory graph of [actions](#action) and the [artifacts](#artifact) that
27these actions read and generate. The graph might include artifacts that exist as
28source files (for example, in the file system) as well as generated
29intermediate/final artifacts that are not mentioned in BUILD files. Produced
30during the [analysis phase](#analysis-phase) and used during the [execution
31phase](#execution-phase).
32
jingwen3decf6d2020-02-20 15:12:36 -080033### Action graph query (aquery)
Jingwen Chena7f52532020-02-19 07:53:26 -080034
35A [query](#query-concept) tool that can query over build [actions](#action).
36This provides the ability to analyze how [build rules](#rule) translate into the
37actual work builds do.
38
jingwen3decf6d2020-02-20 15:12:36 -080039### Action key
Jingwen Chena7f52532020-02-19 07:53:26 -080040
41The cache key of an [action](#action). Computed based on action metadata, which
42might include the command to be execution in the action, compiler flags, library
43locations, or system headers, depending on the action. Enables Bazel to cache or
44invalidate individual actions deterministically.
45
jingwen3decf6d2020-02-20 15:12:36 -080046### Analysis phase
Jingwen Chena7f52532020-02-19 07:53:26 -080047
48The second phase of a build. Processes the [target graph](#target-graph)
49specified in [BUILD files](#build-file) to produce an in-memory [action
50graph](#action-graph) that determines the order of actions to run during the
51[execution phase](#execution-phase). This is the phase in which rule
52implementations are evaluated.
53
jingwen3decf6d2020-02-20 15:12:36 -080054### Artifact
Jingwen Chena7f52532020-02-19 07:53:26 -080055
56A source file or a generated file. Can also be a directory of files, known as
57"tree artifacts". Tree artifacts are black boxes to Bazel: Bazel does not treat
58the files in tree artifacts as individual artifacts and thus cannot reference
59them directly as action inputs / outputs. An artifact can be an input to
60multiple actions, but must only be generated by at most one action.
61
jingwen3decf6d2020-02-20 15:12:36 -080062### Aspect
Jingwen Chena7f52532020-02-19 07:53:26 -080063
64A mechanism for rules to create additional [actions](#action) in their
65dependencies. For example, if target A depends on B, one can apply an aspect on
66A that traverses *up* a dependency edge to B, and runs additional actions in B
67to generate and collect additional output files. These additional actions are
68cached and reused between targets requiring the same aspect. Created with the
69`aspect()` Starlark Build API function. Can be used, for example, to generate
70metadata for IDEs, and create actions for linting.
71
72**See also:** [Aspects documentation](skylark/aspects.html)
73
jingwen3decf6d2020-02-20 15:12:36 -080074### Aspect-on-aspect
Jingwen Chena7f52532020-02-19 07:53:26 -080075
76An aspect composition mechanism, where aspects can be applied on other aspects.
77For an aspect A to inspect aspect B, aspect A must declare the *providers* it
78needs from aspect B (with the `required_aspect_providers` attribute), and aspect
79B must declare the providers it returns (with the `provides` attribute). For
80example, this can be used by IDE aspects to generate files using information
81also generated by aspects, like the `java_proto_library` aspect.
82
jingwen3decf6d2020-02-20 15:12:36 -080083### .bazelrc
Jingwen Chena7f52532020-02-19 07:53:26 -080084
85Bazel’s configuration file used to change the default values for [startup
86flags](#startup-flags) and [command flags](#command-flags), and to define common
87groups of options that can then be set together on the Bazel command line using
88a `--config` flag. Bazel can combine settings from multiple bazelrc files
89(systemwide, per-workspace, per-user, or from a custom location), and a
90bazelrc file may also import settings from other bazelrcs.
91
wyvb9cb4802020-05-06 04:02:16 -070092### Blaze
93
94<!-- "Bazel" gets scrubbed to "Bazel", so we use the corresponding HTML entity
95to circumvent that here. &#66; = "B" -->
Jingwen Chena7f52532020-02-19 07:53:26 -080096
97The Google-internal version of Bazel. Google’s main build system for its
98mono-repository.
99
jingwen3decf6d2020-02-20 15:12:36 -0800100### BUILD File
Jingwen Chena7f52532020-02-19 07:53:26 -0800101
102A BUILD file is the main configuration file that tells Bazel what software
103outputs to build, what their dependencies are, and how to build them. Bazel
104takes a BUILD file as input and uses the file to create a graph of dependencies
105and to derive the actions that must be completed to build intermediate and final
106software outputs. A BUILD file marks a directory and any sub-directories not
107containing a BUILD file as a [package](#package), and can contain
108[targets](#target) created by [rules](#rule). The file can also be named
109BUILD.bazel.
110
jingwen3decf6d2020-02-20 15:12:36 -0800111### BUILD.bazel File
Jingwen Chena7f52532020-02-19 07:53:26 -0800112
113See [BUILD File](#build-file). Takes precedence over a `BUILD` file in the same
114directory.
115
jingwen3decf6d2020-02-20 15:12:36 -0800116### .bzl File
Jingwen Chena7f52532020-02-19 07:53:26 -0800117
118A file that defines rules, [macros](#macro), and constants written in
119[Starlark](#starlark). These can then be imported into [BUILD
120files](#build-file) using the load() function.
121
jingwen3decf6d2020-02-20 15:12:36 -0800122<!-- TODO: ### Build event protocol -->
Jingwen Chena7f52532020-02-19 07:53:26 -0800123
jingwen3decf6d2020-02-20 15:12:36 -0800124<!-- TODO: ### Build flag -->
Jingwen Chena7f52532020-02-19 07:53:26 -0800125
jingwen3decf6d2020-02-20 15:12:36 -0800126### Build graph
Jingwen Chena7f52532020-02-19 07:53:26 -0800127
128The dependency graph that Bazel constructs and traverses to perform a build.
129Includes nodes like [targets](#target), [configured
130targets](#configured-target), [actions](#action), and [artifacts](#artifact). A
131build is considered complete when all [artifacts](#artifact) on which a set of
132requested targets depend are verified as up-to-date.
133
jingwen3decf6d2020-02-20 15:12:36 -0800134### Build setting
Jingwen Chena7f52532020-02-19 07:53:26 -0800135
136A Starlark-defined piece of [configuration](#configuration).
137[Transitions](#transition) can set build settings to change a subgraph's
138configuration. If exposed to the user as a [command-line flag](#command-flags),
139also known as a build flag.
140
jingwen3decf6d2020-02-20 15:12:36 -0800141### Clean build
Jingwen Chena7f52532020-02-19 07:53:26 -0800142
143A build that doesn't use the results of earlier builds. This is generally slower
144than an [incremental build](#incremental-build) but commonly considered to be
145more [correct](#correctness). Bazel guarantees both clean and incremental builds
146are always correct.
147
jingwen3decf6d2020-02-20 15:12:36 -0800148### Client-server model
Jingwen Chena7f52532020-02-19 07:53:26 -0800149
150The `bazel` command-line client automatically starts a background server on the
151local machine to execute Bazel [commands](#command). The server persists across
152commands but automatically stops after a period of inactivity (or explicitly via
153bazel shutdown). Splitting Bazel into a server and client helps amortize JVM
154startup time and supports faster [incremental builds](#incremental-build)
155because the [action graph](#action-graph) remains in memory across commands.
156
jingwen3decf6d2020-02-20 15:12:36 -0800157### Command
Jingwen Chena7f52532020-02-19 07:53:26 -0800158
159Used on the command line to invoke different Bazel functions, like `bazel
160build`, `bazel test`, `bazel run`, and `bazel query`.
161
jingwen3decf6d2020-02-20 15:12:36 -0800162### Command flags
Jingwen Chena7f52532020-02-19 07:53:26 -0800163
164A set of flags specific to a [command](#command). Command flags are specified
165*after* the command (`bazel build <command flags>`). Flags can be applicable to
166one or more commands. For example, `--configure` is a flag exclusively for the
167`bazel sync` command, but `--keep_going` is applicable to `sync`, `build`,
168`test` and more. Flags are often used for [configuration](#configuration)
169purposes, so changes in flag values can cause Bazel to invalidate in-memory
170graphs and restart the [analysis phase](#analysis-phase).
171
jingwen3decf6d2020-02-20 15:12:36 -0800172### Configuration
Jingwen Chena7f52532020-02-19 07:53:26 -0800173
174Information outside of [rule](#rule) definitions that impacts how rules generate
175[actions](#action). Every build has at least one configuration specifying the
176target platform, action environment variables, and command-line [build
177flags](#command-flags). [Transitions](#transition) may create additional
178configurations, e.g. for host tools or cross-compilation.
179
Greg39a6fd42020-02-28 13:37:19 -0800180**See also:** [Configurations](skylark/rules.html#configurations)
181
jingwen3decf6d2020-02-20 15:12:36 -0800182<!-- TODO: ### Configuration fragment -->
laurentlb41fe8762020-02-20 12:04:30 -0800183
jingwen3decf6d2020-02-20 15:12:36 -0800184### Configuration trimming
Jingwen Chena7f52532020-02-19 07:53:26 -0800185
186The process of only including the pieces of [configuration](#configuration) a
187target actually needs. For example, if you build Java binary `//:j` with C++
188dependency `//:c`, it's wasteful to include the value of `--javacopt` in the
189configuration of `//:c` because changing `--javacopt` unnecessarily breaks C++
190build cacheability.
191
jingwen3decf6d2020-02-20 15:12:36 -0800192### Configured query (cquery)
Jingwen Chena7f52532020-02-19 07:53:26 -0800193
194A [query](#query-concept) tool that queries over [configured
195targets](#configured-target) (after the [analysis phase](#analysis-phase)
196completes). This means `select()` and [build flags](#command-flags) (e.g.
197`--platforms`) are accurately reflected in the results.
198
laurentlb41fe8762020-02-20 12:04:30 -0800199**See also:** [cquery documentation](cquery.html)
200
jingwen3decf6d2020-02-20 15:12:36 -0800201### Configured target
Jingwen Chena7f52532020-02-19 07:53:26 -0800202
203The result of evaluating a [target](#target) with a
204[configuration](#configuration). The [analysis phase](#analysis-phase) produces
205this by combining the build's options with the targets that need to be built.
206For example, if `//:foo` builds for two different architectures in the same
207build, it has two configured targets: `<//:foo, x86>` and `<//:foo, arm>`.
208
jingwen3decf6d2020-02-20 15:12:36 -0800209### Correctness
Jingwen Chena7f52532020-02-19 07:53:26 -0800210
211A build is correct when its output faithfully reflects the state of its
212transitive inputs. To achieve correct builds, Bazel strives to be
213[hermetic](#hermeticity), reproducible, and making [build
214analysis](#analysis-phase) and [action execution](#execution-phase)
215deterministic.
216
jingwen3decf6d2020-02-20 15:12:36 -0800217### Dependency
Jingwen Chena7f52532020-02-19 07:53:26 -0800218
219A directed edge between two [targets](#target). A target `//:foo` has a *target
220dependency* on target `//:bar` if `//:foo`'s attribute values contain a
221reference to `//:bar`. `//:foo` has an *action dependency* on `//:bar` if an
222action in `//:foo` depends on an input [artifact](#artifact) created by an
223action in `//:bar`.
224
jingwen3decf6d2020-02-20 15:12:36 -0800225### Depset
Jingwen Chena7f52532020-02-19 07:53:26 -0800226
227A data structure for collecting data on transitive dependencies. Optimized so
228that merging depsets is time and space efficient, because it’s common to have
229very large depsets (e.g. hundreds of thousands of files). Implemented to
230recursively refer to other depsets for space efficiency reasons. [Rule](#rule)
231implementations should not "flatten" depsets by converting them to lists unless
232the rule is at the top level of the build graph. Flattening large depsets incurs
233huge memory consumption. Also known as *nested sets* in Bazel's internal
234implementation.
235
laurentlb41fe8762020-02-20 12:04:30 -0800236**See also:** [Depset documentation](skylark/depsets.html)
237
jingwen3decf6d2020-02-20 15:12:36 -0800238### Disk cache
Jingwen Chena7f52532020-02-19 07:53:26 -0800239
240A local on-disk blob store for the remote caching feature. Can be used in
241conjunction with an actual remote blob store.
242
jingwen3decf6d2020-02-20 15:12:36 -0800243### Distdir
Jingwen Chena7f52532020-02-19 07:53:26 -0800244
245A read-only directory containing files that Bazel would otherwise fetch from the
246internet using repository rules. Enables builds to run fully offline.
247
jingwen3decf6d2020-02-20 15:12:36 -0800248### Dynamic execution
Jingwen Chena7f52532020-02-19 07:53:26 -0800249
250An execution strategy that selects between local and remote execution based on
251various heuristics, and uses the execution results of the faster successful
252method. Certain [actions](#action) are executed faster locally (for example,
253linking) and others are faster remotely (for example, highly parallelizable
254compilation). A dynamic execution strategy can provide the best possible
255incremental and clean build times.
256
jingwen3decf6d2020-02-20 15:12:36 -0800257### Execution phase
Jingwen Chena7f52532020-02-19 07:53:26 -0800258
259The third phase of a build. Executes the [actions](#action) in the [action
260graph](#action-graph) created during the [analysis phase](#analysis-phase).
261These actions invoke executables (compilers, scripts) to read and write
262[artifacts](#artifact). *Spawn strategies* control how these actions are
263executed: locally, remotely, dynamically, sandboxed, docker, and so on.
264
jingwen3decf6d2020-02-20 15:12:36 -0800265### Execution root
Jingwen Chena7f52532020-02-19 07:53:26 -0800266
267A directory in the [workspace](#workspace)’s [output base](#output-base)
268directory where local [actions](#action) are executed in
269non-[sandboxed](#sandboxing) builds. The directory contents are mostly symlinks
270of input [artifacts](#artifact) from the workspace. The execution root also
271contains symlinks to external repositories as other inputs and the `bazel-out`
272directory to store outputs. Prepared during the [loading phase](#loading-phase)
273by creating a *symlink forest* of the directories that represent the transitive
274closure of packages on which a build depends. Accessible with `bazel info
275execution_root` on the command line.
276
jingwen3decf6d2020-02-20 15:12:36 -0800277### File
Jingwen Chena7f52532020-02-19 07:53:26 -0800278
279See [Artifact](#artifact).
280
jingwen3decf6d2020-02-20 15:12:36 -0800281### Hermeticity
Jingwen Chena7f52532020-02-19 07:53:26 -0800282
283A build is hermetic if there are no external influences on its build and test
284operations, which helps to make sure that results are deterministic and
285[correct](#correctness). For example, hermetic builds typically disallow network
286access to actions, restrict access to declared inputs, use fixed timestamps and
287timezones, restrict access to environment variables, and use fixed seeds for
288random number generators
289
jingwen3decf6d2020-02-20 15:12:36 -0800290### Incremental build
Jingwen Chena7f52532020-02-19 07:53:26 -0800291
292An incremental build reuses the results of earlier builds to reduce build time
293and resource usage. Dependency checking and caching aim to produce correct
294results for this type of build. An incremental build is the opposite of a clean
295build.
296
jingwen3decf6d2020-02-20 15:12:36 -0800297<!-- TODO: ### Install base -->
Jingwen Chena7f52532020-02-19 07:53:26 -0800298
jingwen3decf6d2020-02-20 15:12:36 -0800299### Label
Jingwen Chena7f52532020-02-19 07:53:26 -0800300
301An identifier for a [target](#target). A fully-qualified label such as
302`//path/to/package:target` consists of `//` to mark the workspace root
303directory, `path/to/package` as the directory that contains the [BUILD
304file](#build-file) declaring the target, and `:target` as the name of the target
305declared in the aforementioned BUILD file. May also be prefixed with
306`@my_repository//<..>` to indicate that the target is declared in an ]external
307repository] named `my_repository`.
308
jingwen3decf6d2020-02-20 15:12:36 -0800309### Loading phase
Jingwen Chena7f52532020-02-19 07:53:26 -0800310
311The first phase of a build where Bazel parses `WORKSPACE`, `BUILD`, and [.bzl
312files](#bzl-file) to create [packages](#package). [Macros](#macro) and certain
313functions like `glob()` are evaluated in this phase. Interleaved with the second
314phase of the build, the [analysis phase](#analysis-phase), to build up a [target
315graph](#target-graph).
316
jingwen3decf6d2020-02-20 15:12:36 -0800317### Macro
Jingwen Chena7f52532020-02-19 07:53:26 -0800318
319A mechanism to compose multiple [rule](#rule) target declarations together under
320a single [Starlark](#starlark) function. Enables reusing common rule declaration
321patterns across BUILD files. Expanded to the underlying rule target declarations
322during the [loading phase](#loading-phase).
323
laurentlb41fe8762020-02-20 12:04:30 -0800324**See also:** [Macro documentation](skylark/macros.html)
325
jingwen3decf6d2020-02-20 15:12:36 -0800326### Mnemonic
Jingwen Chena7f52532020-02-19 07:53:26 -0800327
328A short, human-readable string selected by a rule author to quickly understand
329what an [action](#action) in the rule is doing. Mnemonics can be used as
330identifiers for *spawn strategy* selections. Some examples of action mnemonics
331are `Javac` from Java rules, `CppCompile` from C++ rules, and
332`AndroidManifestMerger` from Android rules.
333
jingwen3decf6d2020-02-20 15:12:36 -0800334### Native rules
Jingwen Chena7f52532020-02-19 07:53:26 -0800335
336[Rules](#rule) that are built into Bazel and implemented in Java. Such rules
337appear in [`.bzl` files](#bzl-file) as functions in the native module (for
338example, `native.cc_library` or `native.java_library`). User-defined rules
339(non-native) are created using [Starlark](#starlark).
340
jingwen3decf6d2020-02-20 15:12:36 -0800341### Output base
Jingwen Chena7f52532020-02-19 07:53:26 -0800342
343A [workspace](#workspace)-specific directory to store Bazel output files. Used
344to separate outputs from the *workspace*'s source tree. Located in the [output
345user root](#output-user-root).
346
jingwen3decf6d2020-02-20 15:12:36 -0800347### Output groups
Jingwen Chena7f52532020-02-19 07:53:26 -0800348
349A group of files that is expected to be built when Bazel finishes building a
350target. [Rules](#rule) put their usual outputs in the "default output group"
351(e.g the `.jar` file of a `java_library`, `.a` and `.so` for `cc_library`
352targets). The default output group is the output group whose
353[artifacts](#artifact) are built when a target is requested on the command line.
354Rules can define more named output groups that can be explicitly specified in
355[BUILD files](#build-file) (`filegroup` rule) or the command line
356(`--output_groups` flag).
357
jingwen3decf6d2020-02-20 15:12:36 -0800358### Output user root
Jingwen Chena7f52532020-02-19 07:53:26 -0800359
360A user-specific directory to store Bazel's outputs. The directory name is
361derived from the user's system username. Prevents output file collisions if
362multiple users are building the same project on the system at the same time.
363Contains subdirectories corresponding to build outputs of individual workspaces,
364also known as [output bases](#output-base).
365
jingwen3decf6d2020-02-20 15:12:36 -0800366### Package
Jingwen Chena7f52532020-02-19 07:53:26 -0800367
368The set of [targets](#target) defined by a [BUILD file](#build-file). A
369package's name is the BUILD file's path relative to the workspace root. A
370package can contain subpackages, or subdirectories containing BUILD files, thus
371forming a package hierarchy.
372
jingwen3decf6d2020-02-20 15:12:36 -0800373### Package group
Jingwen Chena7f52532020-02-19 07:53:26 -0800374
375A [target](#target) representing a set of packages. Often used in visibility
376attribute values.
377
jingwen3decf6d2020-02-20 15:12:36 -0800378### Platform
Jingwen Chena7f52532020-02-19 07:53:26 -0800379
380A "machine type" involved in a build. This includes the machine Bazel runs on
381(the "host" platform), the machines build tools execute on ("exec" platforms),
382and the machines targets are built for ("target platforms").
383
jingwen3decf6d2020-02-20 15:12:36 -0800384### Provider
Jingwen Chena7f52532020-02-19 07:53:26 -0800385
386A set of information passed from a rule [target](#target) to other rule targets.
387Usually contains information like: compiler options, transitive source files,
388transitive output files, and build metadata. Frequently used in conjunction with
389[depsets](#depset).
390
laurentlb41fe8762020-02-20 12:04:30 -0800391**See also:** [Provider documentation](rules.html#providers)
392
jingwen3decf6d2020-02-20 15:12:36 -0800393### Query (concept)
Jingwen Chena7f52532020-02-19 07:53:26 -0800394
395The process of analyzing a [build graph](#build-graph) to understand
396[target](#target) properties and dependency structures. Bazel supports three
397query variants: [query](#query-command), [cquery](#configured-query-cquery), and
398[aquery](#action-graph-query-aquery).
399
jingwen3decf6d2020-02-20 15:12:36 -0800400### query (command)
Jingwen Chena7f52532020-02-19 07:53:26 -0800401
402A [query](#query-concept) tool that operates over the build's post-[loading
403phase](#loading-phase) [target graph](#target-graph). This is relatively fast,
404but can't analyze the effects of `select()`, [build flags](#command-flags),
405[artifacts](#artifact), or build [actions](#action).
406
laurentlb41fe8762020-02-20 12:04:30 -0800407**See also:** [Query how-to](query-how-to.html), [Query reference](query.html)
408
jingwen3decf6d2020-02-20 15:12:36 -0800409### Repository cache
Jingwen Chena7f52532020-02-19 07:53:26 -0800410
411A shared content-addressable cache of files downloaded by Bazel for builds,
412shareable across [workspaces](#workspace). Enables offline builds after the
413initial download. Commonly used to cache files downloaded through repository
414rules like `http_archive` and repository rule APIs like
415`repository_ctx.download`. Files are cached only if their SHA-256 checksums are
416specified for the download.
417
jingwen3decf6d2020-02-20 15:12:36 -0800418<!-- TODO: ### Repository rule -->
Jingwen Chena7f52532020-02-19 07:53:26 -0800419
jingwen3decf6d2020-02-20 15:12:36 -0800420### Reproducibility
Jingwen Chena7f52532020-02-19 07:53:26 -0800421
422The property of a build or test that a set of inputs to the build or test will
423always produce the same set of outputs every time, regardless of time, method,
424or environment. Note that this does not necessarily imply that the outputs are
425[correct](#correctness) or the desired outputs.
426
jingwen3decf6d2020-02-20 15:12:36 -0800427### Rule
Jingwen Chena7f52532020-02-19 07:53:26 -0800428
429A function implementation that registers a series of [actions](#action) to be
430performed on input [artifacts](#artifact) to produce a set of output artifacts.
431Rules can read values from *attributes* as inputs (e.g. deps, testonly, name).
432Rule targets also produce and pass along information that may be useful to other
433rule targets in the form of [providers](#provider) (e.g. `DefaultInfo`
434provider).
435
laurentlb41fe8762020-02-20 12:04:30 -0800436**See also:** [Rules documentation](skylark/rules.html)
437
jingwen3decf6d2020-02-20 15:12:36 -0800438### Runfiles
Jingwen Chena7f52532020-02-19 07:53:26 -0800439
440The runtime dependencies of an executable [target](#target). Most commonly, the
441executable is the executable output of a test rule, and the runfiles are runtime
442data dependencies of the test. Before the invocation of the executable (during
443bazel test), Bazel prepares the tree of runfiles alongside the test executable
444according to their source directory structure.
445
laurentlb41fe8762020-02-20 12:04:30 -0800446**See also:** [Runfiles documentation](skylark/rules.html#runfiles)
447
jingwen3decf6d2020-02-20 15:12:36 -0800448### Sandboxing
Jingwen Chena7f52532020-02-19 07:53:26 -0800449
450A technique to isolate a running [action](#action) inside a restricted and
451temporary [execution root](#execution-root), helping to ensure that it doesn’t
452read undeclared inputs or write undeclared outputs. Sandboxing greatly improves
453[hermeticity](#hermeticity), but usually has a performance cost, and requires
454support from the operating system. The performance cost depends on the platform.
455On Linux, it's not significant, but on macOS it can make sandboxing unusable.
456
jingwen3decf6d2020-02-20 15:12:36 -0800457### Skyframe
Jingwen Chena7f52532020-02-19 07:53:26 -0800458
459The core parallel, functional, and incremental evaluation framework of Bazel.
460[https://bazel.build/designs/skyframe.html](https://bazel.build/designs/skyframe.html)
461
jingwen3decf6d2020-02-20 15:12:36 -0800462<!-- TODO: ### Spawn strategy -->
Jingwen Chena7f52532020-02-19 07:53:26 -0800463
jingwen3decf6d2020-02-20 15:12:36 -0800464### Stamping
Jingwen Chena7f52532020-02-19 07:53:26 -0800465
466A feature to embed additional information into Bazel-built
467[artifacts](#artifact). For example, this can be used for source control, build
468time and other workspace or environment-related information for release builds.
469Enable through the `--workspace_status_command` flag and [rules](rules) that
470support the stamp attribute.
471
jingwen3decf6d2020-02-20 15:12:36 -0800472### Starlark
Jingwen Chena7f52532020-02-19 07:53:26 -0800473
474The extension language for writing [rules](rules) and [macros](#macro). A
475restricted subset of Python (syntactically and grammatically) aimed for the
476purpose of configuration, and for better performance. Uses the [`.bzl`
477file](#bzl-file) extension. [BUILD files](#build-file) use an even more
478restricted version of Starlark (e.g. no `def` function definitions). Formerly
479known as Skylark.
480
laurentlb41fe8762020-02-20 12:04:30 -0800481**See also:** [Starlark language documentation](skylark/language.html)
482
jingwen3decf6d2020-02-20 15:12:36 -0800483<!-- TODO: ### Starlark rules -->
Jingwen Chena7f52532020-02-19 07:53:26 -0800484
jingwen3decf6d2020-02-20 15:12:36 -0800485<!-- TODO: ### Starlark rule sandwich -->
Jingwen Chena7f52532020-02-19 07:53:26 -0800486
jingwen3decf6d2020-02-20 15:12:36 -0800487### Startup flags
Jingwen Chena7f52532020-02-19 07:53:26 -0800488
489The set of flags specified between `bazel` and the [command](#query-command),
490for example, bazel `--host_jvm_debug` build. These flags modify the
491[configuration](#configuration) of the Bazel server, so any modification to
492startup flags causes a server restart. Startup flags are not specific to any
493command.
494
jingwen3decf6d2020-02-20 15:12:36 -0800495### Target
Jingwen Chena7f52532020-02-19 07:53:26 -0800496
497A buildable unit. Can be a [rule](#rule) target, file target, or a [package
498group](#package-group). Rule targets are instantiated from rule declarations in
499[BUILD files](#build-file). Depending on the rule implementation, rule targets
500can also be testable or runnable. Every file used in BUILD files is a file
501target. Targets can depend on other targets via attributes (most commonly but
502not necessarily `deps`). A [configured target](#configured-target) is a pair of
503target and [build configuration](#configuration).
504
jingwen3decf6d2020-02-20 15:12:36 -0800505### Target graph
Jingwen Chena7f52532020-02-19 07:53:26 -0800506
507An in-memory graph of [targets](#target) and their dependencies. Produced during
508the [loading phase](#loading-phase) and used as an input to the [analysis
509phase](#analysis-phase).
510
jingwen3decf6d2020-02-20 15:12:36 -0800511### Target pattern
Jingwen Chena7f52532020-02-19 07:53:26 -0800512
513A way to specify a group of [targets](#target) on the command line. Commonly
514used patterns are `:all` (all rule targets), `:*` (all rule + file targets),
515`...` (current [package](#package) and all subpackages recursively). Can be used
516in combination, for example, `//...:*` means all rule and file targets in all
517packages recursively from the root of the [workspace](#workspace).
518
jingwen3decf6d2020-02-20 15:12:36 -0800519### Tests
Jingwen Chena7f52532020-02-19 07:53:26 -0800520
521Rule [targets](#target) instantiated from test rules, and therefore contains a
522test executable. A return code of zero from the completion of the executable
523indicates test success. The exact contract between Bazel and tests (e.g. test
524environment variables, test result collection methods) is specified in the [Test
525Encyclopedia](test-encyclopedia.html).
526
jingwen3decf6d2020-02-20 15:12:36 -0800527### Toolchain
Jingwen Chena7f52532020-02-19 07:53:26 -0800528
529A set of tools to build outputs for a language. Typically, a toolchain includes
530compilers, linkers, interpreters or/and linters. A toolchain can also vary by
531platform, that is, a Unix compiler toolchain's components may differ for the
532Windows variant, even though the toolchain is for the same language. Selecting
533the right toolchain for the platform is known as toolchain resolution.
534
jingwen3decf6d2020-02-20 15:12:36 -0800535### Top-level target
Jingwen Chena7f52532020-02-19 07:53:26 -0800536
537A build [target](#target) is top-level if it’s requested on the Bazel command
538line. For example, if `//:foo` depends on `//:bar`, and `bazel build //:foo` is
539called, then for this build, `//:foo` is top-level, and `//:bar` isn’t
540top-level, although both targets will need to be built. An important difference
541between top-level and non-top-level targets is that [command
542flags](#command-flags) set on the Bazel command line (or via
543[.bazelrc](#bazelrc)) will set the [configuration](#configuration) for top-level
544targets, but might be modified by a [transition](#transition) for non-top-level
545targets.
546
jingwen3decf6d2020-02-20 15:12:36 -0800547### Transition
Jingwen Chena7f52532020-02-19 07:53:26 -0800548
549A mapping of [configuration](#configuration) state from one value to another.
550Enables [targets](#target) in the [build graph](#build-graph) to have different
551configurations, even if they were instantiated from the same [rule](#rule). A
552common usage of transitions is with *split* transitions, where certain parts of
553the [target graph](#target-graph) is forked with distinct configurations for
554each fork. For example, one can build an Android APK with native binaries
555compiled for ARM and x86 using split transitions in a single build.
556
Greg39a6fd42020-02-28 13:37:19 -0800557**See also:** [User-defined transitions](skylark/config.html#user-defined-transitions)
558
jingwen3decf6d2020-02-20 15:12:36 -0800559### Tree artifact
Jingwen Chena7f52532020-02-19 07:53:26 -0800560
561See [Artifact](#artifact).
562
jingwen3decf6d2020-02-20 15:12:36 -0800563### Visibility
Jingwen Chena7f52532020-02-19 07:53:26 -0800564
565Defines whether a [target](#target) can be depended upon by other targets. By
566default, target visibility is private. That is, the target can only be depended
567upon by other targets in the same [package](#package). Can be made visible to
568specific packages or be completely public.
569
laurentlb41fe8762020-02-20 12:04:30 -0800570**See also:** [Visibility documentation](be/common-definitions.html#common-attributes)
571
jingwen3decf6d2020-02-20 15:12:36 -0800572### Workspace
Jingwen Chena7f52532020-02-19 07:53:26 -0800573
574A directory containing a `WORKSPACE` file and source code for the software you
575want to build. Labels that start with `//` are relative to the workspace
576directory.
577
jingwen3decf6d2020-02-20 15:12:36 -0800578### WORKSPACE file
Jingwen Chena7f52532020-02-19 07:53:26 -0800579
580Defines a directory to be a [workspace](#workspace). The file can be empty,
581although it usually contains external repository declarations to fetch
582additional dependencies from the network or local filesystem.
583
584## Contributing
585
586We welcome contributions to this glossary.
587
588The definitions should strive to be crisp, concise, and easy to understand.
589
590Principles:
591
592* Use the simplest words possible. Try to avoid technical jargon.
593* Use the simplest grammar possible. Try not to string too many concepts into a
594 sentence.
595* Make the last word of each sentence count.
596* Make each adjective *really* count.
597* Avoid adverbs.
598* Keep definitions as self-contained as possible.
599* Calibrate a word's value by considering what would be lost without it.
600* Hit core concepts foremost. Avoid pedantry.
601* Enlightening the reader is more important than being thorough.
602* Links can provide deeper dives, for those who want it.