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_patters`, `exclude_srcs_patters` and `replace_prefixes` attributes. ## copy_to_directory
copy_to_directory(name, allow_overwrites, exclude_prefixes, exclude_srcs_packages, exclude_srcs_patterns, include_external_repositories, include_srcs_packages, include_srcs_patterns, out, replace_prefixes, root_paths, srcs)**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.
exclude_srcs_patterns
instead**
, *
and ?
are supported. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.root_paths
, starts with or fully matches one of the patterns specified.include_srcs_patterns
on files within directories you can use the make_directory_paths
helper to specify individual files inside directories in srcs
. This restriction may be fixed in a future release by performing matching inside the copy action instead of in Starlark./
) should be used as path separators.include_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
**
, *
and ?
are supported. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md./
) should be used as path separators."."
value means exclude srcs that are in the target's package. It expands to the target's package path (ctx.label.package
). This will be an empty string ""
if the target is in the root package."./**"
value means exclude srcs that are in subpackages of the target's package. It expands to the target's package path followed by a slash and a globstar ("{}/**".format(ctx.label.package)
). If the target's package is the root package, "./**"
expands to ["?*", "?*/**"]
instead.include_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
**
, *
and ?
are supported. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.root_paths
, matches one of the patterns specified.include_srcs_patterns
on files within directories you can use the make_directory_paths
helper to specify individual files inside directories in srcs
. This restriction may be fixed in a future release by performing matching inside the copy action instead of in Starlark./
) should be used as path separators.include_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
**
, *
and ?
are supported. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.@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_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
**
, *
and ?
are supported. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md./
) should be used as path separators."."
value means include srcs that are in the target's package. It expands to the target's package path (ctx.label.package
). This will be an empty string ""
if the target is in the root package."./**"
value means include srcs that are in subpackages of the target's package. It expands to the target's package path followed by a slash and a globstar ("{}/**".format(ctx.label.package)
). If the target's package is the root package, "./**"
expands to ["?*", "?*/**"]
instead.["**"]
which includes sources from all packages.include_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
**
, *
and ?
are supported. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.root_paths
, matches one of the patterns specified.include_srcs_patterns
on files within directories you can use the make_directory_paths
helper to specify individual files inside directories in srcs
. This restriction may be fixed in a future release by performing matching inside the copy action instead of in Starlark./
) should be used as path separators.include_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
**
, *
and ?
are supported but the pattern must not end with a **
glob expression. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.replace_prefixes
on files within directories you can use the make_directory_paths
helper to specify individual files inside directories in srcs
. This restriction may be fixed in a future release by performing matching inside the copy action instead of in Starlark./
) should be used as path separators. include_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
**
, *
and ?
are supported. See glob_match
documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md./
) should be used as path separators.ctx.label.package
).include_external_repositories
include_srcs_packages
exclude_srcs_packages
root_paths
include_srcs_patterns
exclude_srcs_patterns
replace_prefixes
copy_to_directory_action(ctx, srcs, dst, additional_files, root_paths, include_external_repositories, include_srcs_packages, exclude_srcs_packages, include_srcs_patterns, exclude_srcs_patterns, exclude_prefixes, replace_prefixes, allow_overwrites, is_windows)Helper function to copy files to a directory. 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 | | srcs | Files and/or directories or targets that provide DirectoryPathInfo to copy into the output directory. | none | | dst | The directory to copy to. Must be a TreeArtifact. | none | | additional_files | List or depset of additional files to copy that are not in the DefaultInfo or DirectoryPathInfo of srcs |
[]
|
| 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.[]
|
| exclude_prefixes | List of path prefixes 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
|
| is_windows | Deprecated and unused | None
|
## copy_to_directory_lib.impl
copy_to_directory_lib.impl(ctx)**PARAMETERS** | Name | Description | Default Value | | :------------- | :------------- | :------------- | | ctx |
-
| none |