Bazel BUILD Files: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 13: Line 13:


The file cannot contain function definitions, <code>for</code> or <code>if</code> control statements. List comprehensions and <code>if</code> expressions are allowed.
The file cannot contain function definitions, <code>for</code> or <code>if</code> control statements. List comprehensions and <code>if</code> expressions are allowed.
Starlark programs can't perform arbitrary I/O, which makes the interpretation of the <code>BUILD</code> files [[Bazel_Concepts#Hermeticity|hermetic]].


=<span id='Build_Rule'></span>Build Rules=
=<span id='Build_Rule'></span>Build Rules=

Revision as of 21:10, 16 July 2024

External

Internal

Overview

A BUILD is a short program, an interpretable list of Starlark statements. It can be named BUILD or BUILD.bazel and where both exist, BUILD.bazel takes precedence.

General Syntax

Variables must be defined before they are used.

The relative order in which build rules are declared is unimportant.

The file cannot contain function definitions, for or if control statements. List comprehensions and if expressions are allowed.

Starlark programs can't perform arbitrary I/O, which makes the interpretation of the BUILD files hermetic.

Build Rules

When a build rule function is executed, it creates a new target in the graph, which can later referred using a label.

Functions

Functions can be declared in .bzl files.