xref: /aosp_15_r20/external/cronet/build/toolchain/rbe.gni (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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
7declare_args() {
8  # The directory where the re-client tooling binaries are.
9  rbe_bin_dir = rebase_path("//buildtools/reclient", root_build_dir)
10
11  # Execution root - this should be the root of the source tree.
12  # This is defined here instead of in the config file because
13  # this will vary depending on where the user has placed the
14  # chromium source on their system.
15  rbe_exec_root = rebase_path("//")
16
17  # Set to true to enable remote compilation using reclient.
18  use_remoteexec = false
19
20  # Set to true to enable remote linking using reclient.
21  use_remoteexec_links = false
22
23  # The directory where the re-client configuration files are.
24  rbe_cfg_dir = "//buildtools/reclient_cfgs"
25}
26
27declare_args() {
28  # Set to the path of the RBE reclient configuration files.
29  # Configuration file selection based on operating system.
30  if (host_os == "linux") {
31    rbe_py_cfg_file =
32        rebase_path(rbe_cfg_dir, root_build_dir) + "/python/rewrapper_linux.cfg"
33    rbe_py_large_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
34                            "/python/rewrapper_linux_large.cfg"
35    rbe_cc_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
36                      "/chromium-browser-clang/rewrapper_linux.cfg"
37    rbe_link_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
38                        "/chromium-browser-clang/rewrapper_linux_link.cfg"
39  } else if (host_os == "win") {
40    rbe_py_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
41                      "/python/rewrapper_windows.cfg"
42    rbe_py_large_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
43                            "/python/rewrapper_windows_large.cfg"
44    rbe_cc_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
45                      "/chromium-browser-clang/rewrapper_windows.cfg"
46    rbe_link_cfg_file = ""
47  } else if (host_os == "mac") {
48    rbe_py_cfg_file =
49        rebase_path(rbe_cfg_dir, root_build_dir) + "/python/rewrapper_mac.cfg"
50    rbe_py_large_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
51                            "/python/rewrapper_mac_large.cfg"
52    rbe_cc_cfg_file = rebase_path(rbe_cfg_dir, root_build_dir) +
53                      "/chromium-browser-clang/rewrapper_mac.cfg"
54    rbe_link_cfg_file = ""
55  } else {
56    rbe_linkcfg_file = ""
57    rbe_py_cfg_file = ""
58    rbe_cc_cfg_file = ""
59  }
60
61  # Set to the path of the RBE recleint wrapper for ChromeOS.
62  rbe_cros_cc_wrapper = "${rbe_bin_dir}/rewrapper"
63}
64
65if (use_remoteexec && current_toolchain == default_toolchain) {
66  # Check existence of reclient configs and show user friendly error message if
67  # it doesn't.
68  exec_script(rebase_path("//build/toolchain/check_rewrapper_cfg.py"),
69              [ rbe_cc_cfg_file ],
70              "",
71              [ rebase_path(rbe_cc_cfg_file, ".", root_build_dir) ])
72}
73
74if (is_win) {
75  if (use_remoteexec_links) {
76    print("For now, remote linking is not available for Windows.")
77    use_remoteexec_links = false
78  }
79}
80if (is_mac || is_ios) {
81  if (use_remoteexec_links) {
82    print("For now, remote linking is not available on Macs.")
83    use_remoteexec_links = false
84  }
85}
86
87# TODO(crbug.com/326584510): Reclient does not upload `inputs` from C/C++
88# targets. This file is added to `inputs` for all C targets in
89# //build/config/BUILDCONFIG.gn. We work around the bug in Reclient by
90# specifying the file here.
91#
92# This is a comma-delimited list of paths relative to the source tree root. The
93# leading space is important, if the string is non-empty. :)
94rbe_bug_326584510_missing_inputs = ""
95if (defined(clang_unsafe_buffers_paths) &&
96    "$clang_unsafe_buffers_paths" != "") {
97  from_exec_root = rebase_path(clang_unsafe_buffers_paths, rbe_exec_root)
98  rbe_bug_326584510_missing_inputs = " -inputs=$from_exec_root"
99}
100