Skip to main content

LazyCqueryContext

The context for performing lazy cquery operations in bxl. The functions offered on this ctx are the same behaviour as the query functions available within cquery command.

An instance may be obtained with bxl.LazyContext.cquery().

LazyCqueryContext.eval

def LazyCqueryContext.eval(
query: str,
/,
*,
query_args: None | target_set | list[str] = None,
target_universe: None | list[str] | tuple[str, ...] = None,
) -> bxl.Lazy

Evaluates some general query string. query_args can be a target_set of unconfigured nodes, or a list of strings. Returns a dict of target labels mapped to their target_set results if query_args was passed in, otherwise returns a single target_set.

Sample usage:

def _impl_eval(ctx):
result1 = ctx.lazy.cquery().eval("inputs(root//bin:the_binary)").resolve()
ctx.output.print(result1)

result2 = ctx.lazy.cquery().eval("inputs(%s)", query_args = ["cell//path/to/file:target"]).resolve()
ctx.output.print(result2)