diff options
author | Ben Burwell <ben@benburwell.com> | 2020-04-14 00:18:46 -0400 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2020-04-14 00:18:46 -0400 |
commit | ec87a295591eb762ffa214f9c0da9ed7c9485721 (patch) | |
tree | 78372eaeefb874dcd25604528fb42e65e1bea47e /Makefile | |
parent | 2ce3b86e0ff69538935db3149d1ed2f24aea09a3 (diff) |
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 56 |
1 files changed, 11 insertions, 45 deletions
@@ -1,54 +1,20 @@ -CASHIER_CMD := ./cmd/cashier -CASHIERD_CMD := ./cmd/cashierd -SRC_FILES = $(shell find * -type f -name '*.go' -not -path 'vendor/*' -not -name 'a_*-packr.go') +SOURCES=$(shell find . -type f -name '*.go') VERSION_PKG := github.com/nsheridan/cashier/lib.Version VERSION := $(shell git describe --tags --always --dirty) +IMAGE_NAME=benburwell/cashier -STATIC_LINKER_FLAGS ?= -linkmode external -extldflags -static -w -GOOS ?= $(shell go env GOOS) -GOARCH ?= $(shell go env GOARCH) -CGO_ENABLED ?= $(shell go env CGO_ENABLED) +all: cashier cashierd -all: test build +cashier: $(SOURCES) + go build -o $@ -ldflags="-X $(VERSION_PKG)=$(VERSION)" ./cmd/$@ -test: - go test -coverprofile=coverage.txt -covermode=count ./... - go install -race $(CASHIER_CMD) $(CASHIERD_CMD) +cashierd: $(SOURCES) + go build -o $@ -ldflags="-X $(VERSION_PKG)=$(VERSION)" ./cmd/$@ -lint: dep - go vet ./... - go list ./... |xargs -L1 golint -set_exit_status - gofmt -s -d -l -e $(SRC_FILES) - $(MAKE) generate - @[ -z "`git status --porcelain`" ] || (echo "unexpected files: `git status --porcelain`" && exit 1) - -build: cashier cashierd -install: install-cashierd install-cashier -cashier: cashier-bin -cashierd: cashierd-bin - -generate: - go generate ./... - -%-bin: - CGO_ENABLED=$(CGO_ENABLED) GOARCH=$(GOARCH) GOOS=$(GOOS) go build -ldflags="-X $(VERSION_PKG)=$(VERSION) $(STATIC_LINKER_FLAGS)" ./cmd/$* -install-%: generate - CGO_ENABLED=$(CGO_ENABLED) GOARCH=$(GOARCH) GOOS=$(GOOS) go install -ldflags="-X $(VERSION_PKG)=$(VERSION) $(STATIC_LINKER_FLAGS)" ./cmd/$* - -docker-image: - docker build -f Dockerfile . +.PHONY: docker +docker: + docker build -t "$(IMAGE_NAME)" . +.PHONY: clean clean: rm -f cashier cashierd - -# usage: make migration name=whatever -migration: - go run ./generate/migration/migration.go $(name) - -dep: - go get -u golang.org/x/lint/golint - -version: - @echo $(VERSION) - -.PHONY: all build dep generate test cashier cashierd clean migration |