Skip to content
File

Blob: build/AGENTS.md

Markdown41 lines

build/ — Bazel Build Rules

OVERVIEW

Custom Bazel rules (wd_* macros) for C++, TypeScript, Rust, Cap'n Proto, and test orchestration. Uses bzlmod (MODULE.bazel), not WORKSPACE. This is build system definitions, NOT build output (bazel-bin/).

KEY RULES

Rule Purpose
wd_cc_library.bzl Wraps cc_library; strip_include_prefix="/src", arch-specific CPU flags (CRC32C)
wd_cc_binary.bzl Wraps cc_binary; macOS dead-strip linkopts; creates _cross alias for prebuilt arm64 binaries
wd_cc_embed.bzl Binary/text data -> C++ via C23 #embed; auto-detects text vs binary by extension
wd_cc_benchmark.bzl Google Benchmark wrapper; generates CSV report genrule
wd_test.bzl .wd-test config test runner; generates up to 3 variants per test
kj_test.bzl C++ unit test wrapper; also generates test variants
wpt_test.bzl Web Platform Tests; generates JS runner + .wd-test config from WPT tree; delegates to wd_test
wd_ts_bundle.bzl TypeScript compilation + JS bundle generation
wd_js_bundle.bzl JS bundle -> Cap'n Proto Modules.Bundle embedding via generated .capnp
wd_capnp_library.bzl Cap'n Proto schema compilation
wd_rust_crate.bzl / wd_rust_binary.bzl Rust build rules
lint_test.bzl ESLint integration

Conventions:

  • _cross alias pattern: every wd_cc_binary gets a name_cross alias selecting prebuilt arm64 or source build
  • Test tags: off-by-default, requires-container-engine, no-asan, no-coverage
  • Variant generation controllable per-test via generate_*_variant booleans
  • BUILD.* files: overlay build files for third-party deps (sqlite3, zlib, simdutf, pyodide, wpt)

DEPENDENCY MANAGEMENT

Lives in deps/. Uses jsonc manifests + codegen:

  • deps.jsonc, build_deps.jsonc, shared_deps.jsonc — dependency specifications
  • update-deps.py [dep_name] — fetches latest versions, computes hashes, regenerates gen/ MODULE.bazel fragments
  • gen/ — autogenerated; do not hand-edit
  • *.MODULE.bazel (e.g., rust.MODULE.bazel, v8.MODULE.bazel) — included by root MODULE.bazel
  • workerd-v8/ — separate Bazel module wrapping V8 dependency
  • python/ — Pyodide package lists (versioned .bzl files)