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

Modified makefile help with colors and required targets #190

Open
kidpixo opened this issue Dec 16, 2019 · 3 comments
Open

Modified makefile help with colors and required targets #190

kidpixo opened this issue Dec 16, 2019 · 3 comments

Comments

@kidpixo
Copy link

kidpixo commented Dec 16, 2019

Hi,
first time user here, thanks for the repo!

I modified the makefile and the help target to have a simplified help and get the target+required target+ description

I have a fancy colors-help and a clean almost no dependencies help ( I found it useful in docker images).

My makefile uses this structure target : required_targets ## inline description , this syntax allow me to easily grep the targets and their description and I find it easy to read the makefile too.

.DEFAULT_GOAL := helpcol

install_package :  ## install the package from setup.py via setuptools
	python setup.py install --verbose
# cleaning
clean-pyc: ## remove all pyc, pyo and __pycache__
	find . -name '*.pyc' -exec rm -rf {} +
	find . -name '*.pyo' -exec rm -rf {} +
	find . -name '__pycache__'  -exec rm -rf {} +

help: ## Show help. Only lines with ": ##" will show up! This is a plain help, requires only grep+sed.
	@grep -h "## " $(MAKEFILE_LIST) | sed '/grep -h/d'

helpcol: ## Show help. Only lines with ": ##" will show up! This require columns. Shows: rules(green), targets(red), description.
	@(echo "$$(tput bold)Available rules>$$(tput sgr0;tput setaf 1)target$$(tput sgr0)>description"; \
	grep -h ":.*## " $(MAKEFILE_LIST) |\
		sed -E -e '/grep -h/d' -e 's/([^:]+)\s?:([^#]+)## (.*)/'$$(tput setaf 6)'\1>'$$(tput setaf 1)'\2'$$(tput sgr0)'>\3/' ) |\
	   	column -t -s '>' | sort

Example output :

Screen Shot 2019-12-16 at 17 02 56

@isms
Copy link
Contributor

isms commented Dec 17, 2019

Hi @kidpixo, thanks for commenting. Do you know if this works across platforms?

@kidpixo
Copy link
Author

kidpixo commented Dec 17, 2019

Hi @isms,
Good point, I have no idea. I use it in OSX and I can test a couple of Linux distro with docker, but I think it should just work, it calls a subshell and execute some commands there, like your original makefile.
I'll update this issue with some tests.

@kidpixo
Copy link
Author

kidpixo commented Dec 18, 2019

Tested with debian 9 (Stretch) and it works, installing from standard aptitude repository :

  • gnu make
  • column from bsdmainutils package.

Maybe a less fancy helpcol version without column -t -s '>' | sort could be better, but I purposely split in a base help and a fancy helpcol(or) targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants