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 7import("//build/toolchain/remoteexec_defaults.gni") 8import("//build/toolchain/siso.gni") 9 10declare_args() { 11 # Deprecated: Please use reclient_bin_dir instead. 12 rbe_bin_dir = "" 13 14 # Deprecated: Please use reclient_cfg_dir instead. 15 rbe_cfg_dir = "" 16 17 # Deprecated: Please use reclient_cros_cc_wrapper instead. 18 rbe_cros_cc_wrapper = "" 19 20 # Execution root - this should be the root of the source tree. 21 # This is defined here instead of in the config file because 22 # this will vary depending on where the user has placed the 23 # chromium source on their system. 24 rbe_exec_root = rebase_path("//") 25 26 # Set to true to enable remote executions. 27 use_remoteexec = false 28} 29 30use_reclient_default = false 31if (use_remoteexec) { 32 if (use_siso) { 33 use_reclient_default = use_reclient_on_siso 34 } else { 35 use_reclient_default = use_reclient_on_ninja 36 } 37} 38 39declare_args() { 40 # Set to true to use re-client. 41 # Set to false to use Siso's builtin RBE client. 42 use_reclient = use_reclient_default 43 44 # The directory where the re-client tooling binaries are. 45 if (rbe_bin_dir != "") { 46 if (current_toolchain == default_toolchain) { 47 print( 48 "WARNING: rbe_bin_dir is deprecated. Please use reclient_bin_dir instead.") 49 } 50 reclient_bin_dir = rbe_bin_dir 51 } else { 52 reclient_bin_dir = rebase_path("//buildtools/reclient", root_build_dir) 53 } 54 55 # The directory where the re-client configuration files are. 56 if (rbe_cfg_dir != "") { 57 if (current_toolchain == default_toolchain) { 58 print( 59 "WARNING: rbe_cfg_dir is deprecated. Please use reclient_cfg_dir instead.") 60 } 61 reclient_cfg_dir = rbe_cfg_dir 62 } else { 63 reclient_cfg_dir = "//buildtools/reclient_cfgs" 64 } 65} 66 67# Check if any unsupported combination is specified. 68if (use_reclient) { 69 assert(use_remoteexec, "Can't enable Reclient when use_remoteexec is false") 70} 71 72if (use_remoteexec) { 73 rbe_logs = [ "use_remoteexec=true" ] 74} else { 75 rbe_logs = [ "use_remoteexec=false" ] 76} 77 78if (use_reclient) { 79 rbe_logs += [ "use_reclient=true" ] 80} else { 81 rbe_logs += [ "use_reclient=false" ] 82} 83 84# Siso native also uses rewrapper cfg file 85# to get remote platform property. 86use_reclient_cfgs = 87 use_reclient || (use_remoteexec && (host_os == "win" || host_os == "mac")) 88 89declare_args() { 90 # Set to the path of the RBE reclient configuration files. 91 # Configuration file selection based on operating system. 92 if (!use_reclient_cfgs) { 93 reclient_cc_cfg_file = "" 94 reclient_py_cfg_file = "" 95 } else if (use_reclient && host_os == "linux") { 96 reclient_py_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) + 97 "/python/rewrapper_linux.cfg" 98 reclient_cc_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) + 99 "/chromium-browser-clang/rewrapper_linux.cfg" 100 } else if (host_os == "win") { 101 reclient_py_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) + 102 "/python/rewrapper_windows.cfg" 103 reclient_cc_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) + 104 "/chromium-browser-clang/rewrapper_windows.cfg" 105 } else if (host_os == "mac") { 106 reclient_py_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) + 107 "/python/rewrapper_mac.cfg" 108 reclient_cc_cfg_file = rebase_path(reclient_cfg_dir, root_build_dir) + 109 "/chromium-browser-clang/rewrapper_mac.cfg" 110 } else { 111 reclient_cc_cfg_file = "" 112 reclient_py_cfg_file = "" 113 } 114 115 if (use_reclient) { 116 # TODO: crbug.com/342270134 - Rename reclient_cros_cc_wrapper to reclient_cros_cc_wrapper. 117 # Note that reclient_cros_cc_wrapper is referenced by CrOS's chromite. 118 # Set to the path of the RBE recleint wrapper for ChromeOS. 119 if (rbe_cros_cc_wrapper != "") { 120 if (current_toolchain == default_toolchain) { 121 print( 122 "WARNING: rbe_cros_cc_wrapper is deprecated. Please use reclient_cros_cc_wrapper instead.") 123 } 124 reclient_cros_cc_wrapper = rbe_cros_cc_wrapper 125 } else { 126 reclient_cros_cc_wrapper = "${reclient_bin_dir}/rewrapper" 127 } 128 } else { 129 reclient_cros_cc_wrapper = "" 130 } 131} 132 133if (use_reclient_cfgs && current_toolchain == default_toolchain) { 134 # Check existence of reclient configs and show user friendly error message if 135 # it doesn't. 136 if (!path_exists(reclient_cc_cfg_file)) { 137 # Use exec_script() to show a good error message. 138 exec_script(rebase_path("//build/toolchain/check_rewrapper_cfg.py"), 139 [ reclient_cc_cfg_file ], 140 "", 141 [ rebase_path(reclient_cc_cfg_file, ".", root_build_dir) ]) 142 } 143} 144