bazel-contrib / bazel-lib

Common useful functions for writing BUILD files and Starlark macros/rules
Apache License 2.0
140 stars 90 forks source link

[FR]: support output groups in copy_file #977

Open joca-bt opened 4 weeks ago

joca-bt commented 4 weeks ago

Would it be possible to support output groups in copy_file? For example, to copy the tar generated by oci_load the user uses a filegroup and then a genrule (or copy_file). If copy_file could support output groups then these 2 steps could be merged into 1.

The idea is to replace something like:

oci_load(
    name = _oci_load,
    ...
)

native.filegroup(
    name = _filegroup,
    srcs = [
        _oci_load,
    ],
    output_group = "tarball",
)

native.genrule(
    name = name,
    srcs = [
        _filegroup,
    ],
    outs = [
        "{}.tar".format(name),
    ],
    cmd = "cp $< $@",
)

with something like:

oci_load(
    name = _oci_load,
    ...
)

copy_file(
    name = name,
    src = _oci_load,
    out = "{}.tar".format(name),
    ... # output groups configuration
)