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