Copy files and directories to an output directory. ## copy_to_directory
copy_to_directory(name, allow_overwrites, exclude_srcs_packages, exclude_srcs_patterns, hardlink, include_external_repositories, include_srcs_packages, include_srcs_patterns, out, replace_prefixes, root_paths, srcs, verbose)Copies files and directories to an output directory. Files and directories can be arranged as needed in the output directory using the `root_paths`, `include_srcs_patterns`, `exclude_srcs_patterns` and `replace_prefixes` attributes. Filters and transformations are applied in the following order: 1. `include_external_repositories` 2. `include_srcs_packages` 3. `exclude_srcs_packages` 4. `root_paths` 5. `include_srcs_patterns` 6. `exclude_srcs_patterns` 7. `replace_prefixes` For more information each filters / transformations applied, see the documentation for the specific filter / transformation attribute. Glob patterns are supported. Standard wildcards (globbing patterns) plus the `**` doublestar (aka. super-asterisk) are supported with the underlying globbing library, https://github.com/bmatcuk/doublestar. This is the same globbing library used by [gazelle](https://github.com/bazelbuild/bazel-gazelle). See https://github.com/bmatcuk/doublestar#patterns for more information on supported globbing patterns. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | allow_overwrites | If True, allow files to be overwritten if the same output file is copied to twice.
False
|
| exclude_srcs_packages | List of Bazel packages (with glob support) to exclude from output directory./
) should be used as path separators. A first character of "."
will be replaced by the target's package path.[]
|
| exclude_srcs_patterns | List of paths (with glob support) to exclude from output directory.root_paths
, matches one of the patterns specified./
) should be used as path separators.[]
|
| hardlink | Controls when to use hardlinks to files instead of making copies.auto
: hardlinks are used for generated files already in the output tree - off
: all files are copied - on
: hardlinks are used for all files (not recommended) | String | optional | "auto"
|
| include_external_repositories | List of external repository names (with glob support) to include in the output directory.@external_repo//path/to:file
to path/to/file
within the output directory. copy_to_directory( name = "dir", include_external_repositories = ["external_*"], srcs = ["@external_repo//path/to:file"], )
[]
|
| include_srcs_packages | List of Bazel packages (with glob support) to include in output directory./
) should be used as path separators. A first character of "."
will be replaced by the target's package path.["**"]
which includes sources from all packages.["**"]
|
| include_srcs_patterns | List of paths (with glob support) to include in output directory.root_paths
, matches one of the patterns specified./
) should be used as path separators.["**"]
which includes all sources.["**"]
|
| out | Path of the output directory, relative to this package.""
|
| replace_prefixes | Map of paths prefixes (with glob support) to replace in the output directory path when copying files./
) should be used as path separators.{}
|
| root_paths | List of paths (with glob support) that are roots in the output directory./
) should be used as path separators."."
value expands to the target's package path (ctx.label.package
).["."]
which results in the output directory path of files in the target's package and and sub-packages are relative to the target's package and files outside of that retain their full workspace relative paths.["."]
|
| srcs | Files and/or directories or targets that provide DirectoryPathInfo
to copy into the output directory. | List of labels | optional | []
|
| verbose | If true, prints out verbose logs to stdout | Boolean | optional | False
|
## copy_to_directory_bin_action
copy_to_directory_bin_action(ctx, name, dst, copy_to_directory_bin, files, targets, root_paths, include_external_repositories, include_srcs_packages, exclude_srcs_packages, include_srcs_patterns, exclude_srcs_patterns, replace_prefixes, allow_overwrites, hardlink, verbose)Factory function to copy files to a directory using a tool binary. The tool binary will typically be the `@aspect_bazel_lib//tools/copy_to_directory` `go_binary` either built from source or provided by a toolchain. This helper is used by copy_to_directory. It is exposed as a public API so it can be used within other rule implementations where additional_files can also be passed in. **PARAMETERS** | Name | Description | Default Value | | :------------- | :------------- | :------------- | | ctx | The rule context. | none | | name | Name of target creating this action used for config file generation. | none | | dst | The directory to copy to. Must be a TreeArtifact. | none | | copy_to_directory_bin | Copy to directory tool binary. | none | | files | List of files to copy into the output directory. |
[]
|
| targets | List of targets that provide DirectoryPathInfo
to copy into the output directory. | []
|
| root_paths | List of paths that are roots in the output directory.["."]
|
| include_external_repositories | List of external repository names to include in the output directory.[]
|
| include_srcs_packages | List of Bazel packages to include in output directory.["**"]
|
| exclude_srcs_packages | List of Bazel packages (with glob support) to exclude from output directory.[]
|
| include_srcs_patterns | List of paths (with glob support) to include in output directory.["**"]
|
| exclude_srcs_patterns | List of paths (with glob support) to exclude from output directory.[]
|
| replace_prefixes | Map of paths prefixes to replace in the output directory path when copying files.{}
|
| allow_overwrites | If True, allow files to be overwritten if the same output file is copied to twice.False
|
| hardlink | Controls when to use hardlinks to files instead of making copies."auto"
|
| verbose | If true, prints out verbose logs to stdout | False
|
## copy_to_directory_lib.impl
copy_to_directory_lib.impl(ctx)**PARAMETERS** | Name | Description | Default Value | | :------------- | :------------- | :------------- | | ctx |
-
| none |