xref: /aosp_15_r20/build/soong/docs/rbe.md (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1# Build Android Platform on Remote Build Execution
2
3Soong is integrated with Google's Remote Build Execution(RBE) service, which
4implements the
5[Remote Executaion API](https://github.com/bazelbuild/remote-apis).
6
7With RBE enabled, it can speed up the Android Platform builds by distributing
8build actions through a worker pool sharing a central cache of build results.
9
10## Configuration
11
12To enable RBE, you need to set several environment variables before triggering
13the build. You can set them through a
14[environment variables config file](https://android.googlesource.com/platform/build/soong/+/main/README.md#environment-variables-config-file).
15As an example, [build/soong/docs/rbe.json](rbe.json) is a config that enables
16RBE in the build. Once the config file is created, you need to let Soong load
17the config file by specifying `ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR` environment
18variable and `ANDROID_BUILD_ENVIRONMENT_CONFIG` environment variable. The
19following command starts Soong with [build/soong/docs/rbe.json](rbe.json)
20loaded:
21
22```shell
23ANDROID_BUILD_ENVIRONMENT_CONFIG=rbe \
24ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR=build/soong/doc \
25  build/soong/soong_ui.bash
26```
27
28### Configuration Explanation
29
30Below a brief explanation of each field in
31[build/soong/docs/rbe.json](rbe.json):
32
33##### USE\_RBE:
34If set to 1, enable RBE for the build.
35
36##### RBE\_CXX\_EXEC\_STRATEGY / RBE\_JAVAC\_EXEC\_STRATEGY / RBE\_R8\_EXEC\_STRATEGY / RBE\_D8\_EXEC\_STRATEGY:
37
38Sets strategies for C++/javac/r8/d8 action types. Available options are
39(**Note**: all options will update the remote cache if the right permissions to
40update cache are given to the user.):
41
42*   **local**: Only execute locally.
43*   **remote**: Only execute remotely.
44*   **remote_local_fallback**: Try executing remotely and fall back to local
45    execution if failed.
46*   **racing**: Race remote execution and local execution and use the earlier
47    result.
48
49##### RBE\_JAVAC / RBE\_R8 / RBE\_D8
50
51If set to 1, enable javac/r8/d8 support. C++ compilation is enabled by default.
52
53##### RBE\_service / RBE\_instance
54
55The remote execution service endpoint and instance ID to target when calling
56remote execution via gRPC to execute actions.
57
58##### RBE\_DIR
59
60Where to find remote client binaries (rewrapper, reproxy)
61
62##### RBE\_use\_application\_default\_credentials
63
64reclient uses
65[application default credentials](https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login)
66for autentication, as generated by `gcloud auth application-default login`
67
68##### RBE\_log\_dir/RBE\_proxy\_log\_dir/RBE\_output\_dir
69
70Logs generated by rewrapper and reproxy will go here.
71