Files

284 lines
10 KiB
Makefile
Raw Permalink Normal View History

PLUGIN_PAY_SRC := plugins/pay.c
PLUGIN_PAY_HEADER :=
PLUGIN_PAY_OBJS := $(PLUGIN_PAY_SRC:.c=.o)
PLUGIN_AUTOCLEAN_SRC := plugins/autoclean.c
PLUGIN_AUTOCLEAN_OBJS := $(PLUGIN_AUTOCLEAN_SRC:.c=.o)
PLUGIN_chanbackup_SRC := plugins/chanbackup.c
PLUGIN_chanbackup_OBJS := $(PLUGIN_chanbackup_SRC:.c=.o)
PLUGIN_TOPOLOGY_SRC := plugins/topology.c
PLUGIN_TOPOLOGY_OBJS := $(PLUGIN_TOPOLOGY_SRC:.c=.o)
PLUGIN_TXPREPARE_SRC := plugins/txprepare.c
PLUGIN_TXPREPARE_OBJS := $(PLUGIN_TXPREPARE_SRC:.c=.o)
PLUGIN_BCLI_SRC := plugins/bcli.c
PLUGIN_BCLI_OBJS := $(PLUGIN_BCLI_SRC:.c=.o)
PLUGIN_COMMANDO_SRC := plugins/commando.c
PLUGIN_COMMANDO_OBJS := $(PLUGIN_COMMANDO_SRC:.c=.o)
2020-03-27 14:31:00 +01:00
PLUGIN_KEYSEND_SRC := plugins/keysend.c
PLUGIN_KEYSEND_OBJS := $(PLUGIN_KEYSEND_SRC:.c=.o)
Makefile: create a library containing common, wire and bitcoin objects. This means we don't have to manually choose what to link against, which is much of the complexity of our Makefiles: the compiler will automatically use any object files it needs to link. We already do this for ccan as libccan.a, now we have libcommon.a. We don't link against it for *everything*, as some tests require their own versions. Notes: 1. I get rid of the weird plugins/test/Makefile2 (accidental commit?) 2. Many tests change due to update-mocks. 3. In some places I added the missing dependency on the Makefile itself, though most are in the next patch. Before: Total program size: 221366528 Total tests size: 364243856 After: Total program size: 190733656 Total tests size: 337880888 Build time from make clean (RUST=0) (includes building external libs): Before: real 0m38.227000-44.245000(41.8222+/-1.6)s user 3m2.105000-33.696000(23.1442+/-8.4)s sys 0m35.054000-42.269000(39.7231+/-2)s After: real 0m38.944000-40.416000(40.1131+/-0.4)s user 3m6.790000-17.159000(15.0571+/-2.8)s sys 0m35.304000-37.336000(36.8942+/-0.57)s Build time after touch config.vars (RUST=0): Before: real 0m18.928000-22.776000(21.5084+/-1.1)s user 2m8.613000-36.567000(27.7281+/-7.7)s sys 0m20.458000-23.436000(22.3963+/-0.77)s After: real 0m19.831000-21.862000(21.5528+/-0.58)s user 2m15.361000-30.731000(28.4798+/-4.4)s sys 0m21.056000-22.339000(22.0346+/-0.35)s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> rusty@rusty-Framework:~/devel/cvs/lightni
2025-10-22 19:44:26 +10:30
PLUGIN_LIB_SRC := plugins/libplugin.c
PLUGIN_LIB_HEADER := plugins/libplugin.h
PLUGIN_LIB_OBJS := $(PLUGIN_LIB_SRC:.c=.o)
PLUGIN_PAY_LIB_SRC := \
plugins/channel_hint.c \
plugins/libplugin-pay.c
PLUGIN_PAY_LIB_HEADER := \
plugins/channel_hint.h \
plugins/libplugin-pay.h
PLUGIN_PAY_LIB_OBJS := $(PLUGIN_PAY_LIB_SRC:.c=.o)
PLUGIN_OFFERS_SRC := plugins/offers.c plugins/offers_offer.c plugins/offers_invreq_hook.c plugins/offers_inv_hook.c plugins/establish_onion_path.c plugins/fetchinvoice.c
PLUGIN_OFFERS_OBJS := $(PLUGIN_OFFERS_SRC:.c=.o)
PLUGIN_OFFERS_HEADER := $(PLUGIN_OFFERS_SRC:.c=.h)
PLUGIN_SQL_SRC := plugins/sql.c
PLUGIN_SQL_HEADER :=
PLUGIN_SQL_OBJS := $(PLUGIN_SQL_SRC:.c=.o)
PLUGIN_EXPOSESECRET_SRC := plugins/exposesecret.c
PLUGIN_EXPOSESECRET_HEADER :=
PLUGIN_EXPOSESECRET_OBJS := $(PLUGIN_EXPOSESECRET_SRC:.c=.o)
PLUGIN_SPENDER_SRC := \
plugins/spender/fundchannel.c \
plugins/spender/main.c \
plugins/spender/multifundchannel.c \
plugins/spender/multiwithdraw.c \
plugins/spender/openchannel.c \
plugins/spender/splice.c
PLUGIN_SPENDER_HEADER := \
plugins/spender/multifundchannel.h \
plugins/spender/multiwithdraw.h \
plugins/spender/fundchannel.h \
plugins/spender/multifundchannel.h \
plugins/spender/openchannel.h \
plugins/spender/splice.h
PLUGIN_SPENDER_OBJS := $(PLUGIN_SPENDER_SRC:.c=.o)
PLUGIN_RECOVER_SRC := plugins/recover.c
PLUGIN_RECOVER_OBJS := $(PLUGIN_RECOVER_SRC:.c=.o)
PLUGIN_FUNDER_SRC := \
plugins/funder.c \
plugins/funder_policy.c
PLUGIN_FUNDER_HEADER := \
plugins/funder_policy.h
PLUGIN_FUNDER_OBJS := $(PLUGIN_FUNDER_SRC:.c=.o)
PLUGIN_RECKLESSRPC_SRC := plugins/recklessrpc.c
PLUGIN_RECKLESSRPC_OBJS := $(PLUGIN_RECKLESSRPC_SRC:.c=.o)
PLUGIN_ALL_SRC := \
$(PLUGIN_AUTOCLEAN_SRC) \
$(PLUGIN_chanbackup_SRC) \
$(PLUGIN_BCLI_SRC) \
$(PLUGIN_COMMANDO_SRC) \
$(PLUGIN_FUNDER_SRC) \
$(PLUGIN_TOPOLOGY_SRC) \
$(PLUGIN_EXPOSESECRET_SRC) \
$(PLUGIN_KEYSEND_SRC) \
$(PLUGIN_TXPREPARE_SRC) \
$(PLUGIN_LIB_SRC) \
$(PLUGIN_OFFERS_SRC) \
$(PLUGIN_PAY_LIB_SRC) \
$(PLUGIN_PAY_SRC) \
$(PLUGIN_SPENDER_SRC) \
$(PLUGIN_RECOVER_SRC) \
$(PLUGIN_RECKLESSRPC_SRC)
PLUGIN_ALL_HEADER := \
$(PLUGIN_PAY_HEADER) \
$(PLUGIN_LIB_HEADER) \
$(PLUGIN_FUNDER_HEADER) \
$(PLUGIN_PAY_LIB_HEADER) \
$(PLUGIN_OFFERS_HEADER) \
$(PLUGIN_SPENDER_HEADER)
C_PLUGINS := \
plugins/autoclean \
plugins/chanbackup \
plugins/bcli \
plugins/commando \
plugins/funder \
plugins/topology \
plugins/exposesecret \
plugins/keysend \
plugins/offers \
plugins/pay \
plugins/recklessrpc \
plugins/recover \
plugins/txprepare \
plugins/cln-renepay \
plugins/cln-xpay \
plugins/spenderp \
plugins/cln-askrene
ifeq ($(HAVE_SQLITE3),1)
C_PLUGINS += plugins/sql
PLUGIN_ALL_SRC += $(PLUGIN_SQL_SRC)
PLUGIN_ALL_HEADER += $(PLUGIN_SQL_HEADER)
endif
# This is non-python plugins (PY_PLUGINS need their whole directory!)
PLUGINS := $(C_PLUGINS)
# Remove clnrest directory if exists which is the old python plugin code
$(shell test -d plugins/clnrest && $(RM) -r plugins/clnrest || true)
# Remove wss-proxy directory if exists which is the old python plugin code
$(shell test -d plugins/wss-proxy && $(RM) -r plugins/wss-proxy || true)
ifneq ($(RUST),0)
# Builtin plugins must be in this plugins dir to work when we're executed
# *without* make install.
plugins/cln-grpc: $(RUST_TARGET_DIR)/cln-grpc
@cp $< $@
plugins/clnrest: $(RUST_TARGET_DIR)/clnrest
@cp $< $@
plugins/cln-lsps-client: $(RUST_TARGET_DIR)/cln-lsps-client
@cp $< $@
plugins/cln-lsps-service: $(RUST_TARGET_DIR)/cln-lsps-service
@cp $< $@
plugins/wss-proxy: $(RUST_TARGET_DIR)/wss-proxy
@cp $< $@
plugins/cln-bip353: $(RUST_TARGET_DIR)/cln-bip353
@cp $< $@
PLUGINS += plugins/cln-grpc plugins/clnrest plugins/cln-lsps-client plugins/cln-lsps-service plugins/wss-proxy plugins/cln-bip353
endif
include plugins/askrene/Makefile
include plugins/bkpr/Makefile
include plugins/renepay/Makefile
include plugins/xpay/Makefile
# Make sure these depend on everything.
ALL_C_SOURCES += $(PLUGIN_ALL_SRC)
ALL_C_HEADERS += $(PLUGIN_ALL_HEADER)
ALL_PROGRAMS += $(C_PLUGINS)
PLUGIN_ALL_OBJS := $(PLUGIN_ALL_SRC:.c=.o)
# Make all plugins depend on all plugin headers, for simplicity (and this file!)
$(PLUGIN_ALL_OBJS): $(PLUGIN_ALL_HEADER) plugins/Makefile
plugins/pay: $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) libcommon.a
plugins/autoclean: $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/chanbackup: $(PLUGIN_chanbackup_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/commando: $(PLUGIN_COMMANDO_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
# Topology wants to decode node_announcement, and peer_wiregen which
# pulls in some of bitcoin/.
plugins/topology: $(PLUGIN_TOPOLOGY_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/txprepare: $(PLUGIN_TXPREPARE_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/exposesecret: $(PLUGIN_EXPOSESECRET_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/bcli: $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/keysend: $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) libcommon.a
Makefile: create a library containing common, wire and bitcoin objects. This means we don't have to manually choose what to link against, which is much of the complexity of our Makefiles: the compiler will automatically use any object files it needs to link. We already do this for ccan as libccan.a, now we have libcommon.a. We don't link against it for *everything*, as some tests require their own versions. Notes: 1. I get rid of the weird plugins/test/Makefile2 (accidental commit?) 2. Many tests change due to update-mocks. 3. In some places I added the missing dependency on the Makefile itself, though most are in the next patch. Before: Total program size: 221366528 Total tests size: 364243856 After: Total program size: 190733656 Total tests size: 337880888 Build time from make clean (RUST=0) (includes building external libs): Before: real 0m38.227000-44.245000(41.8222+/-1.6)s user 3m2.105000-33.696000(23.1442+/-8.4)s sys 0m35.054000-42.269000(39.7231+/-2)s After: real 0m38.944000-40.416000(40.1131+/-0.4)s user 3m6.790000-17.159000(15.0571+/-2.8)s sys 0m35.304000-37.336000(36.8942+/-0.57)s Build time after touch config.vars (RUST=0): Before: real 0m18.928000-22.776000(21.5084+/-1.1)s user 2m8.613000-36.567000(27.7281+/-7.7)s sys 0m20.458000-23.436000(22.3963+/-0.77)s After: real 0m19.831000-21.862000(21.5528+/-0.58)s user 2m15.361000-30.731000(28.4798+/-4.4)s sys 0m21.056000-22.339000(22.0346+/-0.35)s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> rusty@rusty-Framework:~/devel/cvs/lightni
2025-10-22 19:44:26 +10:30
$(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER) libcommon.a
2020-03-27 14:31:00 +01:00
plugins/spenderp: $(PLUGIN_SPENDER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/offers: $(PLUGIN_OFFERS_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/funder: $(PLUGIN_FUNDER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/recover: $(PLUGIN_RECOVER_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
plugins/recklessrpc: $(PLUGIN_RECKLESSRPC_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
# 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 listchainmoves listchannelmoves bkpr-listaccountevents bkpr-listincome listnetworkevents
SQL_LISTRPCS_SCHEMAS := $(foreach l,$(SQL_LISTRPCS),doc/schemas/$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: doc/schemas/%.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
plugins/sql: $(PLUGIN_SQL_OBJS) $(PLUGIN_LIB_OBJS) libcommon.a
# Generated from PLUGINS definition in plugins/Makefile
ALL_C_HEADERS += plugins/list_of_builtin_plugins_gen.h
PLUGIN_BASES := $(PLUGINS:plugins/%=%) $(PY_PLUGINS:plugins/%=%)
plugins/list_of_builtin_plugins_gen.h: plugins/Makefile Makefile config.vars
@$(call VERBOSE,GEN $@,echo "static const char *list_of_builtin_plugins[] = { $(PLUGIN_BASES:%=\"%\",) NULL };" > $@)
$(RUST_TARGET_DIR)/examples/cln-subscribe-wildcard: ${CLN_PLUGIN_SRC} plugins/examples/cln-subscribe-wildcard.rs
cargo build ${CARGO_OPTS} --example cln-subscribe-wildcard
CLN_PLUGIN_EXAMPLES := \
$(RUST_TARGET_DIR)/examples/cln-plugin-startup \
$(RUST_TARGET_DIR)/examples/cln-plugin-reentrant \
$(RUST_TARGET_DIR)/examples/cln-rpc-getinfo \
$(RUST_TARGET_DIR)/examples/cln-subscribe-wildcard
CLN_PLUGIN_SRC = $(shell find plugins/src -name "*.rs")
CLN_GRPC_PLUGIN_SRC = $(shell find plugins/grpc-plugin/src -name "*.rs")
CLN_REST_PLUGIN_SRC = $(shell find plugins/rest-plugin/src -name "*.rs")
CLN_LSPS_PLUGIN_SRC = $(shell find plugins/lsps-plugin/src -name "*.rs")
CLN_WSS_PROXY_PLUGIN_SRC = $(shell find plugins/wss-proxy-plugin/src -name "*.rs")
CLN_BIP353_PLUGIN_SRC = $(shell find plugins/bip353-plugin/src -name "*.rs")
$(RUST_TARGET_DIR)/cln-grpc: ${CLN_PLUGIN_SRC} ${CLN_GRPC_PLUGIN_SRC} $(MSGGEN_GENALL) $(MSGGEN_GEN_ALL)
cargo build ${CARGO_OPTS} --bin cln-grpc
$(RUST_TARGET_DIR)/clnrest: ${CLN_REST_PLUGIN_SRC}
cargo build ${CARGO_OPTS} --bin clnrest
$(RUST_TARGET_DIR)/cln-lsps-client: ${CLN_LSPS_PLUGIN_SRC}
cargo build ${CARGO_OPTS} --bin cln-lsps-client
$(RUST_TARGET_DIR)/cln-lsps-service: ${CLN_LSPS_PLUGIN_SRC}
cargo build ${CARGO_OPTS} --bin cln-lsps-service
$(RUST_TARGET_DIR)/wss-proxy: ${CLN_WSS_PROXY_PLUGIN_SRC}
cargo build ${CARGO_OPTS} --bin wss-proxy
$(RUST_TARGET_DIR)/cln-bip353: ${CLN_BIP353_PLUGIN_SRC}
cargo build ${CARGO_OPTS} --bin cln-bip353
ifneq ($(RUST),0)
build: fix rust parallel build race. plugins/Makefile has target/${RUST_PROFILE}/cln-grpc depend on the generated files via $(MSGGEN_GENALL), but cln-rpc/Makefile adds to that variable, so needs to be included first. Here's an example build error: ``` Combining schemas from /home/rusty/lightning-ltest/doc/schemas into /home/rusty/lightning-ltest/contrib/msggen/msggen/schema.json Created /home/rusty/lightning-ltest/contrib/msggen/msggen/schema.json from 2 files error: failed to run custom build command for `cln-grpc v0.3.0 (/home/rusty/lightning-ltest/cln-grpc)` Caused by: process didn't exit successfully: `/home/rusty/lightning-ltest/target/debug/build/cln-grpc-95489e3ba33c0ab3/build-script-build` (exit status: 101) --- stdout cargo:rerun-if-changed=proto/node.proto cargo:rerun-if-changed=proto --- stderr thread 'main' panicked at cln-grpc/build.rs:7:10: called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: node.proto:134:52: \"AskreneageResponse\" is not defined.\nnode.proto:135:23: \"GetroutesRequest\" is not defined.\nnode.proto:135:50: \"GetroutesResponse\" is not defined.\nnode.proto:136:32: \"AskrenedisablenodeRequest\" is not defined.\nnode.proto:136:68: \"AskrenedisablenodeResponse\" is not defined.\nnode.proto:137:34: \"AskreneinformchannelRequest\" is not defined.\nnode.proto:137:72: \"AskreneinformchannelResponse\" is not defined.\nnode.proto:138:34: \"AskrenecreatechannelRequest\" is not defined.\nnode.proto:138:72: \"AskrenecreatechannelResponse\" is not defined.\nnode.proto:139:34: \"AskreneupdatechannelRequest\" is not defined.\nnode.proto:139:72: \"AskreneupdatechannelResponse\" is not defined.\nnode.proto:140:32: \"AskrenebiaschannelRequest\" is not defined.\nnode.proto:140:68: \"AskrenebiaschannelResponse\" is not defined.\nnode.proto:141:37: \"AskrenelistreservationsRequest\" is not defined.\nnode.proto:141:78: \"AskrenelistreservationsResponse\" is not defined.\nnode.proto:142:32: \"InjectpaymentonionRequest\" is not defined.\nnode.proto:142:68: \"InjectpaymentonionResponse\" is not defined.\nnode.proto:143:18: \"XpayRequest\" is not defined.\nnode.proto:143:40: \"XpayResponse\" is not defined.\nnode.proto:145:33: \"StreamBlockAddedRequest\" is not defined.\nnode.proto:145:74: \"BlockAddedNotification\" is not defined.\nnode.proto:146:40: \"StreamChannelOpenFailedRequest\" is not defined.\nnode.proto:146:88: \"ChannelOpenFailedNotification\" is not defined.\nnode.proto:147:36: \"StreamChannelOpenedRequest\" is not defined.\nnode.proto:147:80: \"ChannelOpenedNotification\" is not defined.\nnode.proto:148:30: \"StreamConnectRequest\" is not defined.\nnode.proto:148:68: \"PeerConnectNotification\" is not defined.\nnode.proto:149:32: \"StreamCustomMsgRequest\" is not defined.\nnode.proto:149:72: \"CustomMsgNotification\" is not defined.\n" } note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace make: *** [plugins/Makefile:305: target/debug/cln-grpc] Error 101 make: *** Waiting for unfinished jobs.... ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-11 13:01:27 +10:30
include plugins/rest-plugin/Makefile
include plugins/wss-proxy-plugin/Makefile
DEFAULT_TARGETS += $(CLN_PLUGIN_EXAMPLES) plugins/cln-grpc plugins/clnrest plugins/cln-lsps-client plugins/cln-lsps-service plugins/wss-proxy plugins/cln-bip353
endif
clean: plugins-clean
plugins-clean:
$(RM) $(PLUGINS) $(CLN_PLUGIN_EXAMPLES)
$(RM) plugins/sql-schema_gen.h
include plugins/test/Makefile