From 712a497bb7fcb7b3d39ab5aa99fdb4f646270edc Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Thu, 18 May 2023 14:14:14 +0200 Subject: [PATCH] build: improve makefile and requirements documentation (#17) --- Makefile | 50 ++++++++++++++++++++++++++++++++++++++++---------- README.md | 10 +++++----- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 6662f22..798d49b 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,48 @@ +ifneq (, $(shell which tput)) + GREEN := $(shell tput -Txterm setaf 2) + YELLOW := $(shell tput -Txterm setaf 3) + WHITE := $(shell tput -Txterm setaf 7) + CYAN := $(shell tput -Txterm setaf 6) + RESET := $(shell tput -Txterm sgr0) +endif + +# Git +GIT_VERSION ?= $(shell git describe --abbrev=6 --always --tags) +GIT_REMOTE_URL ?= $(shell git remote get-url origin | sed 's|git@github.com:|https://github.com/|') + +# Buf.build +BUF=buf + +ifeq (, $(shell which $(BUF))) +$(error "No buf command in $$PATH, see: https://buf.build/docs/installation/#install-the-buf-cli") +endif + + .DEFAULT_GOAL := all all: lint breaking +## Buf format: - @buf format -w + $(BUF) format -w -lint: - @echo "Running buf lint" - @buf lint +lint: ## Run buf.build lint + $(BUF) lint -breaking: - @echo "Running buf breaking changes checks" - @buf breaking --against="https://github.com/vacp2p/waku.git#branch=main" +breaking: ## Run buf.build breaking changes checks + $(BUF) breaking --against="${GIT_REMOTE_URL}#branch=main" -build: - @echo "Running buf compilation" - @buf build +build: ## Run buf.build compilation + $(BUF) build + +## Help: +help: ## Show this help + @echo '' + @echo 'Usage:' + @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' + @echo '' + @echo 'Targets:' + @awk 'BEGIN {FS = ":.*?## "} { \ + if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ + else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ + }' $(MAKEFILE_LIST) diff --git a/README.md b/README.md index 0095835..a4c9755 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ capabilities to it. [Learn more about Waku](https://waku.org/) -## Dependencies +## Requirements + +- GNU Make +- [Buf CLI](https://docs.buf.build/installation) +- [Protobuf Compiler (protoc)](https://grpc.io/docs/protoc-installation/) (Optional) -For mac: -```console -brew install bufbuild/buf/buf -```