compatible_with | List of labels; nonconfigurable; default is [] The list of environments this target can be built for, in addition to default-supported environments. This is part of Bazel’s constraint system, which lets users declare which targets can and cannot depend on each other. For example, externally deployable binaries shouldn’t depend on libraries with company-secret code. See ConstraintSemantics for details. |
deprecation | String; nonconfigurable; default is None An explanatory warning message associated with this target. Typically this is used to notify users that a target has become obsolete, or has become superseded by another rule, is private to a package, or is perhaps considered harmful for some reason. It is a good idea to include some reference (like a webpage, a bug number or example migration CLs) so that one can easily find out what changes are required to avoid the message. If there is a new target that can be used as a drop in replacement, it is a good idea to just migrate all users of the old target. This attribute has no effect on the way things are built, but it may affect a build tool’s diagnostic output. The build tool issues a warning when a rule with a deprecation attribute is depended upon by a target in another package. Intra-package dependencies are exempt from this warning, so that, for example, building the tests of a deprecated rule does not encounter a warning. If a deprecated target depends on another deprecated target, no warning message is issued. Once people have stopped using it, the target can be removed. |
distribs | List of strings; nonconfigurable; default is [] A list of distribution-method strings to be used for this particular target. This is part of a deprecated licensing API that Bazel no longer uses. Don’t use this. |
exec_compatible_with | List of labels; nonconfigurable; default is [] A list of constraint_values that must be present in the execution platform for this target. This is in addition to any constraints already set by the rule type. Constraints are used to restrict the list of available execution platforms. For more details, see the description of toolchain resolution. |
exec_properties | Dictionary of strings; default is {} A dictionary of strings that will be added to the exec_properties of a platform selected for this target. See exec_properties of the platform rule. If a key is present in both the platform and target-level properties, the value will be taken from the target. |
features | List of feature strings; default is [] A feature is string tag that can be enabled or disabled on a target. The meaning of a feature depends on the rule itself. This features attribute is combined with the package level features attribute. For example, if the features [“a”, “b”] are enabled on the package level, and a target’s features attribute contains [“-a”, “c”], the features enabled for the rule will be “b” and “c”. See example. |
restricted_to | List of labels; nonconfigurable; default is [] The list of environments this target can be built for, instead of default-supported environments. This is part of Bazel’s constraint system. See compatible_with for details. |
tags | List of strings; nonconfigurable; default is [] Tags can be used on any rule. Tags on test and test_suite rules are useful for categorizing the tests. Tags on non-test targets are used to control sandboxed execution of genrules and Starlark actions, and for parsing by humans and/or external tools. Bazel modifies the behavior of its sandboxing code if it finds the following keywords in the tags attribute of any test or genrule target, or the keys of execution_requirements for any Starlark action. * no-sandbox keyword results in the action or test never being sandboxed; it can still be cached or run remotely - use no-cache or no-remote to prevent either or both of those. * no-cache keyword results in the action or test never being cached (remotely or locally) * no-remote-cache keyword results in the action or test never being cached remotely (but it may be cached locally; it may also be executed remotely). Note: for the purposes of this tag, the disk-cache is considered a local cache, whereas the http and gRPC caches are considered remote. If a combination of local disk cache and remote cache are used (combined cache), it’s treated as a remote cache and disabled entirely unless --incompatible_remote_results_ignore_disk is set in which case the local components will be used. * no-remote-exec keyword results in the action or test never being executed remotely (but it may be cached remotely). * no-remote keyword prevents the action or test from being executed remotely or cached remotely. This is equivalent to using both no-remote-cache and no-remote-exec. * no-remote-cache-upload keyword disables upload part of remote caching of a spawn. it does not disable remote execution. * local keyword precludes the action or test from being remotely cached, remotely executed, or run inside the sandbox. For genrules and tests, marking the rule with the local = True attribute has the same effect. * requires-network keyword allows access to the external network from inside the sandbox. This tag only has an effect if sandboxing is enabled. * block-network keyword blocks access to the external network from inside the sandbox. In this case, only communication with localhost is allowed. This tag only has an effect if sandboxing is enabled. * requires-fakeroot runs the test or action as uid and gid 0 (i.e., the root user). This is only supported on Linux. This tag takes precedence over the --sandbox_fake_username command-line option. Tags on tests are generally used to annotate a test’s role in your debug and release process. Typically, tags are most useful for C++ and Python tests, which lack any runtime annotation ability. The use of tags and size elements gives flexibility in assembling suites of tests based around codebase check-in policy. Bazel modifies test running behavior if it finds the following keywords in the tags attribute of the test rule: * exclusive will force the test to be run in the “exclusive” mode, ensuring that no other tests are running at the same time. Such tests will be executed in serial fashion after all build activity and non-exclusive tests have been completed. Remote execution is disabled for such tests because Bazel doesn’t have control over what’s running on a remote machine. * exclusive-if-local will force the test to be run in the “exclusive” mode if it is executed locally, but will run the test in parallel if it’s executed remotely. * manual keyword will exclude the target from expansion of target pattern wildcards (..., :*, :all, etc.) and test_suite rules which do not list the test explicitly when computing the set of top-level targets to build/run for the build, test, and coverage commands. It does not affect target wildcard or test suite expansion in other contexts, including the query command. Note that manual does not imply that a target should not be built/run automatically by continuous build/test systems. For example, it may be desirable to exclude a target from bazel test ... because it requires specific Bazel flags, but still have it included in properly-configured presubmit or continuous test runs. * external keyword will force test to be unconditionally executed (regardless of --cache_test_results value). See Tag Conventions in the Test Encyclopedia for more conventions on tags attached to test targets. |
target_compatible_with | List of labels; default is [] A list of constraint_values that must be present in the target platform for this target to be considered compatible. This is in addition to any constraints already set by the rule type. If the target platform does not satisfy all listed constraints then the target is considered incompatible. Incompatible targets are skipped for building and testing when the target pattern is expanded (e.g. //..., :all). When explicitly specified on the command line, incompatible targets cause Bazel to print an error and cause a build or test failure. Targets that transitively depend on incompatible targets are themselves considered incompatible. They are also skipped for building and testing. An empty list (which is the default) signifies that the target is compatible with all platforms. All rules other than Workspace Rules support this attribute. For some rules this attribute has no effect. For example, specifying target_compatible_with for a cc_toolchain is not useful. See the Platforms page for more information about incompatible target skipping. |
testonly | Boolean; nonconfigurable; default is False except for test and test suite targets If True, only testonly targets (such as tests) can depend on this target. Equivalently, a rule that is not testonly is not allowed to depend on any rule that is testonly. Tests (*_test rules) and test suites (test_suite rules) are testonly by default. This attribute is intended to mean that the target should not be contained in binaries that are released to production. Because testonly is enforced at build time, not run time, and propagates virally through the dependency tree, it should be applied judiciously. For example, stubs and fakes that are useful for unit tests may also be useful for integration tests involving the same binaries that will be released to production, and therefore should probably not be marked testonly. Conversely, rules that are dangerous to even link in, perhaps because they unconditionally override normal behavior, should definitely be marked testonly. |
toolchains | List of labels; nonconfigurable; default is [] The set of targets whose Make variables this target is allowed to access. These targets are either instances of rules that provide TemplateVariableInfo or special targets for toolchain types built into Bazel. These include: * @bazel_tools//tools/cpp:current_cc_toolchain* @bazel_tools//tools/jdk:current_java_runtime Note that this is distinct from the concept of toolchain resolution that is used by rule implementations for platform-dependent configuration. You cannot use this attribute to determine which specific cc_toolchain or java_toolchain a target will use. |
visibility | List of labels; nonconfigurable; default is default_visibility from package if specified, or "//visibility:private" otherwise The visibility attribute on a target controls whether the target can be used in other packages. See the documentation for visibility. |