Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: ensure that we have jq, fail if it fails #7662

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ else
exit 1
fi

if ! check_command 'jq' jq; then
echo "*** We need jq!" >&2
exit 1
fi

# Now we can finally set our warning flags
if [ -z ${CWARNFLAGS+x} ]; then
CWARNFLAGS=$(default_cwarnflags "$COPTFLAGS" \
Expand Down
28 changes: 16 additions & 12 deletions plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,29 @@ plugins/recklessrpc: $(PLUGIN_RECKLESSRPC_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMM
# This covers all the low-level list RPCs which return simple arrays
SQL_LISTRPCS := listchannels listforwards listhtlcs listinvoices listnodes listoffers listpeers listpeerchannels listclosedchannels listtransactions listsendpays bkpr-listaccountevents bkpr-listincome
SQL_LISTRPCS_SCHEMAS := $(foreach l,$(SQL_LISTRPCS),doc/schemas/lightning-$l.json)
SQL_SCHEMA_PARTS := $(foreach l,$(SQL_LISTRPCS), plugins/sql-schema_$l_gen.h)

# RES_JSON is generated by:
# 1: deleting description array (used for field details) but keeping description keys
# 2: deleting additionalProperties, required, enum, maxLength, minLength, pre_return_value_notes, post_return_value_notes, anyOf, oneOf, hidden, untyped, default, comment, added, maximum, minimum, pattern, format
# (We only need [field].type, [field].name, [field].deprecated, [field].allOf, [field].items.allOf and allOf from response.properties)
# 3: deleting empty objects from .response.properties
# But these simple removals drop us from 100k to 18k.
plugins/sql-schema_gen.h: plugins/Makefile $(SQL_LISTRPCS_SCHEMAS)
@$(call VERBOSE,GEN $@, \
( \
SEP=""; \
echo '"{'; \
for f in $(SQL_LISTRPCS); do \
RES_JSON=$$(echo "$$(jq 'walk(if type == "object" then if has("description") and (.description | type) == "array" then del(.description) else . end else . end ) | walk(if type == "object" then del(.additionalProperties, .required, .enum, .maxLength, .minLength, .pre_return_value_notes, .post_return_value_notes, .anyOf, .oneOf, .hidden, .untyped, .default, .comment, .added, .maximum, .minimum, .pattern, .format) else . end) | walk(if type == "object" then with_entries(select(.value != {})) else . end) | .response.properties' < doc/schemas/lightning-$$f.json)" | sed 's/"/\\"/g'); \
echo "$$SEP\\\"$$f\\\":{\\\"properties\\\": $$RES_JSON}"; \
SEP=","; \
done; \
echo '}"' \
) | tr -d ' \n' > $@ \
plugins/sql-schema_%_gen.h: doc/schemas/lightning-%.json
@jq 'walk(if type == "object" then if has("description") and (.description | type) == "array" then del(.description) else . end else . end ) | walk(if type == "object" then del(.additionalProperties, .required, .enum, .maxLength, .minLength, .pre_return_value_notes, .post_return_value_notes, .anyOf, .oneOf, .hidden, .untyped, .default, .comment, .added, .maximum, .minimum, .pattern, .format) else . end) | walk(if type == "object" then with_entries(select(.value != {})) else . end) | .response.properties' < $< > $@

# Regen if these rules change!
$(SQL_SCHEMA_PARTS): plugins/Makefile

plugins/sql-schema_gen.h: $(SQL_SCHEMA_PARTS)
@$(call VERBOSE,GEN $@, set -e; (\
SEP=""; \
echo "\"{"; \
for l in $(SQL_LISTRPCS); do \
echo "$$SEP\"$$l\":{\"properties\":$$(cat plugins/sql-schema_$${l}_gen.h)}" | sed s/\"/\\\"/g; \
SEP=","; \
done | sed "s/\\\"/\\\\\"/g"; \
echo "}\"") | tr -d " \n" > $@ \
)

plugins/sql.o: plugins/sql-schema_gen.h
Expand Down
Loading