2017-05-08 19:33:37 +03:00
|
|
|
DOCKER_REGISTRY ?= docker.io
|
|
|
|
IMAGE_PREFIX ?= microsoft
|
2017-02-14 22:38:18 +03:00
|
|
|
IMAGE_TAG ?= canary
|
2017-06-02 04:32:49 +03:00
|
|
|
TARGETS = darwin/amd64 linux/amd64 linux/386 linux/arm windows/amd64
|
2017-01-18 11:10:11 +03:00
|
|
|
DIST_DIRS = find * -type d -exec
|
2017-04-21 18:19:58 +03:00
|
|
|
APP = draft
|
2018-12-09 20:13:26 +03:00
|
|
|
INSTALL_DIR := /usr/local/bin
|
|
|
|
PROJECT := draft
|
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
TARGET = $(PROJECT).exe
|
|
|
|
else
|
|
|
|
TARGET = $(PROJECT)
|
|
|
|
endif
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
# go option
|
|
|
|
GO ?= go
|
2017-03-13 22:18:29 +03:00
|
|
|
TAGS := kqueue
|
2017-01-18 11:10:11 +03:00
|
|
|
TESTS := .
|
|
|
|
TESTFLAGS :=
|
|
|
|
LDFLAGS :=
|
|
|
|
GOFLAGS :=
|
2018-05-30 00:01:08 +03:00
|
|
|
GOXFLAGS :=
|
2017-01-18 11:10:11 +03:00
|
|
|
BINDIR := $(CURDIR)/bin
|
2017-04-21 18:19:58 +03:00
|
|
|
BINARIES := draft
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
# Required for globs to work correctly
|
|
|
|
SHELL=/bin/bash
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: build
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
2017-05-08 19:33:37 +03:00
|
|
|
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/...
|
2017-01-18 11:10:11 +03:00
|
|
|
|
2018-03-15 22:34:41 +03:00
|
|
|
# usage: make clean build-cross dist APP=draft VERSION=v2.0.0-alpha.3
|
2017-01-18 11:10:11 +03:00
|
|
|
.PHONY: build-cross
|
|
|
|
build-cross: LDFLAGS += -extldflags "-static"
|
|
|
|
build-cross:
|
2018-05-30 00:01:08 +03:00
|
|
|
CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' $(GOXFLAGS) github.com/Azure/draft/cmd/$(APP)
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
.PHONY: dist
|
|
|
|
dist:
|
|
|
|
( \
|
|
|
|
cd _dist && \
|
|
|
|
$(DIST_DIRS) cp ../LICENSE {} \; && \
|
|
|
|
$(DIST_DIRS) cp ../README.md {} \; && \
|
2018-04-23 22:34:29 +03:00
|
|
|
$(DIST_DIRS) tar -zcf draft-${VERSION}-{}.tar.gz {} \; && \
|
|
|
|
$(DIST_DIRS) zip -r draft-${VERSION}-{}.zip {} \; \
|
2017-01-18 11:10:11 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
.PHONY: checksum
|
|
|
|
checksum:
|
2018-04-27 18:57:40 +03:00
|
|
|
for f in _dist/*.{gz,zip} ; do \
|
2017-01-18 11:10:11 +03:00
|
|
|
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
|
|
|
|
done
|
|
|
|
|
2017-02-14 22:38:18 +03:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
-rm bin/*
|
|
|
|
-rm rootfs/bin/*
|
2017-06-09 20:19:30 +03:00
|
|
|
-rm -rf _dist/
|
2017-02-14 22:38:18 +03:00
|
|
|
|
2018-12-09 20:13:26 +03:00
|
|
|
.PHONY: install
|
|
|
|
install:
|
|
|
|
install $(BINDIR)/$(TARGET) $(INSTALL_DIR)
|
|
|
|
|
2017-01-18 11:10:11 +03:00
|
|
|
.PHONY: test
|
|
|
|
test: TESTFLAGS += -race -v
|
2017-09-13 00:48:29 +03:00
|
|
|
test: test-lint test-unit
|
2017-06-06 21:39:04 +03:00
|
|
|
|
|
|
|
test-cover:
|
|
|
|
scripts/cover.sh
|
2017-03-17 06:23:59 +03:00
|
|
|
|
|
|
|
.PHONY: test-lint
|
|
|
|
test-lint:
|
2017-05-17 02:10:50 +03:00
|
|
|
scripts/lint.sh
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
.PHONY: test-unit
|
|
|
|
test-unit:
|
2017-10-05 00:52:20 +03:00
|
|
|
$(GO) test $(GOFLAGS) -cover -run $(TESTS) ./... $(TESTFLAGS)
|
2017-01-18 11:10:11 +03:00
|
|
|
|
2017-03-17 06:23:59 +03:00
|
|
|
HAS_GOMETALINTER := $(shell command -v gometalinter;)
|
2017-10-05 00:52:20 +03:00
|
|
|
HAS_DEP := $(shell command -v dep;)
|
2017-01-18 11:10:11 +03:00
|
|
|
HAS_GOX := $(shell command -v gox;)
|
|
|
|
HAS_GIT := $(shell command -v git;)
|
2017-06-03 18:31:59 +03:00
|
|
|
HAS_BINDATA := $(shell command -v go-bindata;)
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
.PHONY: bootstrap
|
|
|
|
bootstrap:
|
2017-03-17 06:23:59 +03:00
|
|
|
ifndef HAS_GOMETALINTER
|
|
|
|
go get -u github.com/alecthomas/gometalinter
|
|
|
|
gometalinter --install
|
|
|
|
endif
|
2017-10-05 00:52:20 +03:00
|
|
|
ifndef HAS_DEP
|
|
|
|
go get -u github.com/golang/dep/cmd/dep
|
2017-01-18 11:10:11 +03:00
|
|
|
endif
|
|
|
|
ifndef HAS_GOX
|
|
|
|
go get -u github.com/mitchellh/gox
|
|
|
|
endif
|
|
|
|
ifndef HAS_GIT
|
|
|
|
$(error You must install git)
|
2017-06-03 18:31:59 +03:00
|
|
|
endif
|
|
|
|
ifndef HAS_BINDATA
|
|
|
|
go get github.com/jteeuwen/go-bindata/...
|
2017-01-18 11:10:11 +03:00
|
|
|
endif
|
2017-10-05 00:52:20 +03:00
|
|
|
dep ensure -v
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
include versioning.mk
|