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

Macros and Functions

copy_directory

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.

Example usage (generated)

load("@bazel_skylib//rules:copy_directory.bzl", "copy_directory")

copy_directory(
    # Name of the rule.
    name = "",
    # The directory to make a copy of
    src = "",
    # Path of the output directory, relative to this package.
    out = "",
)

name

Name of the rule.

src

The directory to make a copy of. Can be a source directory or TreeArtifact.

out

Path of the output directory, relative to this package.

kwargs

further keyword arguments, e.g. visibility


copy_directory_action

Helper function that creates an action to copy a directory from src to dst.

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

Example usage (generated)

load("@bazel_skylib//rules:copy_directory.bzl", "copy_directory_action")

copy_directory_action(
    # The rule context.
    ctx = None,
    # The directory to make a copy of
    src = "",
    # The directory to copy to
    dst = None,
)

ctx

The rule context.

src

The directory to make a copy of. Can be a source directory or TreeArtifact.

dst

The directory to copy to. Must be a TreeArtifact.

is_windows

If true, an cmd.exe action is created so there is no bash dependency.