Generating BUILD Files
summary
Dropbox uses a command-line generator called BZLgen to emit BUILD files from source and small templates, producing 52 MB of BUILD files in the main repo; it parses imports to create explicit deps for Go, Python, Rust, TypeScript, Sass and Java (including Maven resolution), and supports build.bzl templates plus a reverse-deps-gen mode that regenerates dependents after refactoring. Generation usually succeeds even when execution fails; conventions and hermetic rules are required, and bad practices (global public visibility, non‑hermetic codegen) create large, painful maintenance costs.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 3:36Introducing BZL and subcommands
- 5:21BZLgen and build file generation
- 7:26Bazel build files for Go
- 10:55Bazel build files for Python
- 14:44Template-based generation
- 16:53Other languages and Maven
- 17:38Advantages of automation
- 20:52Pitfalls in generation
- 23:22Non-hermetic operations risks
- 26:48Code generation in BZLgen
- 28:14Avoiding visibility overrides
- 29:38Lessons learned
related talks
31mBazel: Do We Really Need Another Build Tool?
09mBazel: {Fast, Correct, Seamless}: Choose 3
11mPerformant Bazel Builds for Web Monorepos at Scale
09mLightning Talk – Bazel UI
23mPolyglot Builds with Bazel
42mMake local development (with Bazel) great again!
43mDeep dive into Go's build system
49mDRY compiling!
