WORKSPACE.rbs file at its root. Inside
it, any directory that contains a build file is a package, and each package declares
one or more targets — the things you build, test, and run. Targets are addressed by
labels like //services/api:server.
The workspace
The workspace root is marked by aWORKSPACE.rbs file. Every rbs command finds the root
by walking up from your current directory, so you can run commands from anywhere inside
the workspace. WORKSPACE.rbs is also where you declare the hermetic toolchains your
workspace uses — rbs downloads and manages them itself, so nothing needs to be installed
on the machine:
rbs keeps per-workspace build state in a
.rbs/ directory next to WORKSPACE.rbs
(build outputs, launchers, test logs). It is disposable — safe to delete, never commit
it. Cached action results live in the shared content-addressed cache outside the
workspace, so deleting .rbs/ does not throw away cached work.--workspace-root or the
RBS_WORKSPACE_ROOT environment variable instead of relying on auto-discovery.
Packages and build files
A package is any directory containing a file namedBUILD.rbs (lowercase
build.rbs is also accepted). The package’s path relative to the workspace root is its
name: the build file at services/api/BUILD.rbs defines the package services/api. A
build file at the workspace root defines the root package.
Build files are written in the RBS language — a small, deterministic, Python-like
language. A build file loads the rules it needs and calls them to declare targets:
glob() is available in every build file without a load. It matches files relative to
the package directory:
. are never treated as packages, so a build file inside a
hidden directory is ignored.
Labels
A label names one target. The full form is//package/path:target_name:
Inside a build file, use
:name for targets in the same package and
//package:name for targets in other packages.
Target patterns
Thebuild, test, run, query, and coverage commands all accept the same pattern
syntax for addressing sets of targets:
Depending on other targets
Thedeps attribute wires targets together. rbs resolves the whole dependency closure,
builds it in dependency order, and runs independent targets in parallel:
@external:// labels,
pinned to a version:
npm install or pip install step.
load() semantics
load() imports named symbols from another .rbs module. Four path forms exist:
Gotchas worth knowing
Other language properties to keep in mind:- Build files are declarative: evaluating a build file only registers targets — no
compilation or command runs until you invoke
rbs build. glob()is the way to enumerate source files; there is no general file I/O in build files.- Loaded modules are cached, so loading the same module from many files is cheap.