2022-09-03 19:22:35 +01:00
|
|
|
SHELL := bash
|
|
|
|
|
2019-11-16 21:59:32 -08:00
|
|
|
VERSION ?=
|
|
|
|
CMD ?=
|
|
|
|
|
2019-07-10 19:12:20 -07:00
|
|
|
EMACS ?= emacs
|
|
|
|
|
2022-01-05 15:35:12 -08:00
|
|
|
TAG ?= latest
|
|
|
|
|
2019-07-10 19:12:20 -07:00
|
|
|
# The order is important for compilation.
|
2023-10-17 21:20:38 +01:00
|
|
|
for_compile := \
|
2023-11-17 16:17:08 -08:00
|
|
|
apheleia-utils.el \
|
2023-11-04 12:18:02 -07:00
|
|
|
apheleia-formatter-context.el \
|
2023-10-17 21:20:38 +01:00
|
|
|
apheleia-log.el \
|
2023-11-04 12:18:02 -07:00
|
|
|
apheleia-formatters.el \
|
2023-10-17 21:20:38 +01:00
|
|
|
apheleia-rcs.el \
|
|
|
|
apheleia.el
|
2019-07-10 19:12:20 -07:00
|
|
|
for_checkdoc := *.el
|
2022-09-03 19:22:35 +01:00
|
|
|
for_checkindent := *.el
|
2019-07-10 19:12:20 -07:00
|
|
|
|
2019-11-16 21:59:32 -08:00
|
|
|
.PHONY: help
|
|
|
|
help: ## Show this message
|
|
|
|
@echo "usage:" >&2
|
|
|
|
@grep -h "[#]# " $(MAKEFILE_LIST) | \
|
|
|
|
sed 's/^/ make /' | \
|
|
|
|
sed 's/:[^#]*[#]# /|/' | \
|
|
|
|
sed 's/%/LANG/' | \
|
|
|
|
column -t -s'|' >&2
|
|
|
|
|
|
|
|
.PHONY: lint
|
2022-09-03 19:22:35 +01:00
|
|
|
lint: compile checkdoc longlines checkindent fmt-lint ## Run all fast linters
|
2019-07-10 19:12:20 -07:00
|
|
|
|
|
|
|
.PHONY: compile
|
2019-07-10 22:06:18 -07:00
|
|
|
compile: ## Check for byte-compiler errors
|
2019-07-10 19:12:20 -07:00
|
|
|
@for file in $(for_compile); do \
|
|
|
|
echo "[compile] $$file" ;\
|
2019-07-10 22:17:26 -07:00
|
|
|
rm -f "$${file}c" ;\
|
2019-07-10 19:12:20 -07:00
|
|
|
$(EMACS) -Q --batch -L . -f batch-byte-compile $$file 2>&1 \
|
|
|
|
| grep -v "^Wrote" \
|
|
|
|
| grep . && exit 1 || true ;\
|
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: checkdoc
|
2019-07-10 22:06:18 -07:00
|
|
|
checkdoc: ## Check for missing or poorly formatted docstrings
|
2019-07-10 19:12:20 -07:00
|
|
|
@for file in $(for_checkdoc); do \
|
|
|
|
echo "[checkdoc] $$file" ;\
|
|
|
|
$(EMACS) -Q --batch \
|
|
|
|
--eval "(or (fboundp 'checkdoc-file) (kill-emacs))" \
|
|
|
|
--eval "(setq sentence-end-double-space nil)" \
|
|
|
|
--eval "(checkdoc-file \"$$file\")" 2>&1 \
|
|
|
|
| grep . && exit 1 || true ;\
|
|
|
|
done
|
|
|
|
|
2022-09-03 19:22:35 +01:00
|
|
|
.PHONY: checkindent
|
|
|
|
checkindent: ## Ensure that indentation is correct
|
|
|
|
@tmpdir="$$(mktemp -d)"; for file in $(for_checkindent); do \
|
|
|
|
echo "[checkindent] $$file" >&2; \
|
|
|
|
emacs -Q --batch \
|
|
|
|
-l scripts/apheleia-indent.el \
|
|
|
|
--eval "(setq inhibit-message t)" \
|
2023-03-12 10:22:36 +00:00
|
|
|
--eval "(setq load-path \
|
|
|
|
(append (list default-directory) load-path))" \
|
2022-09-03 19:22:35 +01:00
|
|
|
--eval "(load (expand-file-name \"apheleia.el\") nil t)" \
|
|
|
|
--eval "(find-file \"$$file\")" \
|
|
|
|
--eval "(indent-region (point-min) (point-max))" \
|
|
|
|
--eval "(write-file \"$$tmpdir/$$file\")"; \
|
|
|
|
(diff <(cat "$$file" | nl -v1 -ba | \
|
|
|
|
sed "s/\t/: /" | sed "s/^ */$$file:/") \
|
|
|
|
<(cat "$$tmpdir/$$file" | nl -v1 -ba | \
|
|
|
|
sed "s/\t/: /" | sed "s/^ */$$file:/") ) \
|
|
|
|
| grep -F ">" | grep -o "[a-z].*" | grep . && exit 1 || true; \
|
|
|
|
done
|
|
|
|
|
2019-07-10 19:12:20 -07:00
|
|
|
.PHONY: longlines
|
2022-01-03 20:07:29 -08:00
|
|
|
longlines: ## Check for long lines
|
|
|
|
@scripts/check-line-length.bash
|
2019-07-10 19:12:20 -07:00
|
|
|
|
|
|
|
.PHONY: clean
|
2019-07-10 22:06:18 -07:00
|
|
|
clean: ## Remove build artifacts
|
2019-07-10 19:12:20 -07:00
|
|
|
@echo "[clean]" *.elc
|
|
|
|
@rm -f *.elc
|
2019-07-10 22:06:18 -07:00
|
|
|
|
|
|
|
.PHONY: docker
|
2019-07-10 22:50:01 -07:00
|
|
|
docker: ## Start a Docker shell; e.g. make docker VERSION=25.3
|
2019-11-16 22:05:28 -08:00
|
|
|
@scripts/docker.bash "$(VERSION)" "$(CMD)"
|
2022-01-05 15:35:12 -08:00
|
|
|
|
|
|
|
.PHONY: fmt-build # env vars: FORMATTERS, TAG
|
|
|
|
fmt-build: ## Build a Docker image with formatters installed
|
2023-10-06 22:01:38 -07:00
|
|
|
@COMMON=0 test/formatters/build-image.bash
|
|
|
|
|
|
|
|
.PHONY: fmt-build-common # env var: TAG
|
|
|
|
fmt-build-common: ## Build a Docker image with just the common base
|
|
|
|
@COMMON=1 test/formatters/build-image.bash
|
2022-01-05 15:35:12 -08:00
|
|
|
|
|
|
|
.PHONY: fmt-docker # env var: TAG
|
|
|
|
fmt-docker: ## Start a Docker shell for testing formatters
|
|
|
|
@scripts/docker-run.bash -e FORMATTERS "apheleia-formatters:$(TAG)" "$(CMD)"
|
|
|
|
|
|
|
|
.PHONY: fmt-lint
|
|
|
|
fmt-lint: ## Do basic linting for formatter configuration
|
|
|
|
@test/formatters/run-func.bash apheleia-ft-lint
|
|
|
|
|
|
|
|
.PHONY: fmt-check
|
|
|
|
fmt-changed: ## Get list of changed formatters on this PR
|
|
|
|
@test/formatters/run-func.bash apheleia-ft-changed
|
|
|
|
|
|
|
|
.PHONY: fmt-test # env var: FORMATTERS
|
|
|
|
fmt-test: ## Actually run formatter tests
|
|
|
|
@test/formatters/run-func.bash apheleia-ft-test
|