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