PREFIX ?= $(shell pwd)/bin/ GO ?= go FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) GOHOSTOS ?= $(shell $(GO) env GOHOSTOS) GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH) BUILDTIME = ${shell TZ=Asia/Shanghai date +%Y-%m-%dT%H:%M:%S%z} GOBUILD = CGO_ENABLED=0 go build -trimpath export GOBIN=${PREFIX}/.bin # protoc v4.22.0 export PROTOC_VERSION=22.0 ifdef VERSION VERSION=${VERSION} else VERSION=$(shell git describe --tags --always --dirty="-dirty") endif ifdef GITCOMMIT GITCOMMIT=${GITCOMMIT} else GITCOMMIT=$(shell git rev-parse HEAD) endif # Go Reproducible Build ifdef REPRODUCIBLE_BUILD GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags=-buildid= BUILDTIME=0 endif LDFLAG=-ldflags "-X github.com/ifooth/apollo/pkg/version.Version=${VERSION} \ -X github.com/ifooth/apollo/pkg/version.GitCommit=${GITCOMMIT} \ -X github.com/ifooth/apollo/pkg/version.BuildTime=${BUILDTIME}" .PHONY: ini init: @echo Download protoc @mkdir -p ${PREFIX}/.bin @cd ${PREFIX}/.bin && \ rm -rf protoc-*.zip* && \ wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ unzip -o protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ mv -f bin/protoc . && \ rm -rf protoc-*.zip* readme.txt bin go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.15.2 go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.15.2 go install github.com/swaggo/swag/cmd/swag@v1.8.10 .PHONY: tidy tidy: @go mod tidy .PHONY: test test: @echo ">> test not support" .PHONY: benchmark benchmark: @echo ">> benchmark not support" .PHONY: swagger swagger: @swag init --outputTypes go,json -g pkg/apis/routes.go --exclude ./ @swag fmt -g pkg/apis/routes.go --exclude ./