diff options
author | Sam Delmerico <delmerico@google.com> | 2022-02-22 15:07:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-02-22 15:07:07 +0000 |
commit | 4b4d2a699bc039712ece6c5caea330a6543b8da3 (patch) | |
tree | 308d3d03b1e5dfdb33815eefa6dae69ccead0d5b /json_module_graph | |
parent | 235126c0aa26c672c9e7db6535f5c3bce480b9e4 (diff) | |
parent | 26d987669e5b789e4b6d1430d521fe39f254e6a4 (diff) | |
download | bazel-4b4d2a699bc039712ece6c5caea330a6543b8da3.tar.gz |
Merge "add jq query for modules with specific property"
Diffstat (limited to 'json_module_graph')
-rw-r--r-- | json_module_graph/findModulesWithProperty.jq | 13 | ||||
-rwxr-xr-x | json_module_graph/query.sh | 8 |
2 files changed, 20 insertions, 1 deletions
diff --git a/json_module_graph/findModulesWithProperty.jq b/json_module_graph/findModulesWithProperty.jq new file mode 100644 index 00000000..79f9b1ae --- /dev/null +++ b/json_module_graph/findModulesWithProperty.jq @@ -0,0 +1,13 @@ +# CMD: Returns the modules of type $arg that have property $arg2 + +def hasPropertyWithName($a): + map(select(.Name == $a)) | + length | + . > 0 +; + +[.[] | +select(.Type == $arg) | +select(.Module.Android.SetProperties | + hasPropertyWithName($arg2)) | +.Name] | unique | sort | .[] diff --git a/json_module_graph/query.sh b/json_module_graph/query.sh index 5ae41327..fb3b6c09 100755 --- a/json_module_graph/query.sh +++ b/json_module_graph/query.sh @@ -45,4 +45,10 @@ else ARG="" fi -jq $JQARGS -L "$LIBDIR" -f "$LIBDIR/$COMMAND".jq "$GRAPH" --arg arg "$ARG" +if [[ "$#" -gt 3 ]]; then + ARG2="$4" +else + ARG2="" +fi + +jq $JQARGS -L "$LIBDIR" -f "$LIBDIR/$COMMAND".jq "$GRAPH" --arg arg "$ARG" --arg arg2 "$ARG2" |