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