aboutsummaryrefslogtreecommitdiff
path: root/rules/private/copy_common.bzl
diff options
context:
space:
mode:
Diffstat (limited to 'rules/private/copy_common.bzl')
-rw-r--r--rules/private/copy_common.bzl45
1 files changed, 45 insertions, 0 deletions
diff --git a/rules/private/copy_common.bzl b/rules/private/copy_common.bzl
new file mode 100644
index 0000000..a8f7243
--- /dev/null
+++ b/rules/private/copy_common.bzl
@@ -0,0 +1,45 @@
+# Copyright 2022 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"Helpers for copy rules"
+
+# Hints for Bazel spawn strategy
+COPY_EXECUTION_REQUIREMENTS = {
+ # ----------------+-----------------------------------------------------------------------------
+ # no-remote | Prevents the action or test from being executed remotely or cached remotely.
+ # | This is equivalent to using both `no-remote-cache` and `no-remote-exec`.
+ # ----------------+-----------------------------------------------------------------------------
+ # no-cache | Results in the action or test never being cached (remotely or locally)
+ # ----------------+-----------------------------------------------------------------------------
+ # See https://bazel.build/reference/be/common-definitions#common-attributes
+ #
+ # Copying file & directories is entirely IO-bound and there is no point doing this work
+ # remotely.
+ #
+ # Also, remote-execution does not allow source directory inputs, see
+ # https://github.com/bazelbuild/bazel/commit/c64421bc35214f0414e4f4226cc953e8c55fa0d2 So we must
+ # not attempt to execute remotely in that case.
+ #
+ # There is also no point pulling the output file or directory from the remote cache since the
+ # bytes to copy are already available locally. Conversely, no point in writing to the cache if
+ # no one has any reason to check it for this action.
+ #
+ # Read and writing to disk cache is disabled as well primarily to reduce disk usage on the local
+ # machine. A disk cache hit of a directory copy could be slghtly faster than a copy since the
+ # disk cache stores the directory artifact as a single entry, but the slight performance bump
+ # comes at the cost of heavy disk cache usage, which is an unmanaged directory that grow beyond
+ # the bounds of the physical disk.
+ "no-remote": "1",
+ "no-cache": "1",
+}