Add help output to the Makefile

pull/1116/head^2
James Mills 2 weeks ago
parent 19ec0a97d3
commit 02f9cd7df2
Signed by: prologic
GPG Key ID: AC4C014F1440EBD6
  1. 75
      Makefile

@ -1,5 +1,5 @@
-include environ.inc
.PHONY: deps dev build install image release test clean tr tr-merge docs
.PHONY: help deps dev build install image release test clean tr tr-merge docs
export CGO_ENABLED=0
VERSION=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION")
@ -18,40 +18,64 @@ IMAGE := prologic/yarnd
TAG := dev
endif
all: preflight build
all: help
preflight:
help: ## Show this help message
@echo "Yarn.social - a Self-Hosted, Twitter™-like Decentralised microBlogging platform"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
preflight: ## Run preflight checks to ensure you have the right build tools
@./preflight.sh
deps:
deps: ## Install any dependencies required
@$(GOCMD) install github.com/tdewolff/minify/v2/cmd/minify@latest
@$(GOCMD) install github.com/nicksnyder/go-i18n/v2/goi18n@latest
@$(GOCMD) install github.com/astaxie/bat@latest
dev : DEBUG=1
dev : build
dev : build ## Build debug version of yarnc (cli) and yarnd (server)
@./yarnc -v
@./yarnd -D -O -R $(FLAGS)
cli:
cli: ## Build the yarnc command-line client
ifeq ($(DEBUG), 1)
@echo "Building in debug mode..."
@$(GOCMD) build -tags "netgo static_build" -installsuffix netgo \
-ldflags "\
-X $(shell go list).Version=$(VERSION) \
-X $(shell go list).Commit=$(COMMIT) \
-X $(shell go list).Build=$(BUILD)" \
./cmd/yarnc/
else
@$(GOCMD) build -tags "netgo static_build" -installsuffix netgo \
-ldflags "-w \
-X $(shell go list).Version=$(VERSION) \
-X $(shell go list).Commit=$(COMMIT) \
-X $(shell go list).Build=$(BUILD)" \
./cmd/yarnc/
endif
server: generate
server: generate ## Build the yarnd server
ifeq ($(DEBUG), 1)
@echo "Building in debug mode..."
@$(GOCMD) build $(FLAGS) -tags "netgo static_build" -installsuffix netgo \
-ldflags "\
-X $(shell go list).Version=$(VERSION) \
-X $(shell go list).Commit=$(COMMIT) \
-X $(shell go list).Build=$(BUILD)" \
./cmd/yarnd/...
else
@$(GOCMD) build $(FLAGS) -tags "netgo static_build" -installsuffix netgo \
-ldflags "-w \
-X $(shell go list).Version=$(VERSION) \
-X $(shell go list).Commit=$(COMMIT) \
-X $(shell go list).Build=$(BUILD)" \
./cmd/yarnd/...
endif
build: cli server
build: cli server ## Build the cli and the server
generate:
generate: ## Genereate any code required by the build
@if [ x"$(DEBUG)" = x"1" ]; then \
echo 'Running in debug mode...'; \
else \
@ -59,12 +83,12 @@ generate:
minify -b -o ./internal/theme/static/js/yarn.min.js ./internal/theme/static/js/[0-9]*-*.js; \
fi
install: build
install: build ## Install yarnc (cli) and yarnd (server) to $DESTDIR
@install -D -m 755 yarnd $(DESTDIR)/yarnd
@install -D -m 755 yarnc $(DESTDIR)/yarnc
ifeq ($(PUBLISH), 1)
image: generate
image: generate ## Build the Docker image
@docker buildx build \
--build-arg VERSION="$(VERSION)" \
--build-arg COMMIT="$(COMMIT)" \
@ -79,33 +103,28 @@ image: generate
-t $(IMAGE):$(TAG) .
endif
release: generate
release: generate ## Release a new version to Gitea
@./tools/release.sh
fmt:
fmt: ## Format sources fiels
@$(GOCMD) fmt ./...
test:
test: ## Run test suite
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race ./...
coverage:
coverage: ## Get test coverage report
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race -cover -coverprofile=coverage.out ./...
@$(GOCMD) tool cover -html=coverage.out
bench: bench-yarn.txt
go test -race -benchtime=1x -cpu 16 -benchmem -bench "^(Benchmark)" go.yarn.social/types
bench-yarn.txt:
curl -s https://twtxt.net/user/prologic/twtxt.txt > $@
clean:
@git clean -f -d -X
tr:
tr: ## Build translations (i18n)
@goi18n merge -outdir ./internal/langs ./internal/langs/active.*.toml
tr-merge:
@goi18n merge -outdir ./internal/langs ./internal/langs/active.*.toml ./internal/langs/translate.*.toml
docs:
docs: ## Build the docs site (dev.twtxt.net)
@cd docs; jekyll s
clean: ## Remove untracked files
@git clean -f -d -x
clean-all: ## Remove untracked and Git ignored files
@git clean -f -d -X

Loading…
Cancel
Save