bazel-skylib icon indicating copy to clipboard operation
bazel-skylib copied to clipboard

`native_binary`: use target name as filename by default

Open psigen opened this issue 3 years ago • 0 comments

This changes the out attribute in native binary to default to the target name if unspecified, which is convenient because it can be omitted when renaming targets that are linux executables and frequently share the target name.

:warning: This is just a proposal for feedback. If this looks interesting, I will clean up the change and can apply it more consistently over more of the native_* rules as suggested.

My motivating example: wrapping a ton of CLI tools like this:

native_binary(
    name = "kubectl",
    src = select({
        "@bazel_tools//src/conditions:linux_x86_64": "@io_k8s_kubectl_linux_x86_64//file:kubectl",
        "@bazel_tools//src/conditions:darwin_x86_64": "@io_k8s_kubectl_darwin_x86_64//file:kubectl",
    }),
    out = "kubectl",  # <--- it would be great to de-duplicate this
)

psigen avatar Jun 10 '22 12:06 psigen