2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-12-02 14:52:43 +00:00
bazel-skylib/docs/copy_file_doc.md
Yannic 8f3151fb4a
copy_file: Add parameter to allow symlinks (#252)
* copy_file: Add parameter to allow symlinks

This change adds a new parameter `allow_symlinks` to `copy_file` that
allows the action to create a symlink instead of doing an expensive
copy if the execution platform (host) allows it.

Updates #248

* Update docs

* Refactor `is_executable` into attribute

* Fix typo

* s/_impl/_copy_file_impl/
2020-07-10 14:08:02 -04:00

2.7 KiB
Executable file

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 required.

Name of the rule.

src required.

A Label. The file to make a copy of. (Can also be the label of a rule that generates a file.)

out required.

Path of the output file, relative to this package.

is_executable optional. default is False

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.

kwargs optional.

further keyword arguments, e.g. `visibility`