Rules reference

One page per family. A family is "built" when its rules exist and have been run on a farm; "planned" means it is not built. A release is a source archive and the command line for three platforms, tagged automatically: see Releases.

FamilyStatusLoad fromMain entry points
Rustbuilt@buildrules//rules/rust:defs.bzl, or //:buildrules.bzl from the CLIcargo_workspace, cargo_package, rust_library, rust_binary, rust_test
Nodebuilt@buildrules//rules/node:modules.bzl, defs.bzlnpm_package, npm_modules, tsc_check, tsc_build, jest_test, node_tree_test, node_tree_build, cdk_synth, node_test, esbuild_bundle
Zigbuilt@buildrules//rules/zig:zig.bzlzig_exe, zig_test, zig_module, zig_dist
C/C++built@buildrules//rules/cxx:toolchain.bzl, defs.bzlcxx_toolchains, the prelude's cxx_library and cxx_binary, c_exe, checked_cxx_library
Mojobuilt//pkg:buildrules.mojo.bzl, written by buildrules mojo syncmojo_package
Pythonplannednot releasednone yet

How the rules fit together #

Platforms #

PlatformStatus
Linux x86_64built; the only platform that runs
CPU levels x86-64-v1 to v4built; see CPU levels
CPU levels armv8.0-a to armv8.4-aplanned; the flags are data and no Arm worker has run them
macOSplanned; nothing is built
Windowsplanned; nothing is built

Releases #

Every push to main is built and tested, and a green one that changes more than documentation or CI is released with no human action. A release is a tag vMAJOR.MINOR.PATCH, a GitHub release carrying the source archive buildrules-<version>.tar.gz, the command line for three platforms (buildrules-cli-<version>-<target>.tar.gz for linux-x86_64, linux-aarch64 and macos-arm64), their SHA256SUMS and the notes, and a keyless signature and a build provenance attestation of each of those files. MAJOR.MINOR is the VERSION file, changed by a pull request; PATCH is the highest existing patch of that line plus one.

The command line is a static program: unpack the tarball of your platform and put buildrules on your PATH. The three are built from one source behind the same tests, and a second build in the release must give the same bytes; the linux-x86_64 program is the file the beta stage runs, and the other two are checked for their file header and their version but not yet run by a user beta. The rules themselves build on Linux x86_64 farms only. To pin a release for the rules, name the tag and the sha256 of the archive, or the commit the tag names in your .buckconfig; the archive is the same bytes for the same tag, and the release job checks that before it publishes. RELEASING.md has the steps, the checks and the commands.

A release is made only after two more stages. In the beta stage, hello-world repositories (Rust, C and C++, Zig, Node, and one that mixes them) consume the candidate commit as an external cell, the way you do: buildrules init, cargo new, npm sync, then a build, a run of what was built, and a second build from nothing, in a copy of the repository at another path, that must give the same bytes. The Mojo leg builds a Mojo package with the pinned mopm 0.0.48 release, the same way, and two native legs run the command line the release ships for Arm Linux and for macOS on a runner of that kind, up to the build: the version it says, init writing the same bytes at two paths, Buck2 loading the candidate. They do not build, because no toolchain of the rules runs on those hosts yet. In the gamma stage our own repositories are built with the candidate on the farm, and a farm that is not configured fails the release rather than letting it pass. Each release also gets a page with the tag, the commit to pin, the archive URL and its sha256.

mopm 0.0.48 is released and pinned: the Mojo rules run the published mopm release (see Mojo). a buildrules release holds the source archive and the command line.

CPU levels #

A CPU level is a Buck2 constraint, isa_level. A target platform per level, buildrules//platforms:linux_<id> (for example linux_x86_64_v3), adds the level to the configuration. The compilers of every family get the flags below, so a v1 build and a v3 build have different output paths and different cache keys. A platform without a level, linux_x86_64, passes no CPU flag. native is never passed: a farm schedules on "at least this level", so host-tuned code would be cached under a lower level's key.

