Skip to content

Instantly share code, notes, and snippets.

@iemelyanov
Forked from divan/Makefile
Created October 3, 2017 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iemelyanov/34ed4039477c449e95b7d493539fa279 to your computer and use it in GitHub Desktop.
Save iemelyanov/34ed4039477c449e95b7d493539fa279 to your computer and use it in GitHub Desktop.
Make help
.PHONY: help
# This is a code for automatic help generator.
# It supports ANSI colors and categories.
# To add new item into help output, simply add comments
# starting with '##'. To add category, use @category.
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "Usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; \
}
help: ##@other Show this help
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
# Main targets
cmd: ##@build Build main command
true
lib: ##@build Build library
true
android: ##@cross-compile Build for Android
true
ios: ##@cross-compile Build for iOS
true
ios-sim: ##@cross-compile Build for iOS simulator
true
lint: ##@other Run meta linter on code
true
test: ##@other Run tests
true
generate: ##@other Regenerate assets
true
ensure: ##@other Ensure dependencies
true
docker: ##@deploy Build docker container
true
push: ##@deploy Push docker container
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment