2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-27 05:43:25 +00:00
bazel-skylib/docs/copy_file_doc.md
nickgooding 31ab4c8bd2
feat: bzlmod setup (#385)
Creates MODULE.bazel and WORKSPACE.bzlmod files to enable bazel-skylib
to work with the `--experimental_enable_bzlmod` flag.

rules_go has been updated as the previously used version is not
available in the BCR.

stardoc has been updated due to a strange issue with Bzlmod enabled that
caused the `diff_test` and `unittest` docs to be generated without any
contents that was magically fixed upon updating.

bazelbuild/bazel-central-registry#124

Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
2022-08-30 14:57:34 -04:00

2.3 KiB
Executable file

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

copy_file(name, src, out, is_executable, allow_symlink, kwargs)

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

Name Description Default Value
name Name of the rule. none
src A Label. The file to make a copy of. (Can also be the label of a rule that generates a file.) none
out Path of the output file, relative to this package. none
is_executable A 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_symlink A boolean. Whether to allow symlinking instead of copying. When False, the output is always a hard copy. 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). Set this to True if you need fast copying and your tools can handle symlinks (which most UNIX tools can). False
kwargs further keyword arguments, e.g. visibility none