$ show bazelbuild/bazel
Bazel is a multi-language, hermetic build system developed primarily by Google. The codebase serves as both the build tool itself (a C++ client communicating with a Java server) and the infrastructure for writing build rules in Starlark, a Python-like DSL. It implements a unique incremental build engine (Skyframe) that caches all intermediate states for correctness and speed, and supports remote caching and execution. The repository contains the full stack: command-line option parsing, Starlark interpreter and compiler, process sandboxing and wrapping, test runners (JUnit4 with coverage), jar merging, and platform-specific native code for Linux, macOS, and Windows. The architecture is split into a thin C++ client (handling startup, workspace discovery, and communication with the server) and a heavy Java server that performs all build analysis and execution. Key modules include the Starlark runtime (net.starlark.java.eval) which is an embeddable dynamic language with type checking, and the options framework (com.google.devtools.common.options) which provides annotation-driven, extensible command-line parsing. The repository is self-hosting: builds of Bazel are built with Bazel itself, using a bootstrap script. It maintains an extensive test suite across shell, Java, C++, and Python, and has active CI pipelines for multiple platforms and configurations.
The LLM identified 5 files worth highlighting for reuse:
The Starlark interpreter is a self-contained, sandboxed scripting language runtime used for BUILD files. It can be embedded in any Java application to provide a safe, deterministic scripting environment with strong typing, immutability guarantees, and annotation-based API binding. Its design isolates mutable state via 'Mutability' objects and supports fine-grained feature flags via 'FileOptions'. This component is highly reusable outside Bazel for any application needing a scriptable configuration language.
A mature, annotation-driven command-line option parsing framework. Options are defined via Java annotations on fields or methods, with built-in support for converters (e.g., DurationConverter, EnumConverter, BoolOrEnumConverter), expansion, implicit requirements, deprecation, and documentation. The framework is generic and can be extracted for any Java CLI application that needs rich option handling with minimal boilerplate.
A standalone C++ binary that wraps a subprocess with configurable timeout, kill delay, signal handling, and output redirection. It also collects resource usage statistics (ruage) and serializes them to a protobuf file. This tool is used by Bazel's sandbox execution strategy but is a self-contained utility that can be reused by any build system or CI pipeline needing reliable subprocess execution with timeouts and resource monitoring.
A tool for merging multiple JAR files into a single JAR, with pluggable combiner strategies for handling duplicated entries such as XML, manifest files, and Log4j2 plugin cache files. It supports Zip64, entry deduplication, and deterministic timestamp handling. The combiner pattern is reusable for any archive merging task that requires custom conflict resolution, and the tool is designed to be integrated into build pipelines.
A custom JUnit4 runner that integrates deeply with Bazel's test infrastructure, supporting sharding (RoundRobinShardingFilter, HashBackedShardingFilter), XML report generation (JUnit4TestXmlListener), cancelation via exit files, and JaCoCo coverage mapping. The sharding and XML output modules are self-contained and can be reused in other test harnesses needing distributed test execution and structured output.