bazel_target

Resolver-generated Bazel library-style rule materialized as a Struo graph target.

Description#

bazel_target is created by the bazel_workspace resolver for every rule whose class does not end in _test or _binary. Direct authoring of bazel_target in struo.toml is rejected: the resolver must materialize it so the bazel_label and bazel_rule_kind attributes stay tied to real Bazel state.

bazel_target reads the action graph for its label through bazel aquery and executes the selected default output, runfiles and validation closure from <workspace>/.struo/bazel-actions/. Bazel supplies analysis and external repository downloads. bazel build is not invoked in the ownership path. Owned spawns have explicit environments and declared inputs and outputs; spawn caching additionally requires complete toolchain_inputs. File writes, aliases and manifest-mapped runfiles use cacheable Struo primitives.

Before a spawn executes on a cache miss, Struo removes its declared outputs, matching Bazel's clean-output contract. Warm hits restore those outputs instead of rerunning the command.

Unknown required action contracts fall back to bazel build <label> and record the unsupported mnemonics on the provider. Struo settles this from an action graph without file contents or parameter files before it requests the full graph, which for a large workspace can be hundreds of mebibytes. Delegated commands run with the workspace's own configuration, so they share Bazel's caches and outputs with native bazel build invocations, and remain uncached by Struo.

Ownership-mode outputs land under <workspace>/.struo/bazel-actions/bazel-out/. Fallback-mode outputs land in Bazel's output tree, reported by bazel info output_path. Struo leaves the bazel-bin and bazel-out convenience links untouched.

Attributes#

AttributeTypeRequiredDefaultDescription
bazel_labelstringyesFully qualified Bazel label of the underlying rule, for example //src:kura_lib. Set by the resolver.
bazel_rule_kindstringyesBazel rule class reported by bazel query --output=label_kind, for example rust_library. Set by the resolver.
bazelstringnobazelBazel executable forwarded from the workspace seed.
envmap<string,string>no{}Declared environment forwarded from the workspace seed. Empty values override inherited host variables; native aquery action environments take precedence.
toolchain_inputslist<string>no[]Complete implicit host toolchain inputs, forwarded from the workspace seed. Required for spawn caching.
test_envmap<string,string>no{}Test runtime environment forwarded from the workspace seed.

Providers and capabilities#

The target emits bazel_target and exposes only the build capability. Use bazel_test for test rules and bazel_binary for binary rules.

Direct use#

bazel_target is discovered through its workspace seed. Query the graph to list the materialized rules and their labels:

bash
struo query targets

Build one label without leaving the Struo command surface:

bash
struo bazel build //src:kura_lib

See the bazel_workspace reference for the workspace-level attributes that control graph enumeration.

Sources#