A rule that copies a file to another place.

native.genrule() is sometimes used to copy files (often wishing to rename them). The ‘copy_file’ rule does this with a simpler interface than genrule.

The rule uses a Bash command on Linux/macOS/non-Windows, and a cmd.exe command on Windows (no Bash is required).

copy_file

Copies a file to another location.

native.genrule() is sometimes used to copy files (often wishing to rename them). The ‘copy_file’ rule does this with a simpler interface than genrule.

This rule uses a Bash command on Linux/macOS/non-Windows, and a cmd.exe command on Windows (no Bash is required).

PARAMETERS

NameDescriptionDefault Value
nameName of the rule.none
srcA Label. The file to make a copy of. (Can also be the label of a rule that generates a file.)none
outPath of the output file, relative to this package.none
is_executableA boolean. Whether to make the output file executable. When True, the rule's output can be executed using bazel run and can be in the srcs of binary and test rules that require executable sources. WARNING: If allow_symlink is True, src must also be executable.False
allow_symlinkA boolean. Whether to allow symlinking instead of copying. When False, the output is always a hard copy, but actions consuming that output as an input may still see a symlink (e.g. when using sandboxed excution). When True, the output can be a symlink, but there is no guarantee that a symlink is created (i.e., at the time of writing, we don't create symlinks on Windows by default). This defaults to True if is_executable is False, and False otherwise.None
kwargsfurther keyword arguments, e.g. visibilitynone