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="".
load("@bazel_skylib//rules:native_binary.bzl", "native_binary") native_binary(<a href="#native_binary-name">name</a>, <a href="#native_binary-src">src</a>, <a href="#native_binary-data">data</a>, <a href="#native_binary-out">out</a>, <a href="#native_binary-env">env</a>)
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
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| src | path of the pre-built executable | Label | required | |
| data | data dependencies. See https://bazel.build/reference/be/common-definitions#typical.data | List of labels | optional | [] |
| out | An output name for the copy of the binary. Defaults to name.exe. (We add .exe to the name by default because it's required on Windows and tolerated on other platforms.) | String | optional | "" |
| env | Environment variables to set when running the binary. | Dictionary: String -> String | optional | {} |
load("@bazel_skylib//rules:native_binary.bzl", "native_test") native_test(<a href="#native_test-name">name</a>, <a href="#native_test-src">src</a>, <a href="#native_test-data">data</a>, <a href="#native_test-out">out</a>, <a href="#native_test-env">env</a>)
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
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| src | path of the pre-built executable | Label | required | |
| data | data dependencies. See https://bazel.build/reference/be/common-definitions#typical.data | List of labels | optional | [] |
| out | An output name for the copy of the binary. Defaults to name.exe. (We add .exe to the name by default because it's required on Windows and tolerated on other platforms.) | String | optional | "" |
| env | Environment variables to set when running the binary. | Dictionary: String -> String | optional | {} |