1*bcb5dc79SHONG Yifan# Copyright 2022 The Bazel Authors. All rights reserved. 2*bcb5dc79SHONG Yifan# 3*bcb5dc79SHONG Yifan# Licensed under the Apache License, Version 2.0 (the "License"); 4*bcb5dc79SHONG Yifan# you may not use this file except in compliance with the License. 5*bcb5dc79SHONG Yifan# You may obtain a copy of the License at 6*bcb5dc79SHONG Yifan# 7*bcb5dc79SHONG Yifan# http://www.apache.org/licenses/LICENSE-2.0 8*bcb5dc79SHONG Yifan# 9*bcb5dc79SHONG Yifan# Unless required by applicable law or agreed to in writing, software 10*bcb5dc79SHONG Yifan# distributed under the License is distributed on an "AS IS" BASIS, 11*bcb5dc79SHONG Yifan# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*bcb5dc79SHONG Yifan# See the License for the specific language governing permissions and 13*bcb5dc79SHONG Yifan# limitations under the License. 14*bcb5dc79SHONG Yifan 15*bcb5dc79SHONG Yifan"Helpers for copy rules" 16*bcb5dc79SHONG Yifan 17*bcb5dc79SHONG Yifan# Hints for Bazel spawn strategy 18*bcb5dc79SHONG YifanCOPY_EXECUTION_REQUIREMENTS = { 19*bcb5dc79SHONG Yifan # ----------------+----------------------------------------------------------------------------- 20*bcb5dc79SHONG Yifan # no-remote | Prevents the action or test from being executed remotely or cached remotely. 21*bcb5dc79SHONG Yifan # | This is equivalent to using both `no-remote-cache` and `no-remote-exec`. 22*bcb5dc79SHONG Yifan # ----------------+----------------------------------------------------------------------------- 23*bcb5dc79SHONG Yifan # no-cache | Results in the action or test never being cached (remotely or locally) 24*bcb5dc79SHONG Yifan # ----------------+----------------------------------------------------------------------------- 25*bcb5dc79SHONG Yifan # See https://bazel.build/reference/be/common-definitions#common-attributes 26*bcb5dc79SHONG Yifan # 27*bcb5dc79SHONG Yifan # Copying file & directories is entirely IO-bound and there is no point doing this work 28*bcb5dc79SHONG Yifan # remotely. 29*bcb5dc79SHONG Yifan # 30*bcb5dc79SHONG Yifan # Also, remote-execution does not allow source directory inputs, see 31*bcb5dc79SHONG Yifan # https://github.com/bazelbuild/bazel/commit/c64421bc35214f0414e4f4226cc953e8c55fa0d2 So we must 32*bcb5dc79SHONG Yifan # not attempt to execute remotely in that case. 33*bcb5dc79SHONG Yifan # 34*bcb5dc79SHONG Yifan # There is also no point pulling the output file or directory from the remote cache since the 35*bcb5dc79SHONG Yifan # bytes to copy are already available locally. Conversely, no point in writing to the cache if 36*bcb5dc79SHONG Yifan # no one has any reason to check it for this action. 37*bcb5dc79SHONG Yifan # 38*bcb5dc79SHONG Yifan # Read and writing to disk cache is disabled as well primarily to reduce disk usage on the local 39*bcb5dc79SHONG Yifan # machine. A disk cache hit of a directory copy could be slghtly faster than a copy since the 40*bcb5dc79SHONG Yifan # disk cache stores the directory artifact as a single entry, but the slight performance bump 41*bcb5dc79SHONG Yifan # comes at the cost of heavy disk cache usage, which is an unmanaged directory that grow beyond 42*bcb5dc79SHONG Yifan # the bounds of the physical disk. 43*bcb5dc79SHONG Yifan "no-remote": "1", 44*bcb5dc79SHONG Yifan "no-cache": "1", 45*bcb5dc79SHONG Yifan} 46