refactor: remove exclude_prefixes from copy_to_directory and copy_to_directory_bin_action (#591)
This commit is contained in:
parent
cb9b74f41e
commit
1cd2eb7e0a
|
@ -8,10 +8,9 @@ Copy files and directories to an output directory.
|
|||
## copy_to_directory
|
||||
|
||||
<pre>
|
||||
copy_to_directory(<a href="#copy_to_directory-name">name</a>, <a href="#copy_to_directory-allow_overwrites">allow_overwrites</a>, <a href="#copy_to_directory-exclude_prefixes">exclude_prefixes</a>, <a href="#copy_to_directory-exclude_srcs_packages">exclude_srcs_packages</a>,
|
||||
<a href="#copy_to_directory-exclude_srcs_patterns">exclude_srcs_patterns</a>, <a href="#copy_to_directory-hardlink">hardlink</a>, <a href="#copy_to_directory-include_external_repositories">include_external_repositories</a>,
|
||||
<a href="#copy_to_directory-include_srcs_packages">include_srcs_packages</a>, <a href="#copy_to_directory-include_srcs_patterns">include_srcs_patterns</a>, <a href="#copy_to_directory-out">out</a>, <a href="#copy_to_directory-replace_prefixes">replace_prefixes</a>, <a href="#copy_to_directory-root_paths">root_paths</a>,
|
||||
<a href="#copy_to_directory-srcs">srcs</a>, <a href="#copy_to_directory-verbose">verbose</a>)
|
||||
copy_to_directory(<a href="#copy_to_directory-name">name</a>, <a href="#copy_to_directory-allow_overwrites">allow_overwrites</a>, <a href="#copy_to_directory-exclude_srcs_packages">exclude_srcs_packages</a>, <a href="#copy_to_directory-exclude_srcs_patterns">exclude_srcs_patterns</a>, <a href="#copy_to_directory-hardlink">hardlink</a>,
|
||||
<a href="#copy_to_directory-include_external_repositories">include_external_repositories</a>, <a href="#copy_to_directory-include_srcs_packages">include_srcs_packages</a>, <a href="#copy_to_directory-include_srcs_patterns">include_srcs_patterns</a>, <a href="#copy_to_directory-out">out</a>,
|
||||
<a href="#copy_to_directory-replace_prefixes">replace_prefixes</a>, <a href="#copy_to_directory-root_paths">root_paths</a>, <a href="#copy_to_directory-srcs">srcs</a>, <a href="#copy_to_directory-verbose">verbose</a>)
|
||||
</pre>
|
||||
|
||||
Copies files and directories to an output directory.
|
||||
|
@ -53,7 +52,6 @@ for more information on supported globbing patterns.
|
|||
| :------------- | :------------- | :------------- | :------------- | :------------- |
|
||||
| <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>The order of srcs matters as the last copy of a particular file will win when overwriting. Performance of copy_to_directory will be slightly degraded when allow_overwrites is True since copies cannot be parallelized out as they are calculated. Instead all copy paths must be calculated before any copies can be started. | 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>Files 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>Forward slashes (<code>/</code>) should be used as path separators.<br><br>Files 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>Globs are supported (see rule docstring above). | 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>Files in srcs are not copied to the output directory if the Bazel package of the file matches one of the patterns specified.<br><br>Forward slashes (<code>/</code>) should be used as path separators. A first character of <code>"."</code> will be replaced by the target's package path.<br><br>Files 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>Globs are supported (see rule docstring above). | 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>Files 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>Forward slashes (<code>/</code>) should be used as path separators.<br><br>Files 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>Globs are supported (see rule docstring above). | List of strings | optional | [] |
|
||||
| <a id="copy_to_directory-hardlink"></a>hardlink | Controls when to use hardlinks to files instead of making copies.<br><br>Creating hardlinks is much faster than making copies of files with the caveat that hardlinks share file permissions with their source.<br><br>Since Bazel removes write permissions on files in the output tree after an action completes, hardlinks to source files are not recommended since write permissions will be inadvertently removed from sources files.<br><br>- <code>auto</code>: hardlinks are used for generated files already in the output tree - <code>off</code>: all files are copied - <code>on</code>: hardlinks are used for all files (not recommended) | String | optional | "auto" |
|
||||
|
@ -75,7 +73,7 @@ for more information on supported globbing patterns.
|
|||
copy_to_directory_bin_action(<a href="#copy_to_directory_bin_action-ctx">ctx</a>, <a href="#copy_to_directory_bin_action-name">name</a>, <a href="#copy_to_directory_bin_action-dst">dst</a>, <a href="#copy_to_directory_bin_action-copy_to_directory_bin">copy_to_directory_bin</a>, <a href="#copy_to_directory_bin_action-files">files</a>, <a href="#copy_to_directory_bin_action-targets">targets</a>, <a href="#copy_to_directory_bin_action-root_paths">root_paths</a>,
|
||||
<a href="#copy_to_directory_bin_action-include_external_repositories">include_external_repositories</a>, <a href="#copy_to_directory_bin_action-include_srcs_packages">include_srcs_packages</a>,
|
||||
<a href="#copy_to_directory_bin_action-exclude_srcs_packages">exclude_srcs_packages</a>, <a href="#copy_to_directory_bin_action-include_srcs_patterns">include_srcs_patterns</a>, <a href="#copy_to_directory_bin_action-exclude_srcs_patterns">exclude_srcs_patterns</a>,
|
||||
<a href="#copy_to_directory_bin_action-exclude_prefixes">exclude_prefixes</a>, <a href="#copy_to_directory_bin_action-replace_prefixes">replace_prefixes</a>, <a href="#copy_to_directory_bin_action-allow_overwrites">allow_overwrites</a>, <a href="#copy_to_directory_bin_action-hardlink">hardlink</a>, <a href="#copy_to_directory_bin_action-verbose">verbose</a>)
|
||||
<a href="#copy_to_directory_bin_action-replace_prefixes">replace_prefixes</a>, <a href="#copy_to_directory_bin_action-allow_overwrites">allow_overwrites</a>, <a href="#copy_to_directory_bin_action-hardlink">hardlink</a>, <a href="#copy_to_directory_bin_action-verbose">verbose</a>)
|
||||
</pre>
|
||||
|
||||
Factory function to copy files to a directory using a tool binary.
|
||||
|
@ -104,7 +102,6 @@ other rule implementations where additional_files can also be passed in.
|
|||
| <a id="copy_to_directory_bin_action-exclude_srcs_packages"></a>exclude_srcs_packages | List of Bazel packages (with glob support) to exclude from output directory.<br><br>See copy_to_directory rule documentation for more details. | <code>[]</code> |
|
||||
| <a id="copy_to_directory_bin_action-include_srcs_patterns"></a>include_srcs_patterns | List of paths (with glob support) to include in output directory.<br><br>See copy_to_directory rule documentation for more details. | <code>["**"]</code> |
|
||||
| <a id="copy_to_directory_bin_action-exclude_srcs_patterns"></a>exclude_srcs_patterns | List of paths (with glob support) to exclude from output directory.<br><br>See copy_to_directory rule documentation for more details. | <code>[]</code> |
|
||||
| <a id="copy_to_directory_bin_action-exclude_prefixes"></a>exclude_prefixes | List of path prefixes to exclude from output directory.<br><br>See copy_to_directory rule documentation for more details. | <code>[]</code> |
|
||||
| <a id="copy_to_directory_bin_action-replace_prefixes"></a>replace_prefixes | Map of paths prefixes to replace in the output directory path when copying files.<br><br>See copy_to_directory rule documentation for more details. | <code>{}</code> |
|
||||
| <a id="copy_to_directory_bin_action-allow_overwrites"></a>allow_overwrites | If True, allow files to be overwritten if the same output file is copied to twice.<br><br>See copy_to_directory rule documentation for more details. | <code>False</code> |
|
||||
| <a id="copy_to_directory_bin_action-hardlink"></a>hardlink | Controls when to use hardlinks to files instead of making copies.<br><br>See copy_to_directory rule documentation for more details. | <code>"auto"</code> |
|
||||
|
|
|
@ -164,23 +164,6 @@ Files 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.
|
||||
|
||||
Globs are supported (see rule docstring above).
|
||||
""",
|
||||
# exclude_prefixes
|
||||
"exclude_prefixes": """List of path prefixes (with glob support) to exclude from output directory.
|
||||
|
||||
DEPRECATED: use `exclude_srcs_patterns` instead
|
||||
|
||||
Files in srcs are not copied to the output directory if their output
|
||||
directory path, after applying `root_paths`, starts with or fully matches one of the
|
||||
patterns specified.
|
||||
|
||||
Forward slashes (`/`) should be used as path separators.
|
||||
|
||||
Files 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.
|
||||
|
||||
Globs are supported (see rule docstring above).
|
||||
""",
|
||||
# replace_prefixes
|
||||
|
@ -257,9 +240,6 @@ _copy_to_directory_attr = {
|
|||
"exclude_srcs_patterns": attr.string_list(
|
||||
doc = _copy_to_directory_attr_doc["exclude_srcs_patterns"],
|
||||
),
|
||||
"exclude_prefixes": attr.string_list(
|
||||
doc = _copy_to_directory_attr_doc["exclude_prefixes"],
|
||||
),
|
||||
"replace_prefixes": attr.string_dict(
|
||||
doc = _copy_to_directory_attr_doc["replace_prefixes"],
|
||||
),
|
||||
|
@ -302,7 +282,6 @@ def _copy_to_directory_impl(ctx):
|
|||
exclude_srcs_packages = ctx.attr.exclude_srcs_packages,
|
||||
include_srcs_patterns = ctx.attr.include_srcs_patterns,
|
||||
exclude_srcs_patterns = ctx.attr.exclude_srcs_patterns,
|
||||
exclude_prefixes = ctx.attr.exclude_prefixes,
|
||||
replace_prefixes = ctx.attr.replace_prefixes,
|
||||
allow_overwrites = ctx.attr.allow_overwrites,
|
||||
hardlink = ctx.attr.hardlink,
|
||||
|
@ -342,7 +321,6 @@ def copy_to_directory_bin_action(
|
|||
exclude_srcs_packages = [],
|
||||
include_srcs_patterns = ["**"],
|
||||
exclude_srcs_patterns = [],
|
||||
exclude_prefixes = [],
|
||||
replace_prefixes = {},
|
||||
allow_overwrites = False,
|
||||
hardlink = "auto",
|
||||
|
@ -392,10 +370,6 @@ def copy_to_directory_bin_action(
|
|||
|
||||
See copy_to_directory rule documentation for more details.
|
||||
|
||||
exclude_prefixes: List of path prefixes to exclude from output directory.
|
||||
|
||||
See copy_to_directory rule documentation for more details.
|
||||
|
||||
replace_prefixes: Map of paths prefixes to replace in the output directory path when copying files.
|
||||
|
||||
See copy_to_directory rule documentation for more details.
|
||||
|
@ -418,20 +392,6 @@ def copy_to_directory_bin_action(
|
|||
include_srcs_packages = _expand_src_packages_patterns(include_srcs_packages, ctx.label.package)
|
||||
exclude_srcs_packages = _expand_src_packages_patterns(exclude_srcs_packages, ctx.label.package)
|
||||
|
||||
# Convert and append exclude_prefixes to exclude_srcs_patterns
|
||||
# TODO(2.0): remove exclude_prefixes this block and in a future breaking release
|
||||
for exclude_prefix in exclude_prefixes:
|
||||
if exclude_prefix.endswith("**"):
|
||||
exclude_srcs_patterns.append(exclude_prefix)
|
||||
elif exclude_prefix.endswith("*"):
|
||||
exclude_srcs_patterns.append(exclude_prefix + "/**")
|
||||
exclude_srcs_patterns.append(exclude_prefix)
|
||||
elif exclude_prefix.endswith("/"):
|
||||
exclude_srcs_patterns.append(exclude_prefix + "**")
|
||||
else:
|
||||
exclude_srcs_patterns.append(exclude_prefix + "*/**")
|
||||
exclude_srcs_patterns.append(exclude_prefix + "*")
|
||||
|
||||
if not include_srcs_packages:
|
||||
fail("An empty 'include_srcs_packages' list will exclude all srcs and result in an empty directory")
|
||||
|
||||
|
|
Loading…
Reference in New Issue