fix: add missing convienence aliases to include_srcs_packages
This commit is contained in:
parent
6d3c1a393b
commit
01da4db80c
|
@ -29,11 +29,11 @@ copy_to_directory(<a href="#copy_to_directory-name">name</a>, <a href="#copy_to_
|
|||
| <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_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> 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 | ["**"] |
|
||||
| <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 | ["**"] |
|
||||
| <a id="copy_to_directory-include_srcs_patterns"></a>include_srcs_patterns | List of paths (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 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> Defaults to ["**"] which includes all sources.<br><br> Files and directories that 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-out"></a>out | Path of the output directory, relative to this package.<br><br> If not set, the name of the target is used. | String | optional | "" |
|
||||
| <a id="copy_to_directory-replace_prefixes"></a>replace_prefixes | Map of paths prefixes (with glob support) to replace in the output directory path when copying files.<br><br> Glob patterns <code>**</code>, <code>*</code> and <code>?</code> are supported but the pattern must not end with a <code>**</code> glob expression. 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> If the output directory path for a file or directory starts with or fully matches a a key in the dict then the matching portion of the output directory path is replaced with the dict value for that key. The final path segment matched can be a partial match of that segment and only the matching portion will be replaced. If there are multiple keys that match, the longest match wins.<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>replace_prefixes</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> Replace prefix transformation are the final step in the list of filters and transformations. The final output path of a file or directory being copied into the output directory is determined at this step.<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. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
|
||||
| <a id="copy_to_directory-root_paths"></a>root_paths | List of paths (with glob support) that are roots 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> If any parent directory of a file or directory being copied matches one of the root paths patterns specified, the output directory path will be the path relative to the root path instead of the path relative to the file's or directory's workspace. If there are multiple root paths that match, the longest match wins.<br><br> Matching is done on the parent directory of the output file path so a trailing '**' glob patterm will match only up to the last path segment of the dirname and will not include the basename. Only complete path segments are matched. Partial matches on the last segment of the root path are ignored.<br><br> Forward slashes (<code>/</code>) should be used as path separators. A "." value indicate the target's package path.<br><br> Defaults to ["."] 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.<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-root_paths"></a>root_paths | List of paths (with glob support) that are roots 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> If any parent directory of a file or directory being copied matches one of the root paths patterns specified, the output directory path will be the path relative to the root path instead of the path relative to the file's or directory's workspace. If there are multiple root paths that match, the longest match wins.<br><br> Matching is done on the parent directory of the output file path so a trailing '**' glob patterm will match only up to the last path segment of the dirname and will not include the basename. Only complete path segments are matched. Partial matches on the last segment of the root path are ignored.<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>).<br><br> Defaults to ["."] 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.<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-srcs"></a>srcs | Files and/or directories or targets that provide DirectoryPathInfo to copy into the output directory. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,9 @@ _copy_to_directory_attr = {
|
|||
Only complete path segments are matched. Partial matches on the last segment of the root path
|
||||
are ignored.
|
||||
|
||||
Forward slashes (`/`) should be used as path separators. A "." value indicate the target's package path.
|
||||
Forward slashes (`/`) should be used as path separators.
|
||||
|
||||
A "." value expands to the target's package path (`ctx.label.package`).
|
||||
|
||||
Defaults to ["."] 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
|
||||
|
@ -115,6 +117,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)`).
|
||||
|
||||
Defaults to ["**"] which includes sources from all packages.
|
||||
|
||||
Files and directories that have matching Bazel packages are subject to subsequent filters and
|
||||
|
@ -629,9 +635,15 @@ def copy_to_directory_action(
|
|||
if not srcs:
|
||||
fail("srcs must not be empty")
|
||||
|
||||
# Replace "." root paths with the package name of the target
|
||||
# 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
|
||||
include_srcs_packages = [p if p != "." else ctx.label.package for p in include_srcs_packages]
|
||||
|
||||
# Replace "./**" in include_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]
|
||||
|
||||
# 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:
|
||||
|
|
|
@ -28,6 +28,7 @@ load("//lib:directory_path.bzl", "make_directory_paths")
|
|||
"expected_16",
|
||||
"expected_17",
|
||||
"expected_18",
|
||||
"expected_19",
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -348,7 +349,7 @@ copy_to_directory(
|
|||
name = "case_15",
|
||||
srcs = case_srcs,
|
||||
include_external_repositories = ["externa?_*_rep*"],
|
||||
include_srcs_packages = [package_name()],
|
||||
include_srcs_packages = ["."],
|
||||
)
|
||||
|
||||
diff_test(
|
||||
|
@ -363,7 +364,7 @@ copy_to_directory(
|
|||
srcs = case_srcs,
|
||||
include_external_repositories = ["externa?_*_rep*"],
|
||||
include_srcs_packages = [
|
||||
package_name(),
|
||||
".",
|
||||
"",
|
||||
],
|
||||
)
|
||||
|
@ -400,3 +401,17 @@ diff_test(
|
|||
file1 = "case_18",
|
||||
file2 = ":expected_18",
|
||||
)
|
||||
|
||||
# Case 19: include_srcs_packages with "./**" expansion
|
||||
copy_to_directory(
|
||||
name = "case_19",
|
||||
srcs = case_srcs,
|
||||
include_external_repositories = ["externa?_*_rep*"],
|
||||
include_srcs_packages = ["./**"],
|
||||
)
|
||||
|
||||
diff_test(
|
||||
name = "case_19_test",
|
||||
file1 = "case_19",
|
||||
file2 = ":expected_19",
|
||||
)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
foobar
|
|
@ -0,0 +1 @@
|
|||
foobar
|
Loading…
Reference in New Issue