build: improve makefile and requirements documentation (#17)

This commit is contained in:
Lorenzo Delgado 2023-05-18 14:14:14 +02:00 committed by GitHub
parent 25e892291f
commit 712a497bb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 15 deletions

View File

@ -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}<target>${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)

View File

@ -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
```