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