| # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/toolchain/goma.gni") |
| import("//build/toolchain/rbe.gni") |
| |
| # Defines the configuration of cc wrapper |
| # ccache: a c/c++ compiler cache which can greatly reduce recompilation times. |
| # icecc, distcc: it takes compile jobs from a build and distributes them among |
| # remote machines allowing a parallel build. |
| # |
| # TIPS |
| # |
| # 1) ccache |
| # Set clang_use_chrome_plugins=false if using ccache 3.1.9 or earlier, since |
| # these versions don't support -Xclang. (3.1.10 and later will silently |
| # ignore -Xclang, so it doesn't matter if you disable clang_use_chrome_plugins |
| # or not). |
| # |
| # Use ccache 3.2 or later to avoid clang unused argument warnings: |
| # https://bugzilla.samba.org/show_bug.cgi?id=8118 |
| # |
| # To avoid -Wparentheses-equality clang warnings, at some cost in terms of |
| # speed, you can do: |
| # export CCACHE_CPP2=yes |
| # |
| # 2) icecc |
| # Set clang_use_chrome_plugins=false because icecc cannot distribute custom |
| # clang libraries. |
| # |
| # To use icecc and ccache together, set cc_wrapper = "ccache" with |
| # export CCACHE_PREFIX=icecc |
| |
| declare_args() { |
| # Set to "ccache", "icecc" or "distcc". Probably doesn't work on windows. |
| cc_wrapper = "" |
| |
| if (is_starboard) { |
| enable_sccache = getenv("SCCACHE") == "1" |
| } |
| } |
| |
| if (is_starboard) { |
| declare_args() { |
| # Set to false to completely ignore the cc_wrapper. |
| enable_cc_wrapper = true |
| } |
| assert(enable_cc_wrapper || cc_wrapper == "", |
| "Do not set `cc_wrapper` if you set `enable_cc_wrapper` to false.") |
| } |
| |
| if (is_starboard && getenv("SCCACHE") == "") { |
| enable_sccache = host_os == "win" && cobalt_fastbuild |
| } |
| |
| if (is_starboard && enable_sccache) { |
| _set_sccache_gcs_bucket = getenv("SCCACHE_GCS_BUCKET") != "" |
| _set_sccache_gcs_key_path = getenv("SCCACHE_GCS_KEY_PATH") != "" |
| _set_sccache_gcs_oauth_url = getenv("SCCACHE_GCS_OAUTH_URL") != "" |
| _set_sccache_gcs_rw_mode = getenv("SCCACHE_GCS_RW_MODE") != "" |
| _set_sccache_dir = getenv("SCCACHE_DIR") != "" |
| assert(_set_sccache_dir || |
| (_set_sccache_gcs_bucket && |
| (_set_sccache_gcs_key_path || _set_sccache_gcs_oauth_url) && |
| _set_sccache_gcs_rw_mode), |
| "Set Sccache environment variables before use.") |
| } |
| |
| if (is_starboard && cc_wrapper == "" && enable_cc_wrapper) { |
| # TODO(https://crbug.com/gn/273): Use sccache locally as well. |
| if (enable_sccache) { |
| cc_wrapper = "sccache" |
| } else if (host_os != "win") { |
| cc_wrapper = "ccache" |
| } |
| print("Build Accelerator: " + cc_wrapper) |
| } |
| |
| assert(!use_goma || cc_wrapper == "", |
| "use_goma and cc_wrapper can not be used together.") |
| assert(!use_rbe || cc_wrapper == "", |
| "use_rbe and cc_wrapper can not be used together.") |