mirror of
https://github.com/bazel-contrib/bazel-lib
synced 2024-11-28 21:33:48 +00:00
323329f119
* fix: always include files from the same workspace as the build target in `copy_to_directory` Fixes #359. This updates the `copy_to_directory` tool to accept a workspace name representing the workspace of the target it is executing under. Any files in this workspace are automatically included, regardless of the `include_external_repositories` option. This makes it support usage within an external target (such as `@wksp//:dir`). * test: add e2e test which uses `copy_to_directory` within an external workspace Refs #359. This should catch regressions where no files are copied when built within an external workspace and not using `include_external_repositories`. * ci: fix stray workspace refs --------- Co-authored-by: Alex Eagle <alex@aspect.dev>
37 lines
960 B
Python
37 lines
960 B
Python
"""Test rule executing `copy_to_directory_bin_action`."""
|
|
|
|
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory_bin_action")
|
|
|
|
def _directory_impl(ctx):
|
|
dst = ctx.actions.declare_directory(ctx.attr.name)
|
|
|
|
copy_to_directory_bin_action(
|
|
ctx,
|
|
name = ctx.attr.name,
|
|
copy_to_directory_bin = ctx.executable._tool,
|
|
dst = dst,
|
|
files = ctx.files.srcs,
|
|
verbose = True,
|
|
)
|
|
|
|
return DefaultInfo(files = depset([dst]))
|
|
|
|
directory = rule(
|
|
implementation = _directory_impl,
|
|
attrs = {
|
|
"srcs": attr.label_list(
|
|
mandatory = True,
|
|
allow_files = True,
|
|
),
|
|
"_tool": attr.label(
|
|
executable = True,
|
|
cfg = "exec",
|
|
default = "@aspect_bazel_lib//tools/copy_to_directory",
|
|
),
|
|
},
|
|
doc = """
|
|
Copies the given source files to a directory with
|
|
`copy_to_directory_bin_action()`.
|
|
""",
|
|
)
|