xref: /aosp_15_r20/build/make/core/rbe.mk (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1*9e94795aSAndroid Build Coastguard Worker#
2*9e94795aSAndroid Build Coastguard Worker# Copyright (C) 2019 The Android Open Source Project
3*9e94795aSAndroid Build Coastguard Worker#
4*9e94795aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
5*9e94795aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
6*9e94795aSAndroid Build Coastguard Worker# You may obtain a copy of the License at
7*9e94795aSAndroid Build Coastguard Worker#
8*9e94795aSAndroid Build Coastguard Worker#      http://www.apache.org/licenses/LICENSE-2.0
9*9e94795aSAndroid Build Coastguard Worker#
10*9e94795aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
11*9e94795aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
12*9e94795aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*9e94795aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
14*9e94795aSAndroid Build Coastguard Worker# limitations under the License.
15*9e94795aSAndroid Build Coastguard Worker#
16*9e94795aSAndroid Build Coastguard Worker
17*9e94795aSAndroid Build Coastguard Worker# Notice: this works only with Google's RBE service.
18*9e94795aSAndroid Build Coastguard Workerifneq ($(filter-out false,$(USE_RBE)),)
19*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_DIR
20*9e94795aSAndroid Build Coastguard Worker    rbe_dir := $(RBE_DIR)
21*9e94795aSAndroid Build Coastguard Worker  else
22*9e94795aSAndroid Build Coastguard Worker    rbe_dir := prebuilts/remoteexecution-client/live/
23*9e94795aSAndroid Build Coastguard Worker  endif
24*9e94795aSAndroid Build Coastguard Worker
25*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_CXX_POOL
26*9e94795aSAndroid Build Coastguard Worker    cxx_pool := $(RBE_CXX_POOL)
27*9e94795aSAndroid Build Coastguard Worker  else
28*9e94795aSAndroid Build Coastguard Worker    cxx_pool := default
29*9e94795aSAndroid Build Coastguard Worker  endif
30*9e94795aSAndroid Build Coastguard Worker
31*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_JAVA_POOL
32*9e94795aSAndroid Build Coastguard Worker    java_pool := $(RBE_JAVA_POOL)
33*9e94795aSAndroid Build Coastguard Worker  else
34*9e94795aSAndroid Build Coastguard Worker    java_pool := java16
35*9e94795aSAndroid Build Coastguard Worker  endif
36*9e94795aSAndroid Build Coastguard Worker
37*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_CXX_EXEC_STRATEGY
38*9e94795aSAndroid Build Coastguard Worker    cxx_rbe_exec_strategy := $(RBE_CXX_EXEC_STRATEGY)
39*9e94795aSAndroid Build Coastguard Worker  else
40*9e94795aSAndroid Build Coastguard Worker    cxx_rbe_exec_strategy := local
41*9e94795aSAndroid Build Coastguard Worker  endif
42*9e94795aSAndroid Build Coastguard Worker
43*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_CXX_COMPARE
44*9e94795aSAndroid Build Coastguard Worker    cxx_compare := $(RBE_CXX_COMPARE)
45*9e94795aSAndroid Build Coastguard Worker  else
46*9e94795aSAndroid Build Coastguard Worker    cxx_compare := false
47*9e94795aSAndroid Build Coastguard Worker  endif
48*9e94795aSAndroid Build Coastguard Worker
49*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_JAVAC_EXEC_STRATEGY
50*9e94795aSAndroid Build Coastguard Worker    javac_exec_strategy := $(RBE_JAVAC_EXEC_STRATEGY)
51*9e94795aSAndroid Build Coastguard Worker  else
52*9e94795aSAndroid Build Coastguard Worker    javac_exec_strategy := remote_local_fallback
53*9e94795aSAndroid Build Coastguard Worker  endif
54*9e94795aSAndroid Build Coastguard Worker
55*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_R8_EXEC_STRATEGY
56*9e94795aSAndroid Build Coastguard Worker    r8_exec_strategy := $(RBE_R8_EXEC_STRATEGY)
57*9e94795aSAndroid Build Coastguard Worker  else
58*9e94795aSAndroid Build Coastguard Worker    r8_exec_strategy := remote_local_fallback
59*9e94795aSAndroid Build Coastguard Worker  endif
60*9e94795aSAndroid Build Coastguard Worker
61*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_D8_EXEC_STRATEGY
62*9e94795aSAndroid Build Coastguard Worker    d8_exec_strategy := $(RBE_D8_EXEC_STRATEGY)
63*9e94795aSAndroid Build Coastguard Worker  else
64*9e94795aSAndroid Build Coastguard Worker    d8_exec_strategy := remote_local_fallback
65*9e94795aSAndroid Build Coastguard Worker  endif
66*9e94795aSAndroid Build Coastguard Worker
67*9e94795aSAndroid Build Coastguard Worker  platform := container-image=docker://gcr.io/androidbuild-re-dockerimage/android-build-remoteexec-image@sha256:1eb7f64b9e17102b970bd7a1af7daaebdb01c3fb777715899ef462d6c6d01a45
68*9e94795aSAndroid Build Coastguard Worker  cxx_platform := $(platform),Pool=$(cxx_pool)
69*9e94795aSAndroid Build Coastguard Worker  java_r8_d8_platform := $(platform),Pool=$(java_pool)
70*9e94795aSAndroid Build Coastguard Worker
71*9e94795aSAndroid Build Coastguard Worker  RBE_WRAPPER := $(rbe_dir)/rewrapper
72*9e94795aSAndroid Build Coastguard Worker  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)
73*9e94795aSAndroid Build Coastguard Worker
74*9e94795aSAndroid Build Coastguard Worker  # Append rewrapper to existing *_WRAPPER variables so it's possible to
75*9e94795aSAndroid Build Coastguard Worker  # use both ccache and rewrapper.
76*9e94795aSAndroid Build Coastguard Worker  CC_WRAPPER := $(strip $(CC_WRAPPER) $(RBE_WRAPPER) $(RBE_CXX))
77*9e94795aSAndroid Build Coastguard Worker  CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(RBE_WRAPPER) $(RBE_CXX))
78*9e94795aSAndroid Build Coastguard Worker
79*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_JAVAC
80*9e94795aSAndroid Build Coastguard Worker    JAVAC_WRAPPER := $(strip $(JAVAC_WRAPPER) $(RBE_WRAPPER) --labels=type=compile,lang=java,compiler=javac --exec_strategy=$(javac_exec_strategy) --platform=$(java_r8_d8_platform))
81*9e94795aSAndroid Build Coastguard Worker  endif
82*9e94795aSAndroid Build Coastguard Worker
83*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_R8
84*9e94795aSAndroid Build Coastguard Worker    R8_WRAPPER := $(strip $(RBE_WRAPPER) --labels=type=compile,compiler=r8 --exec_strategy=$(r8_exec_strategy) --platform=$(java_r8_d8_platform) --inputs=$(OUT_DIR)/host/linux-x86/framework/r8.jar,build/make/core/proguard_basic_keeps.flags --toolchain_inputs=$(firstword $(JAVA)))
85*9e94795aSAndroid Build Coastguard Worker  endif
86*9e94795aSAndroid Build Coastguard Worker
87*9e94795aSAndroid Build Coastguard Worker  ifdef RBE_D8
88*9e94795aSAndroid Build Coastguard Worker    D8_WRAPPER := $(strip $(RBE_WRAPPER) --labels=type=compile,compiler=d8 --exec_strategy=$(d8_exec_strategy) --platform=$(java_r8_d8_platform) --inputs=$(OUT_DIR)/host/linux-x86/framework/d8.jar --toolchain_inputs=$(firstword $(JAVA)))
89*9e94795aSAndroid Build Coastguard Worker  endif
90*9e94795aSAndroid Build Coastguard Worker
91*9e94795aSAndroid Build Coastguard Worker  rbe_dir :=
92*9e94795aSAndroid Build Coastguard Workerendif
93*9e94795aSAndroid Build Coastguard Worker
94