diff --git a/Makefile b/Makefile index 86598e283..5f4dafe9c 100644 --- a/Makefile +++ b/Makefile @@ -380,6 +380,11 @@ check-hdr-include-order/%: % check-makefile: @if [ x"$(CCANDIR)/config.h `find $(CCANDIR)/ccan -name '*.h' | grep -v /test/ | $(SORT) | tr '\n' ' '`" != x"$(CCAN_HEADERS) " ]; then echo CCAN_HEADERS incorrect; exit 1; fi +# We exclude test files, which need to do weird include tricks! +SRC_TO_CHECK := $(filter-out $(ALL_TEST_PROGRAMS:=.c), $(ALL_NONGEN_SOURCES)) +check-src-includes: $(SRC_TO_CHECK:%=check-src-include-order/%) +check-hdr-includes: $(ALL_NONGEN_HEADERS:%=check-hdr-include-order/%) + # Experimental quotes quote the exact version. ifeq ($(EXPERIMENTAL_FEATURES),1) CHECK_BOLT_PREFIX=--prefix="BOLT-$(BOLTVERSION)" @@ -425,7 +430,7 @@ check-python: check-pyln-client check-pyln-testing PATH=$(PYLN_PATH) PYTHONPATH=$(PYTHONPATH) $(PYTEST) contrib/pyln-proto/tests/ -check-includes: +check-includes: check-src-includes check-hdr-includes @tools/check-includes.sh # cppcheck gets confused by list_for_each(head, i, list): thinks i is uninit. diff --git a/bitcoin/Makefile b/bitcoin/Makefile index 7d7767dd8..49e2fc806 100644 --- a/bitcoin/Makefile +++ b/bitcoin/Makefile @@ -38,20 +38,15 @@ BITCOIN_HEADERS := bitcoin/address.h \ bitcoin/tx_parts.h \ bitcoin/varint.h -check-source: $(BITCOIN_SRC:%=check-src-include-order/%) \ - $(BITCOIN_HEADERS:%=check-hdr-include-order/%) - # Bitcoin objects depends on bitcoin/ external/ and ccan $(BITCOIN_OBJS): $(CCAN_HEADERS) $(BITCOIN_HEADERS) $(EXTERNAL_HEADERS) -check-source-bolt: $(BITCOIN_SRC:%=bolt-check/%) $(BITCOIN_HEADERS:%=bolt-check/%) - check-makefile: check-bitcoin-makefile check-bitcoin-makefile: @if [ "`echo bitcoin/*.h`" != "$(BITCOIN_HEADERS)" ]; then echo BITCOIN_HEADERS incorrect; exit 1; fi -check-whitespace: $(BITCOIN_SRC:%=check-whitespace/%) $(BITCOIN_HEADERS:%=check-whitespace/%) check-whitespace/bitcoin/Makefile +check-whitespace: check-whitespace/bitcoin/Makefile clean: bitcoin-clean diff --git a/channeld/channeld.c b/channeld/channeld.c index 50f4b2602..2558c475d 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -47,9 +47,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -60,8 +60,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/channeld/full_channel_error.h b/channeld/full_channel_error.h index 899f4623d..49ca03a39 100644 --- a/channeld/full_channel_error.h +++ b/channeld/full_channel_error.h @@ -1,6 +1,7 @@ /* Error enums separated out for easy autogen of names*/ #ifndef LIGHTNING_CHANNELD_FULL_CHANNEL_ERROR_H #define LIGHTNING_CHANNELD_FULL_CHANNEL_ERROR_H +#include "config.h" enum channel_add_err { /* All OK! */ diff --git a/common/Makefile b/common/Makefile index ba316c743..1c13cc258 100644 --- a/common/Makefile +++ b/common/Makefile @@ -119,9 +119,6 @@ common/gossip_store.o: gossipd/gossip_store_wiregen.h check-source-bolt: $(COMMON_SRC_NOGEN:%=bolt-check/%) $(COMMON_HEADERS:%=bolt-check/%) check-whitespace: $(COMMON_SRC_NOGEN:%=check-whitespace/%) $(COMMON_HEADERS:%=check-whitespace/%) -check-source: $(COMMON_SRC_NOGEN:%=check-src-include-order/%) \ - $(COMMON_HEADERS_NOGEN:%=check-hdr-include-order/%) - clean: common-clean common-clean: diff --git a/devtools/blindedpath.c b/devtools/blindedpath.c index feb32ce91..627d1bb0d 100644 --- a/devtools/blindedpath.c +++ b/devtools/blindedpath.c @@ -15,8 +15,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/devtools/decodemsg.c b/devtools/decodemsg.c index 9e0650981..79bd38164 100644 --- a/devtools/decodemsg.c +++ b/devtools/decodemsg.c @@ -6,11 +6,11 @@ #include #include #if EXPERIMENTAL_FEATURES -#include -#include + #include + #include #else -#include -#include + #include + #include #endif int main(int argc, char *argv[]) diff --git a/devtools/dump-gossipstore.c b/devtools/dump-gossipstore.c index 0e7bcf8d0..312915a04 100644 --- a/devtools/dump-gossipstore.c +++ b/devtools/dump-gossipstore.c @@ -1,12 +1,12 @@ #include #include #include +#include #include #include #include -#include -#include #include +#include #include #include #include diff --git a/devtools/gossipwith.c b/devtools/gossipwith.c index 7d9bd3568..31ae79e5c 100644 --- a/devtools/gossipwith.c +++ b/devtools/gossipwith.c @@ -42,7 +42,7 @@ static struct io_plan *simple_close(struct io_conn *conn) return NULL; } -#include "../connectd/handshake.c" + #include "../connectd/handshake.c" /* This makes the handshake prototypes work. */ struct io_conn { diff --git a/devtools/mkcommit.c b/devtools/mkcommit.c index 022ee3b96..2b1eccaf0 100644 --- a/devtools/mkcommit.c +++ b/devtools/mkcommit.c @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/devtools/mkgossip.c b/devtools/mkgossip.c index 9420e79f7..63d7b51b8 100644 --- a/devtools/mkgossip.c +++ b/devtools/mkgossip.c @@ -21,8 +21,8 @@ #include #include #include -#include #include +#include static bool verbose = false; diff --git a/devtools/mkquery.c b/devtools/mkquery.c index 348f76186..d63632ba8 100644 --- a/devtools/mkquery.c +++ b/devtools/mkquery.c @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include static void usage(void) { diff --git a/lightningd/channel.c b/lightningd/channel.c index d57db4496..61dcb2e51 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -19,8 +19,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 4b034d194..7db3a2afb 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -4,9 +4,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/openingd/dualopend.c b/openingd/dualopend.c index a770a9e23..d991e17ff 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -42,8 +42,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/plugins/Makefile b/plugins/Makefile index 68731a7d8..46606d1ba 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -58,7 +58,7 @@ PLUGINS := \ # Make sure these depend on everything. ALL_C_SOURCES += $(PLUGIN_ALL_SRC) -ALL_C_HEADERS += +ALL_C_HEADERS += $(PLUGIN_ALL_HEADER) ALL_PROGRAMS += $(PLUGINS) PLUGIN_COMMON_OBJS := \ diff --git a/plugins/spender/main.c b/plugins/spender/main.c index 3d141aa0d..881dc22ea 100644 --- a/plugins/spender/main.c +++ b/plugins/spender/main.c @@ -1,8 +1,8 @@ #include #include -#include #include #include +#include /*~ The spender plugin contains various commands that handle * spending from the onchain wallet. */ diff --git a/tools/check-bolt.c b/tools/check-bolt.c index 37f7c6463..94e8f7479 100644 --- a/tools/check-bolt.c +++ b/tools/check-bolt.c @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include static bool verbose = false; diff --git a/tools/hsmtool.c b/tools/hsmtool.c index 80808ddf5..b795c3cab 100644 --- a/tools/hsmtool.c +++ b/tools/hsmtool.c @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/tools/test/Makefile b/tools/test/Makefile index b65e95d0b..50b57c942 100644 --- a/tools/test/Makefile +++ b/tools/test/Makefile @@ -14,14 +14,14 @@ TOOL_TEST_INCL_SRC := tools/test/enum.c TOOL_GEN_SRC := tools/test/test_gen.c tools/test/print_gen.c TOOL_GEN_OBJS := $(TOOL_GEN_SRC:.c=.o) TOOL_GEN_HEADER := tools/test/test_gen.h tools/test/print_gen.h -TOOL_TEST_SRC := $(wildcard tools/test/run-*.c) -TOOL_TEST_OBJS := $(TOOL_TEST_SRC:.c=.o) # Don't require update-mocks hack unless developer mode. ifeq ($(DEVELOPER),1) -TOOL_TEST_PROGRAMS := $(TOOL_TEST_OBJS:.o=) +TOOL_TEST_SRC := $(wildcard tools/test/run-*.c) else -TOOL_TEST_PROGRAMS := +TOOL_TEST_SRC := endif +TOOL_TEST_OBJS := $(TOOL_TEST_SRC:.c=.o) +TOOL_TEST_PROGRAMS := $(TOOL_TEST_OBJS:.o=) # Get dependencies correct ALL_C_SOURCES += $(TOOL_GEN_SRC) $(TOOL_TEST_SRC) diff --git a/wallet/db_postgres.c b/wallet/db_postgres.c index 6a0dbb431..60463638d 100644 --- a/wallet/db_postgres.c +++ b/wallet/db_postgres.c @@ -1,9 +1,9 @@ -#include #include "db_postgres_sqlgen.c" #include #include #include #include +#include #if HAVE_POSTGRES /* Indented in order not to trigger the inclusion order check */ diff --git a/wallet/db_sqlite3.c b/wallet/db_sqlite3.c index c6f9820cd..ba90e4d5f 100644 --- a/wallet/db_sqlite3.c +++ b/wallet/db_sqlite3.c @@ -1,11 +1,11 @@ -#include #include "db_sqlite3_sqlgen.c" #include #include #include +#include #if HAVE_SQLITE3 -#include + #include #if !HAVE_SQLITE3_EXPANDED_SQL /* Prior to sqlite3 v3.14, we have to use tracing to dump statements */