How bazelbuild/reclient works
Main components
• Frontend/Integration Layer: This includes the rewrapper binary that intercepts build commands. Rewrapper is responsible for “wrapping” the original invocation so that it connects with the remote execution infrastructure.
• Coordinator/Orchestration Component: The reproxy component acts as the central hub. It is started by and stopped through the bootstrap process. Reproxy manages communication with the remote build server and coordinates fetching and caching build artifacts.
• Dependency Scanner Service: The scandeps_server (and its corresponding CLI clients) handles scanning and processing C/C++ include dependencies.
• API Modules: Under the “api” directory you see various subcomponents (auth, credshelper, log, proxy, scandeps, stat, stats) that define or handle the protocol buffers (with corresponding .proto files) and generated Go implementations. These represent the interfaces and data structures used for communication (for example, with remote execution servers or for internal logging/credential management).
• Internal Processing and Utility Libraries: The “internal” and “pkg” directories contain a wealth of packages (such as auth, inputprocessor, reproxy, rewrapper, stats, etc.) that implement the business logic, input processing, dependency analysis, logging, and other utility functions. They form the backbone of the re-client system.
• Configuration & Build Environment: Files and directories (like BUILD.bazel, WORKSPACE, configs/, and the module extensions) indicate a Bazel-centric build that also supports multiple platforms (Linux, Windows, Mac). These components ensure that all binaries and tools are built from a consistent code base.
Relationships and interactions
• The reproxy, in turn, communicates with the external Remote Execution API server to schedule build actions remotely, upload toolchains and inputs, and download resulting artifacts. Also, it interacts with the scandeps_server to process C++ dependencies.
• Bootstrap manages the lifecycle of reproxy (starting and stopping it) and aggregates build metrics. It also interacts with the configuration sources (command-line flags, environment variables, configuration file) to drive how all these components behave.
• The API components (auth, credshelper, etc.) play a role in ensuring that the correct credentials are attached to the remote requests and that logging is standardized across the system.
• The internal packages support the processing of build inputs (using flags parsing, file-system path translation, toolchain files, etc.), making sure that the environment is faithfully replicated for remote execution.
Architectural patterns and design principles
• Modularity: The project is broken into discrete binaries (rewrapper, reproxy, bootstrap, scandeps, etc.) as well as well-defined internal modules. This separation makes it easier to update or replace parts without affecting the whole system.
• Client-Server Architecture: The rewrapper acts as a client component communicating with reproxy (the local server), which then connects to a remote execution service.
• Dependency Processing: Modules within the “inputprocessor” and subdirectories illustrate a detailed pipeline for processing compilation flags, toolchain inputs, and dependency scanning – crucial for correctly reproducing build environments remotely.
Additional notes based on project type
• Since this is a full-stack build integration system, explicitly separate front-end (client invocation via rewrapper) from the backend (remote execution, caching, and result processing in reproxy). Emphasize the network boundary where reproxy communicates with a remote execution server.
Final checklist
• Clearly label every component using the project’s terminology (rewrapper, reproxy, bootstrap, scandeps_server, API modules, internal processing libraries).
• Annotations for important design decisions such as dependency scanning with two supported modes (goma vs. clang-scan-deps) and the integration patterns for various build systems (GN, CMake, etc.).