Skip to main content
Version: 1.5.x

native_binary

native_binary() and native_test() rule implementations.

These rules let you wrap a pre-built binary or script in a conventional binary and test rule respectively. They fulfill the same goal as sh_binary and sh_test do, but they run the wrapped binary directly, instead of through Bash, so they don't depend on Bash and work with --shell_executable="".

Rules

native_binary

Wraps a pre-built binary or script with a binary rule.

You can "bazel run" this rule like any other binary rule, and use it as a tool in genrule.tools for example. You can also augment the binary with runfiles.

Example usage (generated):

load("@bazel_skylib//rules:native_binary.bzl", "native_binary")

native_binary(
# A unique name for this target.
name = "",
# An output name for the copy of the binary
out = "",
# path of the pre-built executable
src = "",
)

name

Required name.

A unique name for this target.

data

Optional list of labels. Default: []

data dependencies. See https://bazel.build/reference/be/common-definitions#typical.data

out

Required string.

An output name for the copy of the binary

src

Required label.

path of the pre-built executable

native_test

Wraps a pre-built binary or script with a test rule.

You can "bazel test" this rule like any other test rule. You can also augment the binary with runfiles.

Example usage (generated):

load("@bazel_skylib//rules:native_binary.bzl", "native_test")

native_test(
# A unique name for this target.
name = "",
# An output name for the copy of the binary
out = "",
# path of the pre-built executable
src = "",
)

name

Required name.

A unique name for this target.

data

Optional list of labels. Default: []

data dependencies. See https://bazel.build/reference/be/common-definitions#typical.data

out

Required string.

An output name for the copy of the binary

src

Required label.

path of the pre-built executable