woj-server/Makefile

46 lines
1.1 KiB
Makefile
Raw Normal View History

2022-09-07 23:34:37 +08:00
GO := go
2023-08-11 18:54:00 +08:00
PKG_BASE := $(shell head -n 1 go.mod | awk '{print $$2}')
BUILD_TIME := $(shell date -u '+%Y%m%d-%I%M%S')
VERSION := $(shell cat VERSION)
2024-01-06 21:31:10 +08:00
GIT_COMMIT := $(shell git rev-parse --short HEAD)
2023-08-11 18:54:00 +08:00
LDFLAGS += -X $(PKG_BASE)/cmd.BuildTime=$(BUILD_TIME)
LDFLAGS += -X $(PKG_BASE)/cmd.Version=$(VERSION)
LDFLAGS += -X $(PKG_BASE)/cmd.GitCommit=$(GIT_COMMIT)
2023-08-11 18:54:00 +08:00
LDFLAGS += -X $(PKG_BASE)/cmd.SentryDSN=$(shell cat dsn.txt)
2022-09-07 23:34:37 +08:00
LDFLAGS += -s -w
2024-03-13 20:03:12 +08:00
GOBUILD := $(GO) build
GOFLAGS := -ldflags '$(LDFLAGS)'
2022-09-17 09:23:36 +08:00
GOBIN := $(shell go env GOPATH)/bin
2022-09-07 23:34:37 +08:00
2024-01-06 21:03:30 +08:00
.PHONY: all build clean dep swagger fmt coverage test
2022-09-07 23:34:37 +08:00
default: all
all: clean build
2023-07-15 16:19:49 +08:00
build: swagger dep
2024-03-13 20:03:12 +08:00
$(GOBUILD) $(GOFLAGS) -o woj ./cmd/woj
clean:
2024-01-28 21:51:16 +08:00
rm -f woj coverage.out coverage.html
2022-09-07 23:34:37 +08:00
dep:
2023-07-15 16:19:49 +08:00
go mod download
2022-09-07 23:34:37 +08:00
swagger:
go install github.com/swaggo/swag/cmd/swag@latest
$(GOBIN)/swag init -g internal/web/router/api.go -d .,./internal/e,./internal/model --pdl 1 -o internal/web/router/docs
2022-09-17 09:23:36 +08:00
fmt:
go fmt ./...
2024-01-06 21:03:30 +08:00
coverage:
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
test:
go test -race ./...