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="".

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.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
datadata dependencies. See https://bazel.build/reference/be/common-definitions#typical.dataList of labelsoptional[]
outAn output name for the copy of the binaryStringrequired
srcpath of the pre-built executableLabelrequired

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.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
datadata dependencies. See https://bazel.build/reference/be/common-definitions#typical.dataList of labelsoptional[]
outAn output name for the copy of the binaryStringrequired
srcpath of the pre-built executableLabelrequired