62 lines
1.2 KiB
Makefile
62 lines
1.2 KiB
Makefile
VERSION := $(shell git rev-parse --short=8 HEAD)
|
|
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
|
BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
|
|
BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S')
|
|
BUILDUSER := $(shell whoami)
|
|
BUILDHOST := $(shell hostname -s)
|
|
BUILDARCH := $(shell uname -m)
|
|
|
|
FN := http
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
GOLDFLAGS += -X main.Version=$(VERSION)
|
|
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
|
|
|
|
# osx can't statically link apparently?!
|
|
ifeq ($(UNAME_S),Darwin)
|
|
GOFLAGS := -ldflags "$(GOLDFLAGS)"
|
|
endif
|
|
|
|
ifneq ($(UNAME_S),Darwin)
|
|
GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)"
|
|
endif
|
|
|
|
default: debug
|
|
|
|
commit: fmt lint
|
|
git commit -a
|
|
|
|
fmt:
|
|
goimports -l -w .
|
|
golangci-lint run --fix
|
|
|
|
lint:
|
|
golangci-lint run
|
|
sh -c 'test -z "$$(gofmt -l .)"'
|
|
|
|
debug: build
|
|
DEBUG=1 GOTRACEBACK=all ./$(FN)d
|
|
|
|
debugger:
|
|
cd cmd/$(FN)d && dlv debug main.go
|
|
|
|
run: build
|
|
./$(FN)d
|
|
|
|
clean:
|
|
-rm -f ./$(FN)d debug.log
|
|
|
|
build: ./$(FN)d
|
|
|
|
docker:
|
|
docker build .
|
|
|
|
get:
|
|
cd cmd/$(FN)d && go get -v
|
|
|
|
./$(FN)d: */*.go cmd/*/*.go get
|
|
cd cmd/$(FN)d && go build -o ../../$(FN)d $(GOFLAGS) .
|
|
|
|
.PHONY: build fmt test is_uncommitted docker dist hub upload-docker-image clean run rundebug default build-docker-image-dist
|