Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help target to the makefile #10608

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,55 @@ DOCTEST := cabal doctest --allow-newer=False
# default rules

.PHONY: all
all : exe lib
all: help-banner exe lib ## Build the Cabal libraries and cabal-install executables.

.PHONY: lib
lib :
lib: ## Builds the Cabal libraries.
$(CABALBUILD) Cabal:libs

.PHONY: exe
exe :
exe: ## Builds the cabal-install executables.
$(CABALBUILD) cabal-install:exes

.PHONY: init
init: ## Set up git hooks and ignored revisions
init: ## Set up git hooks and ignored revisions.
@git config core.hooksPath .githooks
## TODO

.PHONY: style
style: ## Run the code styler
style: ## Run the code styler.
@fourmolu -q -i Cabal Cabal-syntax cabal-install cabal-validate

.PHONY: style-modified
style-modified: ## Run the code styler on modified files
style-modified: ## Run the code styler on modified files.
@git ls-files --modified Cabal Cabal-syntax cabal-install cabal-validate \
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}

.PHONY: style-commit
style-commit: ## Run the code styler on the previous commit
style-commit: ## Run the code styler on the previous commit.
@git diff --name-only HEAD $(COMMIT) Cabal Cabal-syntax cabal-install cabal-validate \
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}

.PHONY: whitespace
whitespace: ## Run fix-whitespace in check mode
whitespace: ## Run fix-whitespace in check mode.
fix-whitespace --check --verbose

.PHONY: fix-whitespace
fix-whitespace: ## Run fix-whitespace in fix mode
fix-whitespace: ## Run fix-whitespace in fix mode.
fix-whitespace --verbose

.PHONY: lint
lint: ## Run HLint
lint: ## Run HLint.
hlint -j .

.PHONY: lint-json
lint-json: ## Run HLint in JSON mode
lint-json: ## Run HLint in JSON mode.
hlint -j --json -- .

# local checks

.PHONY: checks
checks: whitespace users-guide-typos markdown-typos style lint-json
checks: whitespace users-guide-typos markdown-typos style lint-json ## Run all local checks; whitespace, typos, style, and lint.

# source generation: SPDX

Expand Down Expand Up @@ -116,15 +116,15 @@ analyse-imports :
# ghcid

.PHONY: ghcid-lib
ghcid-lib :
ghcid-lib: ## Run ghcid for the Cabal library.
ghcid -c 'cabal repl Cabal'

.PHONY: ghcid-cli
ghcid-cli :
ghcid-cli: ## Run ghcid for the cabal-install executable.
ghcid -c 'cabal repl cabal-install'

.PHONY: doctest
doctest :
doctest: ## Run doctests.
cd Cabal-syntax && $(DOCTEST)
cd Cabal-described && $(DOCTEST)
cd Cabal && $(DOCTEST)
Expand All @@ -137,7 +137,7 @@ doctest-cli :
doctest -D__DOCTEST__ --fast cabal-install/src cabal-install-solver/src cabal-install-solver/src-assertion

.PHONY: doctest-install
doctest-install:
doctest-install: ## Install doctest tool needed for running doctests.
cabal install doctest --overwrite-policy=always --ignore-project --flag cabal-doctest

# tests
Expand Down Expand Up @@ -234,7 +234,7 @@ validate-via-docker-old:

# tags
.PHONY : tags
tags :
tags: ## Generate editor tags, vim ctags and emacs etags.
hasktags -b Cabal-syntax/src Cabal/src Cabal-described/src cabal-install/src cabal-testsuite/src

# bootstrapping
Expand All @@ -256,11 +256,11 @@ bootstrap-jsons: $(BOOTSTRAP_GHC_VERSIONS:%=bootstrap-json-%)
##############################################################################

.PHONY: users-guide
users-guide:
users-guide: ## Build the users guide.
$(MAKE) -C doc users-guide

.PHONY: users-guide-requirements
users-guide-requirements:
users-guide-requirements: ## Install the requirements for building the users guide.
$(MAKE) -C doc users-guide-requirements

ifeq ($(shell uname), Darwin)
Expand All @@ -269,6 +269,18 @@ else
PROCS := $(shell nproc)
endif

PHONY: help
help: ## Show the commented targets.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

PHONY: help-banner
help-banner: ## Show the help banner.
@echo "===================================================================="
@echo "§ all make with no arguments also shows this banner"
@echo "§ help make help will list targets with descriptions"
@echo "===================================================================="

.PHONY: typos-install
typos-install: ## Install typos-cli for typos target using cargo
cargo install typos-cli
Expand Down
Loading