platform_build_soong/docs/rbe.md
Elliott Hughes 10363161e7 "master" was renamed "main".
Test: N/A
Change-Id: I86d5578eaac260e55a9583db7ab49812b4ba1f5d
2024-01-09 22:09:07 +00:00

2.6 KiB

Build Android Platform on Remote Build Execution

Soong is integrated with Google's Remote Build Execution(RBE) service, which implements the Remote Executaion API.

With RBE enabled, it can speed up the Android Platform builds by distributing build actions through a worker pool sharing a central cache of build results.

Configuration

To enable RBE, you need to set several environment variables before triggering the build. You can set them through a environment variables config file. As an example, build/soong/docs/rbe.json is a config that enables RBE in the build. Once the config file is created, you need to let Soong load the config file by specifying ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR environment variable and ANDROID_BUILD_ENVIRONMENT_CONFIG environment variable. The following command starts Soong with build/soong/docs/rbe.json loaded:

ANDROID_BUILD_ENVIRONMENT_CONFIG=rbe \
ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR=build/soong/doc \
  build/soong/soong_ui.bash

Configuration Explanation

Below a brief explanation of each field in build/soong/docs/rbe.json:

USE_RBE:

If set to 1, enable RBE for the build.

RBE_CXX_EXEC_STRATEGY / RBE_JAVAC_EXEC_STRATEGY / RBE_R8_EXEC_STRATEGY / RBE_D8_EXEC_STRATEGY:

Sets strategies for C++/javac/r8/d8 action types. Available options are (Note: all options will update the remote cache if the right permissions to update cache are given to the user.):

  • local: Only execute locally.
  • remote: Only execute remotely.
  • remote_local_fallback: Try executing remotely and fall back to local execution if failed.
  • racing: Race remote execution and local execution and use the earlier result.
RBE_JAVAC / RBE_R8 / RBE_D8

If set to 1, enable javac/r8/d8 support. C++ compilation is enabled by default.

RBE_service / RBE_instance

The remote execution service endpoint and instance ID to target when calling remote execution via gRPC to execute actions.

RBE_DIR

Where to find remote client binaries (rewrapper, reproxy)

RBE_use_application_default_credentials

reclient uses application default credentials for autentication, as generated by gcloud auth application-default login

RBE_log_dir/RBE_proxy_log_dir/RBE_output_dir

Logs generated by rewrapper and reproxy will go here.