4 KiB
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).
This fork of bazel-skylib's copy_file adds DirectoryPathInfo support and allows multiple copy_file in the same package.
copy_file
copy_file(name, src, out, is_executable, allow_symlink, kwargs)
Copies a file or directory 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).
If using this rule with source directories, it is recommended that you use the
--host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1
startup option so that changes
to files within source directories are detected. See
c64421bc35
for more context.
PARAMETERS
copy_file_action
copy_file_action(ctx, src, dst, dir_path, is_windows)
Helper function that creates an action to copy a file from src to dst.
If src is a TreeArtifact, dir_path must be specified as the path within the TreeArtifact to the file to copy.
This helper is used by copy_file. It is exposed as a public API so it can be used within other rule implementations.
PARAMETERS