Skip to content

Commit

Permalink
added MakeHelp (#21)
Browse files Browse the repository at this point in the history
* added MakeHelp

* stop gendocs
  • Loading branch information
Mararok authored Oct 3, 2018
1 parent 39a84dd commit b6e065b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ install:
script:
- vendor/phpunit/phpunit/phpunit --coverage-clover build/logs/clover.xml
after_success:
- bash .travis_docgen.sh
#- bash .travis_docgen.sh
35 changes: 35 additions & 0 deletions bin/MakeHelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.DEFAULT_GOAL := help
.PHONY: help

HELP_TARGET_MAX_CHAR_NUM ?= 30
SUBPROJECTS ?= <empty list>
BOLD := $(shell tput -Txterm bold)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)

.ONESHELL:
## Shows this help
help:
@echo '${BOLD}Info${RESET}'
@echo ' ${YELLOW}${INFO}${RESET}'
@echo '${BOLD}Usage:${RESET}'
@echo ' ${YELLOW}make${RESET} ${GREEN}${EXTRA_MAKE_ARGS} <target>${RESET}'
@echo '${BOLD}Subprojects:${RESET}'
@printf ' %s\n' $(foreach subproject,$(SUBPROJECTS),"${GREEN}${subproject}${RESET}")
@echo '${BOLD}Targets:${RESET}'
@awk '/^(.+):/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
is_subproject_target = match($$1, /^.+_subproject.+:/); \
if (is_subproject_target) { \
helpCommand = substr($$2, 0, index($$2, ":")-2)"<subproject>"; \
} else { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
} \
printf " ${YELLOW}%-$(HELP_TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)

0 comments on commit b6e065b

Please sign in to comment.