From 318162fdf1ff86297afcce334f61d2d6ff5e3345 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 20 Oct 2024 13:56:08 -0600 Subject: Makefile: Use editorconfig for lint/format --- Makefile | 91 ++++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 25 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a89ec25..d0c5c78 100644 --- a/Makefile +++ b/Makefile @@ -50,30 +50,71 @@ generate-clean: rm -f -- $(generate/files) .PHONY: generate-clean -sources_sh = 3rd-party/linux-errno.txt.gen -sources_sh += libusb/include/libusb/tusb_helpers.h.gen -sources_py = lib9p/idl.gen -sources_py += lib9p/include/lib9p/linux-errno.h.gen +################################################################################ + +.PHONY: FORCE + +# List of sources, by type. +.sources.mk: $(if $(wildcard .git),FORCE) + git ls-files | grep -vFx $(foreach f,$(generate/files),-e $f) \ + | sed 's,^,$(CURDIR)/,' | xargs editorconfig \ + | sed -nE -e 's,\[$(CURDIR)/(.*)\],\1,p' -e 's/^_mode=//p' \ + | sed -E '{N;s/(.*)\n(.*)/sources_\2 += \1/;}' \ + | sort \ + >$@.tmp + if ! cmp -s $@.tmp $@; then mv $@.tmp $@; fi +-include .sources.mk +sources_all := $(foreach v,$(filter sources_%,$(.VARIABLES)),$($v)) + +# lint ############# lint: - shellcheck $(sources_sh) - mypy --strict --scripts-are-modules $(sources_py) - black --check $(sources_py) - isort --check $(sources_py) - r=0; find $$(git ls-files -- $(foreach f,$(generate/files),:!$f) :!cmd/*/static/*) -maxdepth 0 -type f | while read -r filename; do \ - grep -q 'Copyright (C) 2024 Luke T. Shumaker' $$filename || \ - { echo "$$filename is missing a copyright statement"; r=1; continue; }; \ - dscname=$$(sed -n '1,3{ /^#!/d; /^