Skip to content

Commit

Permalink
build(make): moved make helpers to a separate file (#27)
Browse files Browse the repository at this point in the history
* build(ci): fixed build error if no changes in formulas
* build(make): moved make helpers to a separate file
  • Loading branch information
pamburus authored Oct 30, 2024
1 parent 70766d4 commit 21da902
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
with:
name: bottles_${{ matrix.os }}
path: '*.bottle.*'
if-no-files-found: error
if-no-files-found: warn
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@

## Print help
help:
@echo "$$(tput setaf 2)Usage$$(tput sgr0)";sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## /---/;td" -e"s/:.*//;G;s/\\n## /===/;s/\\n//g;p;}" ${MAKEFILE_LIST}|awk -F === -v n=$$(tput cols) -v i=4 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf" '$$(tput setaf 2)make$$(tput sgr0)' %s%s%s\t",a,$$1,z;m=split($$2,w,"---");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;}printf"%*s%s\n",-i," ",w[j];}}' | column -ts $$'\t'
.PHONY: help
# Common makefile helpers
include build/make/common.mk

# Variables
tapctl := bin/tapctl.py $(if $(verbose),--verbose)

## Synchronize formulas
.PHONY: sync
sync:
@$(tapctl) sync
.PHONY: sync

## Synchronize formulas with force
.PHONY: sync-force
sync-force:
@$(tapctl) sync --force
.PHONY: sync-force
12 changes: 12 additions & 0 deletions build/make/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Print help
.PHONY: help
help:
@ echo "$$(tput setaf 2)Usage$$(tput sgr0)"
@ sed -E '/^\.[a-z_]+:/Id' \
${MAKEFILE_LIST} \
| sed -n \
-e '/^## /{h;s/.*//;:d' \
-e 'H;n;s/^## /\t/;td' \
-e 's/:.*//;G;s/\n## /\t/;s/\n//g;p;}' \
| sed -E 's/^(.+)\t/ $(shell tput setaf 2)make$(shell tput sgr0) $(shell tput setaf 6)\1$(shell tput sgr0)\t/' \
| column -ts $$'\t'

0 comments on commit 21da902

Please sign in to comment.