| # Copyright 2021 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Ninja `restat` can lead to on-the-fly pruning of the overall action graph, |
| # when intermediate files are unchanged as a result of re-running an action. |
| |
| import("//build/config/python_interpreter.gni") |
| import("//build/toolchain/rbe.gni") |
| |
| # This script transforms any command to be restat-friendly by redirecting |
| # outputs to a temporary location, followed by move-if-changed. |
| # re-client supports this behavior directly with |
| # --preserve_unchanged_output_mtime (which suppresses downloading over |
| # unchanged files), so this script is only needed for non-RBE build actions. |
| restat_wrapper = "//build/tracer/restat_cacher.py" |
| |
| declare_args() { |
| # Set to true to make Rust compiles preserve timestamps of unchanged outputs. |
| restat_rust = true |
| |
| # Set to true to make C++ compiles preserve timestamps of unchanged outputs. |
| # re-client provides this feature out-of-the-box with |
| # --preserve_unchanged_output_mtime, so it makes sense to default to true |
| # when using `cxx_rbe_enable`. When not using re-client, you can still |
| # get write-if-change behavior through the `restat_wrapper` script, |
| # but at the cost of the wrapper overhead (tradeoff vs. action pruning). |
| restat_cc = cxx_rbe_enable |
| } |
| |
| # Each of `.local` and `.remote` is a list to be prepended to a tool() command |
| # (joined with spaces) when the corresponding `restat_*` setting is enabled. |
| restat_command_launcher = { |
| # Local-only execution may use this wrapper script directly. |
| local = [ |
| rebase_path(python_exe_src, root_build_dir), |
| "-S", |
| rebase_path(restat_wrapper, root_build_dir), |
| "--outputs", |
| "{{output}}", |
| "{{DEPFILE}}", |
| "--", |
| ] |
| |
| # For remote-building, --preserve_unchanged_output_mtime is sufficient to |
| # preserve timestamps of unchanged outputs, and provide restat benefit. |
| # However, in modes that also (conditionally) use local execution |
| # (i.e. --exec_strategy={racing,remote_local_fallback}), the local execution |
| # could unconditionally overwrite outputs. While this may be suboptimal as a |
| # missed opportunity to prune the action graph, it does not violate |
| # correctness. |
| remote = [] |
| } |