110

I prefer a help rule in the Makefile, like so: help: @grep -P &#...

 6 years ago
source link: https://news.ycombinator.com/item?id=11939200
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

I prefer a help rule in the Makefile, like so: help: @grep -P '^[a-zA-Z_-]+:.*?#...

I prefer a help rule in the Makefile, like so:
   help:
        @grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
Assuming that the trimmed Makefile read:
   build: ## Build the binary

   clean: ## Clean the binary and intermediate files

   distclean: clean ## Clean dependencies, intermediate files and binary

   deps: ## Install dependencies

   all: deps build ## Get dependencies and build binary

   release: distclean all ## distclean + all

Now issuing make help would display:
   all                  Get dependencies and build binary
   build                Build the binary
   clean                Clean the binary and intermediate files
   deps                 Install dependencies
   distclean            Clean dependencies, intermediate files and binary
   release              distclean + all

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK