aboutsummaryrefslogtreecommitdiff
path: root/rules/private/copy_file_private.bzl
diff options
context:
space:
mode:
Diffstat (limited to 'rules/private/copy_file_private.bzl')
-rw-r--r--rules/private/copy_file_private.bzl14
1 files changed, 10 insertions, 4 deletions
diff --git a/rules/private/copy_file_private.bzl b/rules/private/copy_file_private.bzl
index 44f133a..15e1d4b 100644
--- a/rules/private/copy_file_private.bzl
+++ b/rules/private/copy_file_private.bzl
@@ -19,6 +19,8 @@ cmd.exe (on Windows). '_copy_xfile' marks the resulting file executable,
'_copy_file' does not.
"""
+load(":copy_common.bzl", "COPY_EXECUTION_REQUIREMENTS")
+
def copy_cmd(ctx, src, dst):
# Most Windows binaries built with MSVC use a certain argument quoting
# scheme. Bazel uses that scheme too to quote arguments. However,
@@ -37,25 +39,26 @@ def copy_cmd(ctx, src, dst):
is_executable = True,
)
ctx.actions.run(
- inputs = [src],
- tools = [bat],
+ inputs = [src, bat],
outputs = [dst],
executable = "cmd.exe",
arguments = ["/C", bat.path.replace("/", "\\")],
mnemonic = "CopyFile",
progress_message = "Copying files",
use_default_shell_env = True,
+ execution_requirements = COPY_EXECUTION_REQUIREMENTS,
)
def copy_bash(ctx, src, dst):
ctx.actions.run_shell(
- tools = [src],
+ inputs = [src],
outputs = [dst],
command = "cp -f \"$1\" \"$2\"",
arguments = [src.path, dst.path],
mnemonic = "CopyFile",
progress_message = "Copying files",
use_default_shell_env = True,
+ execution_requirements = COPY_EXECUTION_REQUIREMENTS,
)
def _copy_file_impl(ctx):
@@ -75,7 +78,10 @@ def _copy_file_impl(ctx):
if ctx.attr.is_executable:
return [DefaultInfo(files = files, runfiles = runfiles, executable = ctx.outputs.out)]
else:
- return [DefaultInfo(files = files, runfiles = runfiles)]
+ # Do not include the copied file into the default runfiles of the
+ # target, but ensure that it is picked up by native rule's data
+ # attribute despite https://github.com/bazelbuild/bazel/issues/15043.
+ return [DefaultInfo(files = files, data_runfiles = runfiles)]
_ATTRS = {
"src": attr.label(mandatory = True, allow_single_file = True),