2020-09-08 22:28:23 +00:00
|
|
|
VERSION := $(shell git rev-parse --short HEAD)
|
2020-09-09 02:57:28 +00:00
|
|
|
COMMIT := $(shell git log --pretty=format:"%H" -1)
|
2020-09-08 22:28:23 +00:00
|
|
|
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 := sco
|
|
|
|
IMAGENAME := sneak/$(FN)
|
|
|
|
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
|
|
|
|
GOLDFLAGS += -X main.Version=$(VERSION)
|
2020-09-09 02:57:28 +00:00
|
|
|
GOLDFLAGS += -X main.Commit=$(COMMIT)
|
2020-09-08 22:28:23 +00:00
|
|
|
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
|
|
|
|
|
2020-09-08 22:58:55 +00:00
|
|
|
default: fmt
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
go fmt ./...
|
2020-09-09 04:15:50 +00:00
|
|
|
goimports -l -w .
|
2020-09-08 22:29:37 +00:00
|
|
|
|
|
|
|
docker-build:
|
2020-09-08 22:58:55 +00:00
|
|
|
docker build -t $(IMAGENAME) .
|
|
|
|
|
2020-09-08 23:13:15 +00:00
|
|
|
run: go-get
|
|
|
|
cd cmd/$(FN) && go run
|
|
|
|
|
2020-09-08 22:58:55 +00:00
|
|
|
build: ./$(FN)
|
2020-09-08 22:28:23 +00:00
|
|
|
|
|
|
|
go-get:
|
|
|
|
cd cmd/$(FN) && go get -v
|
|
|
|
|
2020-09-09 04:29:42 +00:00
|
|
|
vet:
|
2020-09-09 04:21:13 +00:00
|
|
|
go vet ./...
|
2020-09-09 04:32:16 +00:00
|
|
|
bash -c 'test -z "$$(gofmt -l .)"'
|
2020-09-09 04:29:42 +00:00
|
|
|
|
|
|
|
./$(FN): */*.go cmd/*/*.go go-get vet
|
2020-09-09 01:38:55 +00:00
|
|
|
cd cmd/$(FN) && go build -o ../../$(FN) $(GOFLAGS) .
|