Documentation Index
Fetch the complete documentation index at: https://docs.aspect.build/llms.txt
Use this file to discover all available pages before exploring further.
Documentation for @jq.bzl@v0.6.0 — View source
BUILD file with:
Examples
Create a new filebazel-out/.../no_srcs.json containing some JSON data:
package.json:
The output pathbazel-out/.../package.jsonmatches the path of the source file, which means you must refer to the label:no_dev_depsto reference the output, since Bazel doesn’t provide a label for an output file that collides with an input file.
bar.json on top of foo.json, producing foobar.json:
filter.jq, making it easier to edit complex filters:
--stamp, replace some properties with version control info:
genrule by referencing the toolchain.
Rule: jq_rule
Most users should use the jq macro instead.
Attributes
A unique name for this target.
Whether to encode build information into the output. Possible values:
stamp = 1: Always stamp the build information into the output, even in —nostamp builds. This setting should be avoided, since it is non-deterministic. It potentially causes remote cache misses for the target and any downstream actions that depend on the result.stamp = 0: Never stamp, instead replace build information by constant values. This gives good build result caching.stamp = -1: Embedding of build information is controlled by the —[no]stamp flag. Stamped targets are not rebuilt unless their dependencies change.
Function: jq_lib.implementation
Parameters
Function: jq_lib.jq_action
Run jq as a Bazel action.
Parameters
The Bazel action context object
The list of source files jq should process
The filter expression string OR a file containing the filter for —from-file
The output file
Additional arguments to jq
Files jq may need to read at runtime which are referenced in flags like —from-file
Function: jq
Invoke jq with a filter on a set of json input files.
Parameters
Name of the rule
List of input files. May be empty.
Filter expression (https://jqlang.org/manual/#basic-filters).
Subject to stamp variable replacements, see Stamping.
When stamping is enabled, a variable named “STAMP” will be available in the filter.Be careful to write the filter so that it handles unstamped builds, as in the example above.
File containing filter expression (alternative to
filter)Additional args to pass to jq
Name of the output json file; defaults to the rule name plus “.json”
List of additional files. May be empty.
Run bazel’s location and make variable expansion on the args.
Other common named parameters such as
tags or visibilityFunction: jq_test
Assert that the given json files have the same semantic content.
Uses jq to filter each file. The default value of "." as the filter
means to compare the whole file.
See the jq macro for more about the filter expressions as well as
setup notes for the jq toolchain.
Note that this macro is equivalent to calling bazel_lib’s diff_test with the jq outputs.
Parameters
name of resulting diff_test target
a json file
another json file
a jq filter to apply to file1
a jq filter to apply to file2
additional named arguments for the resulting diff_test

