Skip to content

Instantly share code, notes, and snippets.

@craftslab
Last active July 17, 2022 05:01
Show Gist options
  • Save craftslab/3da05d4841b9b1e5d5bba28e9aa32b98 to your computer and use it in GitHub Desktop.
Save craftslab/3da05d4841b9b1e5d5bba28e9aa32b98 to your computer and use it in GitHub Desktop.
android rbe

RBE File

  • readme: build/soong/docs/rbe.md
  • reapi: https://github.com/bazelbuild/remote-apis
  • env: ANDROID_BUILD_ENVIRONMENT_CONFIG=rbe
  • env: ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR=build/soong/doc
  • config: build/soong/docs/rbe.json
  • build: build/make/core/rbe.mk
  • build: build/soong/ui/build/rbe.go
  • binary: prebuilts/remoteexecution-client/live

RBE Build

source build/envsetup.sh
lunch aosp_arm64-eng
ANDROID_BUILD_ENVIRONMENT_CONFIG=rbe ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR=build/soong/docs mmm bionic 2>&1 | tee android-rbe.log

RBE Stack

  • build/soong/docs/rbe.json
{
    "env": {
        "USE_RBE": "1",
        "RBE_R8_EXEC_STRATEGY": "remote_local_fallback",
        "RBE_CXX_EXEC_STRATEGY": "remote_local_fallback",
        "RBE_D8_EXEC_STRATEGY": "remote_local_fallback",
        "RBE_JAVAC_EXEC_STRATEGY": "remote_local_fallback",
        "RBE_JAVAC": "1",
        "RBE_R8": "1",
        "RBE_D8": "1",

        "RBE_instance": "projects/rbe-testing/instances/default_instance",
        "RBE_service": "asia-southeast1-remotebuildexecution.googleapis.com:443",

        "RBE_DIR": "prebuilts/remoteexecution-client/live",

        "RBE_use_application_default_credentials": "true",

        "RBE_log_dir": "/tmp",
        "RBE_output_dir": "/tmp",
        "RBE_proxy_log_dir": "/tmp"
    }
}
  • build/soong/ui/build/config.go
StartRBE
  • build/soong/ui/build/build.go
Build
  • build/soong/ui/build/rbe.go
startRBE
  • build/make/core/rbe.mk
RBE_WRAPPER := $(rbe_dir)/rewrapper
RBE_CXX := --labels=type=compile,lang=cpp,compiler=clang --env_var_allowlist=PWD --exec_strategy=$(cxx_rbe_exec_strategy) --platform=$(cxx_platform) --compare=$(cxx_compare)
CC_WRAPPER := $(strip $(CC_WRAPPER) $(RBE_WRAPPER) $(RBE_CXX))
CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(RBE_WRAPPER) $(RBE_CXX))
JAVAC_WRAPPER := $(strip $(JAVAC_WRAPPER) $(RBE_WRAPPER) --labels=type=compile,lang=java,compiler=javac --exec_strategy=$(javac_exec_strategy) --platform=$(java_r8_d8_platform))
R8_WRAPPER := $(strip $(RBE_WRAPPER) --labels=type=compile,compiler=r8 --exec_strategy=$(r8_exec_strategy) --platform=$(java_r8_d8_platform) --inputs=$(OUT_DIR)/soong/host/linux-x86/framework/r8-compat-proguard.jar,build/make/core/proguard_basic_keeps.flags --toolchain_inputs=prebuilts/jdk/jdk11/linux-x86/bin/java)
D8_WRAPPER := $(strip $(RBE_WRAPPER) --labels=type=compile,compiler=d8 --exec_strategy=$(d8_exec_strategy) --platform=$(java_r8_d8_platform) --inputs=$(OUT_DIR)/soong/host/linux-x86/framework/d8.jar --toolchain_inputs=prebuilts/jdk/jdk11/linux-x86/bin/java)
  • build/make/core/binary.mk
my_cc_wrapper := $(CC_WRAPPER)
my_cxx_wrapper := $(CXX_WRAPPER)
PRIVATE_CC := $(my_cc)
PRIVATE_CXX := $(my_cxx)
  • build/make/core/definitions.mk
transform-c-to-o
transform-cpp-to-o
compile-java
transform-jar-to-dex-r8
transform-classes.jar-to-dex

RBE Implementation

Bazel

BuildGrid

Goma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment