mirror of
https://github.com/warmbly/warmbly.git
synced 2026-09-08 00:02:09 +00:00
41 lines
1.6 KiB
Makefile
41 lines
1.6 KiB
Makefile
GO_BIN := $(shell go env GOBIN)
|
|
ifeq ($(strip $(GO_BIN)),)
|
|
GO_BIN := $(shell go env GOPATH)/bin
|
|
endif
|
|
|
|
export PATH := $(GO_BIN):$(PATH)
|
|
|
|
GOLANGCI_LINT_VERSION ?= v1.64.8
|
|
PROTOC_GEN_GO_VERSION ?= v1.36.11
|
|
PROTOC_GEN_GO_GRPC_VERSION ?= v1.6.1
|
|
|
|
PROTO_DIR := internal/tasks/proto
|
|
PROTO_GEN_FILES := $(PROTO_DIR)/tasks.pb.go
|
|
|
|
.PHONY: setup-tools lint proto check-proto
|
|
|
|
setup-tools:
|
|
@echo "Installing required Go tools into $(GO_BIN)"
|
|
GOBIN=$(GO_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
|
GOBIN=$(GO_BIN) go install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GEN_GO_VERSION)
|
|
GOBIN=$(GO_BIN) go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_GEN_GO_GRPC_VERSION)
|
|
|
|
lint:
|
|
golangci-lint run --timeout=5m
|
|
|
|
proto:
|
|
@command -v protoc >/dev/null || (echo "protoc not found in PATH"; exit 1)
|
|
@command -v protoc-gen-go >/dev/null || (echo "protoc-gen-go not found in PATH; run 'make setup-tools'"; exit 1)
|
|
protoc --proto_path=$(PROTO_DIR) --go_out=$(PROTO_DIR) --go_opt=paths=source_relative $(PROTO_DIR)/*.proto
|
|
|
|
check-proto:
|
|
@tmpdir=$$(mktemp -d); \
|
|
trap 'rm -rf "$$tmpdir"' EXIT; \
|
|
command -v protoc >/dev/null || { echo "protoc not found in PATH"; exit 1; }; \
|
|
command -v protoc-gen-go >/dev/null || { echo "protoc-gen-go not found in PATH; run 'make setup-tools'"; exit 1; }; \
|
|
protoc --proto_path=$(PROTO_DIR) --go_out="$$tmpdir" --go_opt=paths=source_relative $(PROTO_DIR)/*.proto; \
|
|
if ! cmp -s $(PROTO_GEN_FILES) "$$tmpdir/tasks.pb.go"; then \
|
|
echo "Generated protobuf files are out of date. Run 'make proto' and commit the changes."; \
|
|
exit 1; \
|
|
fi
|