fix: add missing convienence aliases to exclude_srcs_packages

This commit is contained in:
Greg Magolan 2022-07-29 18:48:09 -07:00 committed by Greg Magolan
parent 01da4db80c
commit c4f6fcff42
3 changed files with 11 additions and 5 deletions

View File

@ -26,7 +26,7 @@ copy_to_directory(<a href="#copy_to_directory-name">name</a>, <a href="#copy_to_
| <a id="copy_to_directory-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="copy_to_directory-allow_overwrites"></a>allow_overwrites | If True, allow files to be overwritten if the same output file is copied to twice.<br><br> If set, then the order of srcs matters as the last copy of a particular file will win.<br><br> This setting has no effect on Windows where overwrites are always allowed. | Boolean | optional | False |
| <a id="copy_to_directory-exclude_prefixes"></a>exclude_prefixes | List of path prefixes (with glob support) to exclude from output directory.<br><br> DEPRECATED: use <code>exclude_srcs_patterns</code> instead<br><br> Glob patterns <code>**</code>, <code>*</code> and <code>?</code> are supported. See <code>glob_match</code> documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.<br><br> Files and directories in srcs are not copied to the output directory if their output directory path, after applying <code>root_paths</code>, starts with or fully matches one of the patterns specified.<br><br> Patterns do not look into files within source directory or generated directory (TreeArtifact) targets since matches are performed in Starlark. To use <code>include_srcs_patterns</code> on files within directories you can use the <code>make_directory_paths</code> helper to specify individual files inside directories in <code>srcs</code>. This restriction may be fixed in a future release by performing matching inside the copy action instead of in Starlark.<br><br> Forward slashes (<code>/</code>) should be used as path separators.<br><br> Files and directories that do not have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.<br><br> Filters and transformations are applied in the following order:<br><br>1. <code>include_external_repositories</code><br><br>2. <code>include_srcs_packages</code><br><br>3. <code>exclude_srcs_packages</code><br><br>4. <code>root_paths</code><br><br>5. <code>include_srcs_patterns</code><br><br>6. <code>exclude_srcs_patterns</code><br><br>7. <code>replace_prefixes</code><br><br>For more information each filters / transformations applied, see the documentation for the specific filter / transformation attribute. | List of strings | optional | [] |
| <a id="copy_to_directory-exclude_srcs_packages"></a>exclude_srcs_packages | List of Bazel packages (with glob support) to exclude from output directory.<br><br> Glob patterns <code>**</code>, <code>*</code> and <code>?</code> are supported. See <code>glob_match</code> documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.<br><br> Files and directories in srcs are not copied to the output directory if the Bazel package of the file or directory matches one of the patterns specified.<br><br> Forward slashes (<code>/</code>) should be used as path separators.<br><br> Files and directories that have do not have matching Bazel packages are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.<br><br> Filters and transformations are applied in the following order:<br><br>1. <code>include_external_repositories</code><br><br>2. <code>include_srcs_packages</code><br><br>3. <code>exclude_srcs_packages</code><br><br>4. <code>root_paths</code><br><br>5. <code>include_srcs_patterns</code><br><br>6. <code>exclude_srcs_patterns</code><br><br>7. <code>replace_prefixes</code><br><br>For more information each filters / transformations applied, see the documentation for the specific filter / transformation attribute. | List of strings | optional | [] |
| <a id="copy_to_directory-exclude_srcs_packages"></a>exclude_srcs_packages | List of Bazel packages (with glob support) to exclude from output directory.<br><br> Glob patterns <code>**</code>, <code>*</code> and <code>?</code> are supported. See <code>glob_match</code> documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.<br><br> Files and directories in srcs are not copied to the output directory if the Bazel package of the file or directory matches one of the patterns specified.<br><br> Forward slashes (<code>/</code>) should be used as path separators.<br><br> A "." value expands to the target's package path (<code>ctx.label.package</code>). A "./**" value expands to the target's package path followed by a slash and a globstar (<code>"{}/**".format(ctx.label.package)</code>).<br><br> Files and directories that have do not have matching Bazel packages are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.<br><br> Filters and transformations are applied in the following order:<br><br>1. <code>include_external_repositories</code><br><br>2. <code>include_srcs_packages</code><br><br>3. <code>exclude_srcs_packages</code><br><br>4. <code>root_paths</code><br><br>5. <code>include_srcs_patterns</code><br><br>6. <code>exclude_srcs_patterns</code><br><br>7. <code>replace_prefixes</code><br><br>For more information each filters / transformations applied, see the documentation for the specific filter / transformation attribute. | List of strings | optional | [] |
| <a id="copy_to_directory-exclude_srcs_patterns"></a>exclude_srcs_patterns | List of paths (with glob support) to exclude from output directory.<br><br> Glob patterns <code>**</code>, <code>*</code> and <code>?</code> are supported. See <code>glob_match</code> documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.<br><br> Files and directories in srcs are not copied to the output directory if their output directory path, after applying <code>root_paths</code>, matches one of the patterns specified.<br><br> Patterns do not look into files within source directory or generated directory (TreeArtifact) targets since matches are performed in Starlark. To use <code>include_srcs_patterns</code> on files within directories you can use the <code>make_directory_paths</code> helper to specify individual files inside directories in <code>srcs</code>. This restriction may be fixed in a future release by performing matching inside the copy action instead of in Starlark.<br><br> Forward slashes (<code>/</code>) should be used as path separators.<br><br> Files and directories that do not have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.<br><br> Filters and transformations are applied in the following order:<br><br>1. <code>include_external_repositories</code><br><br>2. <code>include_srcs_packages</code><br><br>3. <code>exclude_srcs_packages</code><br><br>4. <code>root_paths</code><br><br>5. <code>include_srcs_patterns</code><br><br>6. <code>exclude_srcs_patterns</code><br><br>7. <code>replace_prefixes</code><br><br>For more information each filters / transformations applied, see the documentation for the specific filter / transformation attribute. | List of strings | optional | [] |
| <a id="copy_to_directory-include_external_repositories"></a>include_external_repositories | List of external repository names (with glob support) to include in the output directory.<br><br> Glob patterns <code>**</code>, <code>*</code> and <code>?</code> are supported. See <code>glob_match</code> documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.<br><br> Files from external repositories are only copied into the output directory if the external repository they come from matches one of the external repository patterns specified.<br><br> When copied from an external repository, the file path in the output directory defaults to the file's path within the external repository. The external repository name is _not_ included in that path.<br><br> For example, the following copies <code>@external_repo//path/to:file</code> to <code>path/to/file</code> within the output directory.<br><br> <pre><code> copy_to_directory( name = "dir", include_external_repositories = ["external_*"], srcs = ["@external_repo//path/to:file"], ) </code></pre><br><br> Files and directories that come from matching external are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be. The external repository name of the file or directory from an external repository is not included in the output directory path and is considered in subsequent filters and transformations.<br><br> Filters and transformations are applied in the following order:<br><br>1. <code>include_external_repositories</code><br><br>2. <code>include_srcs_packages</code><br><br>3. <code>exclude_srcs_packages</code><br><br>4. <code>root_paths</code><br><br>5. <code>include_srcs_patterns</code><br><br>6. <code>exclude_srcs_patterns</code><br><br>7. <code>replace_prefixes</code><br><br>For more information each filters / transformations applied, see the documentation for the specific filter / transformation attribute. | List of strings | optional | [] |
| <a id="copy_to_directory-include_srcs_packages"></a>include_srcs_packages | List of Bazel packages (with glob support) to include in output directory.<br><br> Glob patterns <code>**</code>, <code>*</code> and <code>?</code> are supported. See <code>glob_match</code> documentation for more details on how to use glob patterns: https://github.com/aspect-build/bazel-lib/blob/main/docs/glob_match.md.<br><br> Files and directories in srcs are only copied to the output directory if the Bazel package of the file or directory matches one of the patterns specified.<br><br> Forward slashes (<code>/</code>) should be used as path separators.<br><br> A "." value expands to the target's package path (<code>ctx.label.package</code>). A "./**" value expands to the target's package path followed by a slash and a globstar (<code>"{}/**".format(ctx.label.package)</code>).<br><br> Defaults to ["**"] which includes sources from all packages.<br><br> Files and directories that have matching Bazel packages are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.<br><br> Filters and transformations are applied in the following order:<br><br>1. <code>include_external_repositories</code><br><br>2. <code>include_srcs_packages</code><br><br>3. <code>exclude_srcs_packages</code><br><br>4. <code>root_paths</code><br><br>5. <code>include_srcs_patterns</code><br><br>6. <code>exclude_srcs_patterns</code><br><br>7. <code>replace_prefixes</code><br><br>For more information each filters / transformations applied, see the documentation for the specific filter / transformation attribute. | List of strings | optional | ["**"] |

View File

@ -142,6 +142,10 @@ _copy_to_directory_attr = {
Forward slashes (`/`) should be used as path separators.
A "." value expands to the target's package path (`ctx.label.package`).
A "./**" value expands to the target's package path followed by a slash and a
globstar (`"{{}}/**".format(ctx.label.package)`).
Files and directories that have do not have matching Bazel packages are subject to subsequent
filters and transformations to determine if they are copied and what their path in the output
directory will be.
@ -638,11 +642,13 @@ def copy_to_directory_action(
# Replace "." in root_paths with the package name of the target
root_paths = [p if p != "." else ctx.label.package for p in root_paths]
# Replace "." in include_srcs_packages with the package name of the target
# Replace "." in include_srcs_packages & exclude_srcs_packages with the package name of the target
include_srcs_packages = [p if p != "." else ctx.label.package for p in include_srcs_packages]
exclude_srcs_packages = [p if p != "." else ctx.label.package for p in exclude_srcs_packages]
# Replace "./**" in include_srcs_packages with the package name of the target followed by slash a globstar
# Replace "./**" in include_srcs_packages & exclude_srcs_packages with the package name of the target followed by slash a globstar
include_srcs_packages = [p if p != "./**" else "{}/**".format(ctx.label.package) for p in include_srcs_packages]
exclude_srcs_packages = [p if p != "./**" else "{}/**".format(ctx.label.package) for p in exclude_srcs_packages]
# Convert and append exclude_prefixes to exclude_srcs_patterns
# TODO(2.0): remove exclude_prefixes this block and in a future breaking release

View File

@ -379,7 +379,7 @@ diff_test(
copy_to_directory(
name = "case_17",
srcs = case_srcs,
exclude_srcs_packages = [package_name()],
exclude_srcs_packages = ["."],
)
diff_test(
@ -392,7 +392,7 @@ diff_test(
copy_to_directory(
name = "case_18",
srcs = case_srcs,
exclude_srcs_packages = ["{}/**".format(package_name())],
exclude_srcs_packages = ["./**"],
include_external_repositories = ["e?ter*_test_repo"],
)