summaryrefslogtreecommitdiff
path: root/GNUmakefile
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-27 22:32:10 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-27 23:05:00 -0700
commit1c0769fdc316a5e2982d8909e713050af223c928 (patch)
treedc4291c162b2299ac9082dc325342b94cad5c75e /GNUmakefile
parent536877a84b6ba93c6c228bee27b2c82691c3d733 (diff)
GNUmakefile: Pull lint/c, lint/all, and lint/unknown out into separate shell scripts
Diffstat (limited to 'GNUmakefile')
-rw-r--r--GNUmakefile46
1 files changed, 6 insertions, 40 deletions
diff --git a/GNUmakefile b/GNUmakefile
index ab28ede..3abe629 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -86,8 +86,6 @@ $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/check)): build/%
-include build-aux/sources.mk
sources_all := $(foreach v,$(filter sources_%,$(.VARIABLES)),$($v))
-get_dscname = sed -n '1,3{ /^\#!/d; /^<!--$$/d; /-\*- .* -\*-/d; s,[/*\# ]*,,; s/ - .*//;p; q; }'
-
build-aux/venv: build-aux/requirements.txt
python3 -m venv $@
$@/bin/pip install -r $<
@@ -102,46 +100,14 @@ lint/python3: lint/%: build-aux/venv
./build-aux/venv/bin/mypy --strict --scripts-are-modules $(sources_$*)
./build-aux/venv/bin/black --check $(sources_$*)
./build-aux/venv/bin/isort --check $(sources_$*)
-lint/c: lint/%:
- @for filename in $(filter %.h,$(sources_$*)); do \
- dscname=$$($(get_dscname) $$filename); \
- guard=$${dscname//'/'/'_'}; \
- guard=$${guard//'.'/'_'}; \
- guard="_$${guard^^}_"; \
- if ! { grep -Fxq "#ifndef $${guard}" "$$filename" && \
- grep -Fxq "#define $${guard}" "$$filename" && \
- grep -Fxq "#endif /* $${guard} */" "$$filename"; }; then \
- echo "$$filename does not have $${guard} guard"; r=1; \
- fi; \
- done; exit $$r
+lint/c: lint/%: build-aux/lint-h build-aux/get-dscname
+ ./build-aux/lint-h $(filter %.h,$(sources_$*))
lint/make lint/cmake lint/gitignore lint/ini lint/9p lint/markdown: lint/%:
@:
-lint/unknown: lint/%:
- @printf "%s: cannot lint unknown file type\n" $(sources_$*) >&2
-lint/all: lint/%:
- $(eval export sources_$*)
- @find $$(printf '%s\n' $${sources_$*} | grep -vE '^lib9p/tests/[^/]+/static/') \
- -maxdepth 0 -type f | \
- { r=0; while read -r filename; do \
- if ! grep -E -q 'Copyright \(C\) 202[4-9]((-|, )202[5-9])* Luke T. Shumaker' $$filename; then \
- echo "$$filename is missing a copyright statement"; r=1; \
- fi; \
- if ! grep -q ' SPDX-License-Identifier[:] ' $$filename; then \
- echo "$$filename is missing an SPDX-License-Identifier"; r=1; \
- fi; \
- dscname_act=$$($(get_dscname) $$filename); \
- dscname_exp=$$(echo "$$filename" | sed \
- -e 's,.*/config/,,' \
- -e 's,.*/config\.h$$,config.h,' \
- -e 's,.*include/,,' \
- -e 's/\.wip$$//'); \
- if [ "$$dscname_act" != "$$dscname_exp" ] && [ "cmd/$$dscname_act" != "$$dscname_exp" ]; then \
- echo "$$filename self-identifies as $$dscname_act (expected $$dscname_exp)"; r=1; \
- fi; \
- if grep -n --color=auto "$$(printf '\\S\t')" $$filename; then \
- echo "$$filename uses tabs for alignment"; r=1; \
- fi; \
- done; exit $$r; }
+lint/unknown: lint/%: build-aux/lint-unknown
+ ./build-aux/lint-unknown $(sources_$*)
+lint/all: lint/%: build-aux/lint-generic build-aux/get-dscname
+ ./build-aux/lint-generic $$(printf '%s\n' $(sources_$*) | grep -vE '^lib9p/tests/[^/]+/static/')
.PHONY: lint lint/%
# `format` #########