xref: /aosp_15_r20/external/angle/build/toolchain/rbe.gni (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2024 The Chromium Authors
2*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
3*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file.
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard Worker# Defines the configuration of Remote Build Execution (RBE).
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Workeruse_remoteexec_default =
8*8975f5c5SAndroid Build Coastguard Worker    exec_script(rebase_path("//build/toolchain/use_remoteexec_value.py"),
9*8975f5c5SAndroid Build Coastguard Worker                [],
10*8975f5c5SAndroid Build Coastguard Worker                "value",
11*8975f5c5SAndroid Build Coastguard Worker                [])
12*8975f5c5SAndroid Build Coastguard Worker
13*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
14*8975f5c5SAndroid Build Coastguard Worker  # Deprecated: Please use reclient_bin_dir instead.
15*8975f5c5SAndroid Build Coastguard Worker  rbe_bin_dir = ""
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard Worker  # Deprecated: Please use reclient_cfg_dir instead.
18*8975f5c5SAndroid Build Coastguard Worker  rbe_cfg_dir = ""
19*8975f5c5SAndroid Build Coastguard Worker
20*8975f5c5SAndroid Build Coastguard Worker  # Deprecated: Please use reclient_cros_cc_wrapper instead.
21*8975f5c5SAndroid Build Coastguard Worker  rbe_cros_cc_wrapper = ""
22*8975f5c5SAndroid Build Coastguard Worker
23*8975f5c5SAndroid Build Coastguard Worker  # Execution root - this should be the root of the source tree.
24*8975f5c5SAndroid Build Coastguard Worker  # This is defined here instead of in the config file because
25*8975f5c5SAndroid Build Coastguard Worker  # this will vary depending on where the user has placed the
26*8975f5c5SAndroid Build Coastguard Worker  # chromium source on their system.
27*8975f5c5SAndroid Build Coastguard Worker  rbe_exec_root = rebase_path("//")
28*8975f5c5SAndroid Build Coastguard Worker
29*8975f5c5SAndroid Build Coastguard Worker  # Set to true to enable remote executions.
30*8975f5c5SAndroid Build Coastguard Worker  use_remoteexec = use_remoteexec_default
31*8975f5c5SAndroid Build Coastguard Worker}
32*8975f5c5SAndroid Build Coastguard Worker
33*8975f5c5SAndroid Build Coastguard Workeruse_reclient_default = false
34*8975f5c5SAndroid Build Coastguard Workerif (use_remoteexec && current_toolchain == default_toolchain) {
35*8975f5c5SAndroid Build Coastguard Worker  use_reclient_default =
36*8975f5c5SAndroid Build Coastguard Worker      exec_script(rebase_path("//build/toolchain/use_reclient_value.py"),
37*8975f5c5SAndroid Build Coastguard Worker                  [],
38*8975f5c5SAndroid Build Coastguard Worker                  "value",
39*8975f5c5SAndroid Build Coastguard Worker                  [])
40*8975f5c5SAndroid Build Coastguard Worker}
41*8975f5c5SAndroid Build Coastguard Worker
42*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
43*8975f5c5SAndroid Build Coastguard Worker  # Set to true to use re-client.
44*8975f5c5SAndroid Build Coastguard Worker  # Set to false to use Siso's builtin RBE client.
45*8975f5c5SAndroid Build Coastguard Worker  use_reclient = use_reclient_default
46*8975f5c5SAndroid Build Coastguard Worker
47*8975f5c5SAndroid Build Coastguard Worker  # The directory where the re-client tooling binaries are.
48*8975f5c5SAndroid Build Coastguard Worker  if (rbe_bin_dir != "") {
49*8975f5c5SAndroid Build Coastguard Worker    if (current_toolchain == default_toolchain) {
50*8975f5c5SAndroid Build Coastguard Worker      print(
51*8975f5c5SAndroid Build Coastguard Worker          "WARNING: rbe_bin_dir is deprecated. Please use reclient_bin_dir instead.")
52*8975f5c5SAndroid Build Coastguard Worker    }
53*8975f5c5SAndroid Build Coastguard Worker    reclient_bin_dir = rbe_bin_dir
54*8975f5c5SAndroid Build Coastguard Worker  } else {
55*8975f5c5SAndroid Build Coastguard Worker    reclient_bin_dir = rebase_path("//buildtools/reclient", root_build_dir)
56*8975f5c5SAndroid Build Coastguard Worker  }
57*8975f5c5SAndroid Build Coastguard Worker
58*8975f5c5SAndroid Build Coastguard Worker  # The directory where the re-client configuration files are.
59*8975f5c5SAndroid Build Coastguard Worker  if (rbe_cfg_dir != "") {
60*8975f5c5SAndroid Build Coastguard Worker    if (current_toolchain == default_toolchain) {
61*8975f5c5SAndroid Build Coastguard Worker      print(
62*8975f5c5SAndroid Build Coastguard Worker          "WARNING: rbe_cfg_dir is deprecated. Please use reclient_cfg_dir instead.")
63*8975f5c5SAndroid Build Coastguard Worker    }
64*8975f5c5SAndroid Build Coastguard Worker    reclient_cfg_dir = rbe_cfg_dir
65*8975f5c5SAndroid Build Coastguard Worker  } else {
66*8975f5c5SAndroid Build Coastguard Worker    reclient_cfg_dir = "//buildtools/reclient_cfgs"
67*8975f5c5SAndroid Build Coastguard Worker  }
68*8975f5c5SAndroid Build Coastguard Worker}
69*8975f5c5SAndroid Build Coastguard Worker
70*8975f5c5SAndroid Build Coastguard Worker# Check if any unsupported combination is specified.
71*8975f5c5SAndroid Build Coastguard Workerif (use_reclient) {
72*8975f5c5SAndroid Build Coastguard Worker  assert(use_remoteexec, "Can't enable Reclient when use_remoteexec is false")
73*8975f5c5SAndroid Build Coastguard Worker}
74*8975f5c5SAndroid Build Coastguard Worker
75*8975f5c5SAndroid Build Coastguard Workerif (use_remoteexec) {
76*8975f5c5SAndroid Build Coastguard Worker  rbe_logs = [ "use_remoteexec=true" ]
77*8975f5c5SAndroid Build Coastguard Worker} else {
78*8975f5c5SAndroid Build Coastguard Worker  rbe_logs = [ "use_remoteexec=false" ]
79*8975f5c5SAndroid Build Coastguard Worker}
80*8975f5c5SAndroid Build Coastguard Worker
81*8975f5c5SAndroid Build Coastguard Workerif (use_reclient) {
82*8975f5c5SAndroid Build Coastguard Worker  rbe_logs += [ "use_reclient=true" ]
83*8975f5c5SAndroid Build Coastguard Worker} else {
84*8975f5c5SAndroid Build Coastguard Worker  rbe_logs += [ "use_reclient=false" ]
85*8975f5c5SAndroid Build Coastguard Worker}
86*8975f5c5SAndroid Build Coastguard Worker
87*8975f5c5SAndroid Build Coastguard Worker# Siso native also uses rewrapper cfg file
88*8975f5c5SAndroid Build Coastguard Worker# to get remote platform property.
89*8975f5c5SAndroid Build Coastguard Workeruse_reclient_cfgs =
90*8975f5c5SAndroid Build Coastguard Worker    use_reclient || (use_remoteexec && (host_os == "win" || host_os == "mac"))
91*8975f5c5SAndroid Build Coastguard Worker
92*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
93*8975f5c5SAndroid Build Coastguard Worker  # Set to the path of the RBE reclient configuration files.
94*8975f5c5SAndroid Build Coastguard Worker  # Configuration file selection based on operating system.
95*8975f5c5SAndroid Build Coastguard Worker  if (!use_reclient_cfgs) {
96*8975f5c5SAndroid Build Coastguard Worker    reclient_cc_cfg_file = ""
97*8975f5c5SAndroid Build Coastguard Worker    reclient_py_cfg_file = ""
98*8975f5c5SAndroid Build Coastguard Worker    reclient_py_large_cfg_file = ""
99*8975f5c5SAndroid Build Coastguard Worker  } else if (use_reclient && host_os == "linux") {
100*8975f5c5SAndroid Build Coastguard Worker    reclient_py_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
101*8975f5c5SAndroid Build Coastguard Worker                           "/python/rewrapper_linux.cfg"
102*8975f5c5SAndroid Build Coastguard Worker    reclient_py_large_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
103*8975f5c5SAndroid Build Coastguard Worker                                 "/python/rewrapper_linux_large.cfg"
104*8975f5c5SAndroid Build Coastguard Worker    reclient_cc_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
105*8975f5c5SAndroid Build Coastguard Worker                           "/chromium-browser-clang/rewrapper_linux.cfg"
106*8975f5c5SAndroid Build Coastguard Worker  } else if (host_os == "win") {
107*8975f5c5SAndroid Build Coastguard Worker    reclient_py_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
108*8975f5c5SAndroid Build Coastguard Worker                           "/python/rewrapper_windows.cfg"
109*8975f5c5SAndroid Build Coastguard Worker    reclient_py_large_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
110*8975f5c5SAndroid Build Coastguard Worker                                 "/python/rewrapper_windows_large.cfg"
111*8975f5c5SAndroid Build Coastguard Worker    reclient_cc_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
112*8975f5c5SAndroid Build Coastguard Worker                           "/chromium-browser-clang/rewrapper_windows.cfg"
113*8975f5c5SAndroid Build Coastguard Worker  } else if (host_os == "mac") {
114*8975f5c5SAndroid Build Coastguard Worker    reclient_py_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
115*8975f5c5SAndroid Build Coastguard Worker                           "/python/rewrapper_mac.cfg"
116*8975f5c5SAndroid Build Coastguard Worker    reclient_py_large_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
117*8975f5c5SAndroid Build Coastguard Worker                                 "/python/rewrapper_mac_large.cfg"
118*8975f5c5SAndroid Build Coastguard Worker    reclient_cc_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) +
119*8975f5c5SAndroid Build Coastguard Worker                           "/chromium-browser-clang/rewrapper_mac.cfg"
120*8975f5c5SAndroid Build Coastguard Worker  } else {
121*8975f5c5SAndroid Build Coastguard Worker    reclient_cc_cfg_file = ""
122*8975f5c5SAndroid Build Coastguard Worker    reclient_py_cfg_file = ""
123*8975f5c5SAndroid Build Coastguard Worker    reclient_py_large_cfg_file = ""
124*8975f5c5SAndroid Build Coastguard Worker  }
125*8975f5c5SAndroid Build Coastguard Worker
126*8975f5c5SAndroid Build Coastguard Worker  if (use_reclient) {
127*8975f5c5SAndroid Build Coastguard Worker    # TODO: crbug.com/342270134 - Rename reclient_cros_cc_wrapper to reclient_cros_cc_wrapper.
128*8975f5c5SAndroid Build Coastguard Worker    # Note that reclient_cros_cc_wrapper is referenced by CrOS's chromite.
129*8975f5c5SAndroid Build Coastguard Worker    # Set to the path of the RBE recleint wrapper for ChromeOS.
130*8975f5c5SAndroid Build Coastguard Worker    if (rbe_cros_cc_wrapper != "") {
131*8975f5c5SAndroid Build Coastguard Worker      if (current_toolchain == default_toolchain) {
132*8975f5c5SAndroid Build Coastguard Worker        print(
133*8975f5c5SAndroid Build Coastguard Worker            "WARNING: rbe_cros_cc_wrapper is deprecated. Please use reclient_cros_cc_wrapper instead.")
134*8975f5c5SAndroid Build Coastguard Worker      }
135*8975f5c5SAndroid Build Coastguard Worker      reclient_cros_cc_wrapper = rbe_cros_cc_wrapper
136*8975f5c5SAndroid Build Coastguard Worker    } else {
137*8975f5c5SAndroid Build Coastguard Worker      reclient_cros_cc_wrapper = "${reclient_bin_dir}/rewrapper"
138*8975f5c5SAndroid Build Coastguard Worker    }
139*8975f5c5SAndroid Build Coastguard Worker  } else {
140*8975f5c5SAndroid Build Coastguard Worker    reclient_cros_cc_wrapper = ""
141*8975f5c5SAndroid Build Coastguard Worker  }
142*8975f5c5SAndroid Build Coastguard Worker}
143*8975f5c5SAndroid Build Coastguard Worker
144*8975f5c5SAndroid Build Coastguard Workerif (use_reclient_cfgs && current_toolchain == default_toolchain) {
145*8975f5c5SAndroid Build Coastguard Worker  # Check existence of reclient configs and show user friendly error message if
146*8975f5c5SAndroid Build Coastguard Worker  # it doesn't.
147*8975f5c5SAndroid Build Coastguard Worker  exec_script(rebase_path("//build/toolchain/check_rewrapper_cfg.py"),
148*8975f5c5SAndroid Build Coastguard Worker              [ reclient_cc_cfg_file ],
149*8975f5c5SAndroid Build Coastguard Worker              "",
150*8975f5c5SAndroid Build Coastguard Worker              [ rebase_path(reclient_cc_cfg_file, ".", root_build_dir) ])
151*8975f5c5SAndroid Build Coastguard Worker}
152*8975f5c5SAndroid Build Coastguard Worker
153*8975f5c5SAndroid Build Coastguard Worker# TODO(crbug.com/326584510): Reclient does not upload `inputs` from C/C++
154*8975f5c5SAndroid Build Coastguard Worker# targets. This file is added to `inputs` for all C targets in
155*8975f5c5SAndroid Build Coastguard Worker# //build/config/BUILDCONFIG.gn. We work around the bug in Reclient by
156*8975f5c5SAndroid Build Coastguard Worker# specifying the file here.
157*8975f5c5SAndroid Build Coastguard Worker#
158*8975f5c5SAndroid Build Coastguard Worker# This is a comma-delimited list of paths relative to the source tree root. The
159*8975f5c5SAndroid Build Coastguard Worker# leading space is important, if the string is non-empty. :)
160*8975f5c5SAndroid Build Coastguard Workerrbe_bug_326584510_missing_inputs = ""
161*8975f5c5SAndroid Build Coastguard Workerif (defined(clang_unsafe_buffers_paths) &&
162*8975f5c5SAndroid Build Coastguard Worker    "$clang_unsafe_buffers_paths" != "") {
163*8975f5c5SAndroid Build Coastguard Worker  from_exec_root = rebase_path(clang_unsafe_buffers_paths, rbe_exec_root)
164*8975f5c5SAndroid Build Coastguard Worker  rbe_bug_326584510_missing_inputs = " -inputs=$from_exec_root"
165*8975f5c5SAndroid Build Coastguard Worker}
166