Skip to content

Commit 8510160

Browse files
committed
chore: simplify script
1 parent d7ea41a commit 8510160

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

scripts/build-brillig-gates-report.sh

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,14 @@ artifacts_path="./export"
88
artifacts=$(ls $artifacts_path)
99

1010
# Start the JSON array
11-
echo "{\"programs\": [" > opcode_report.json
11+
REPORTS=$(jq --null-input '[]')
1212

13-
first=true
1413
for artifact in $artifacts; do
15-
ARTIFACT_NAME=$(basename "$artifact")
16-
# Remove .json extension from the name
17-
ARTIFACT_NAME_NO_EXT="${ARTIFACT_NAME%.json}"
18-
19-
# Add comma before object if not first item
20-
if [ "$first" = true ]; then
21-
first=false
22-
else
23-
echo "," >> opcode_report.json
24-
fi
25-
2614
# Get and format the opcode info
27-
OPT_CODE_INFO=$($INSPECTOR info --json "$artifacts_path/$artifact")
28-
29-
# Simplified jq expression to output only package_name and opcodes from unconstrained_functions
30-
echo "$(echo $OPT_CODE_INFO | jq --arg name "$ARTIFACT_NAME_NO_EXT" '{
31-
package_name: $name,
32-
unconstrained_functions: (
33-
if .programs then
34-
(.programs[].unconstrained_functions | map({name: .name, opcodes: .opcodes}))
35-
else
36-
[]
37-
end
38-
)
39-
}')" >> opcode_report.json
15+
OP_CODE_INFO=$($INSPECTOR info --json "$artifacts_path/$artifact")
4016

17+
# Simplified jq expression to output only package_name and opcodes from unconstrained_functions
18+
REPORTS=$(echo $OP_CODE_INFO | jq -c '.programs[0] | del(.functions)' | jq -c --argjson old_reports $REPORTS '$old_reports + [.]')
4119
done
4220

43-
# Close the JSON structure
44-
echo "]}" >> opcode_report.json
21+
echo $REPORTS | jq '{ programs: . }' > opcode_report.json

0 commit comments

Comments
 (0)