LevelISA propertyrustczig ccStatus
x86-64-v1x86-64-C target-cpu=x86-64-mcpu=x86_64built
x86-64-v2x86-64-v2-C target-cpu=x86-64-v2-mcpu=x86_64_v2built
x86-64-v3x86-64-v3-C target-cpu=x86-64-v3-mcpu=x86_64_v3built
x86-64-v4x86-64-v4-C target-cpu=x86-64-v4-mcpu=x86_64_v4built
armv8.0-aarmv8.0-a-C target-cpu=generic-mcpu=genericplanned
armv8.1-aarmv8.1-a-C target-cpu=generic -C target-feature=+v8.1a-mcpu=generic+v8_1aplanned
armv8.2-aarmv8.2-a-C target-cpu=generic -C target-feature=+v8.2a-mcpu=generic+v8_2aplanned
armv8.3-aarmv8.3-a-C target-cpu=generic -C target-feature=+v8.3a-mcpu=generic+v8_3aplanned
armv8.4-aarmv8.4-a-C target-cpu=generic -C target-feature=+v8.4a-mcpu=generic+v8_4aplanned

Test execution requirements. Compile actions run on any worker: the first execution platform is level-agnostic (ISA=x86-64). A test is two targets, <name>__bin (the compile) and <name> (the run). The run lists exec_compatible_with = test_exec_compatible_with(), which selects an execution platform whose ISA property is the test's level, so a v3 test runs on a worker that reports ISA=x86-64-v3. There is one such platform for each of v2, v3 and v4; v1 needs none. If a test is left without that setting, analysis fails with built for ISA x86-64-v3 but its execution platform reports ISA=x86-64.

isa_audit reads the machine code, not the command line: it disassembles the binary with the pinned llvm-objdump and fails unless the binary holds 256-bit ymm instructions at v3 or v4 and none below. A flag that never reached the compiler would otherwise leave a green, cached, wrong build.

Limit. Only x86-64 runs. C that a crate's build script compiles uses the Zig default CPU, with no level flag. Arm levels are data only: a test at an Arm level finds no execution platform and is refused.

The CI matrix #

//ci:matrix is every cell of the matrix, built and tested in one command on the farm. A test of these examples is a build action, so building a cell tests it.

TargetBuilds and tests
//ci:rust_defaultthe hand-written Rust example, the generated-unit examples (build scripts, links, tests) and the Zig examples, with the default Rust and the default Zig
//ci:rust_oldestthe same Rust targets with the oldest supported Rust, through a configuration transition (rust_at)
//ci:zig_nextthe Zig examples with the other pinned Zig
//ci:isa_v1, //ci:isa_v3the CPU-level example at the baseline and at x86-64-v3 (isa_at): the machine code is audited and the test runs on a worker of the level
//ci:refusalswhat the rules must refuse, as analysis tests: an unpinned Rust version, a wrong hash, a user pin that shadows a reviewed one
//ci:cratesthe example with crates.io dependencies, a build script and a native library, and sync --check over it
//ci:gitcratesthe example whose dependency is a git repository pinned by commit (a build script and a proc-macro from GitHub's archive of the commit)
//ci:matrixall of the above

Reproduce one cell by hand with a target platform: buck2 build --target-platforms buildrules//platforms:linux_x86_64_rust_1_85_0 //examples/hello:hello_runs. A Rust version added to the version table needs its line in rules/matrix.bzl, or loading fails.

//ci:mojo builds the Mojo examples. It is not part of //ci:matrix: it needs a mirror of the example registry (buildrules.url_map).

Note. The tests of this site compare the pages with the rule sources when the site is built. They check the rule names, the argument lists shown in signatures and tables, the command-line verbs and flags, the Rust versions and the CPU levels in the tables, and the targets of the matrix. They cannot check what a sentence says a rule does; those sentences are reviewed by hand.