Skip to content

Latest commit

 

History

History
69 lines (43 loc) · 3.84 KB

copy_directory.md

File metadata and controls

69 lines (43 loc) · 3.84 KB

A rule that copies a directory to another place.

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

copy_directory

copy_directory(name, src, out, hardlink, kwargs)

Copies a directory to another location.

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 https://github.com/bazelbuild/bazel/commit/c64421bc35214f0414e4f4226cc953e8c55fa0d2 for more context.

PARAMETERS

Name Description Default Value
name Name of the rule. none
src The directory to make a copy of. Can be a source directory or TreeArtifact. none
out Path of the output directory, relative to this package. none
hardlink Controls when to use hardlinks to files instead of making copies.

Creating hardlinks is much faster than making copies of files with the caveat that hardlinks share file permissions with their source.

Since Bazel removes write permissions on files in the output tree after an action completes, hardlinks to source files within source directories is not recommended since write permissions will be inadvertently removed from sources files.

- "auto": hardlinks are used if src is a tree artifact already in the output tree - "off": files are always copied - "on": hardlinks are always used (not recommended)
"auto"
kwargs further keyword arguments, e.g. visibility none

copy_directory_bin_action

copy_directory_bin_action(ctx, src, dst, copy_directory_bin, hardlink, verbose)

Factory function that creates an action to copy a directory from src to dst using a tool binary.

The tool binary will typically be the @aspect_bazel_lib//tools/copy_directory go_binary either built from source or provided by a toolchain.

This helper is used by the copy_directory rule. It is exposed as a public API so it can be used within other rule implementations.

PARAMETERS

Name Description Default Value
ctx The rule context. none
src The source directory to copy. none
dst The directory to copy to. Must be a TreeArtifact. none
copy_directory_bin Copy to directory tool binary. none
hardlink Controls when to use hardlinks to files instead of making copies.

See copy_directory rule documentation for more details.
"auto"
verbose If true, prints out verbose logs to stdout False