tools/check-includes.sh: test that c files include their .h files.

This is best-practice (to ensure prototypes match up), but there were a
few places we didn't (at least, directly).  Make it a requirement,
either of form "foo.h" or <dir/foo.h>.

The noise is the change to our print templates.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-09-16 14:20:02 +09:30
parent d970cc070e
commit 00a0d09340
47 changed files with 55 additions and 45 deletions

View File

@@ -56,6 +56,12 @@ for C_FILE in $(filter_suffix c); do
echo
EXIT_CODE=1
fi
H_FILE="${C_FILE%.c}.h"
H_BASE="$(basename "$H_FILE")"
if [ -f "$H_FILE" ] && ! grep -E '#include (<'"$H_FILE"'>|"'"$H_BASE"'")' "$C_FILE" > /dev/null; then
echo "${C_FILE} does not include $H_FILE" >& 2
EXIT_CODE=1
fi
done
exit ${EXIT_CODE}

View File

@@ -1,7 +1,7 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
#include "${options.header_filename}"
#include <${header_filename}>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>