45 lines
1.1 KiB
Makefile
45 lines
1.1 KiB
Makefile
.PHONY: all
|
|
|
|
BIN_NAME := rpi-relay
|
|
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
|
|
ifneq ($(DRONE_TAG),)
|
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
|
else
|
|
VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
|
|
endif
|
|
|
|
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
current_dir := $(dir $(mkfile_path))
|
|
|
|
LDFLAGS ?= -X rpirelay/internal/version.Version=$(VERSION) -X rpirelay/internal/version.BuildDate=$(BUILD_DATE)
|
|
|
|
all: clean generate-spec unpack-swagger build
|
|
dev: clean generate-spec unpack-swagger
|
|
|
|
build:
|
|
go build -o $(BIN_NAME) -ldflags "-s -w $(LDFLAGS)" ./cmd/server/main.go
|
|
|
|
clean:
|
|
rm -rf $(BIN_NAME)
|
|
rm -rf *.so
|
|
go clean
|
|
|
|
generate-spec:
|
|
swagger generate spec -m --compact -o spec.json
|
|
|
|
test-code: clean generate-spec unpack-swagger
|
|
go test -cover=true ./...
|
|
|
|
test-code-coverage: clean generate-spec unpack-swagger
|
|
go test -cover -coverprofile cover.out ./...
|
|
|
|
show-coverage:
|
|
go tool cover -html=cover.out
|
|
|
|
install-dep:
|
|
go get github.com/go-swagger/go-swagger/...
|
|
|
|
unpack-swagger:
|
|
mkdir -p public/swagger && tar xvf swagger.tar -C public/swagger
|