draft-classic/Makefile

111 строки
2.6 KiB
Makefile
Исходник Обычный вид История

2017-01-20 22:06:37 +03:00
DOCKER_REGISTRY ?= quay.io
2017-01-23 22:09:48 +03:00
IMAGE_PREFIX ?= deis
2017-01-20 22:06:37 +03:00
SHORT_NAME ?= prowd
2017-01-18 11:10:11 +03:00
TARGETS = darwin/amd64 linux/amd64 linux/386 linux/arm windows/amd64
DIST_DIRS = find * -type d -exec
APP = prow
# go option
GO ?= go
PKG := $(shell glide novendor)
TAGS :=
TESTS := .
TESTFLAGS :=
LDFLAGS :=
GOFLAGS :=
BINDIR := $(CURDIR)/bin
BINARIES := prow
# Required for globs to work correctly
SHELL=/bin/bash
.PHONY: all
all: build
.PHONY: build
build:
2017-01-23 22:09:48 +03:00
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/deis/prow/cmd/...
2017-01-18 11:10:11 +03:00
2017-01-20 22:06:37 +03:00
# usage: make clean build-cross dist APP=prow|prowd VERSION=v2.0.0-alpha.3
2017-01-18 11:10:11 +03:00
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross:
2017-01-23 22:09:48 +03:00
CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/deis/prow/cmd/$(APP)
2017-01-18 11:10:11 +03:00
.PHONY: dist
dist:
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
2017-01-20 22:06:37 +03:00
$(DIST_DIRS) tar -zcf prow-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r prow-${VERSION}-{}.zip {} \; && \
2017-01-18 11:10:11 +03:00
mv $(APP)-${VERSION}-*.* .. \
)
.PHONY: checksum
checksum:
for f in _dist/*.{gz,zip} ; do \
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
done
2017-01-20 22:06:37 +03:00
.PHONY: check-docker
check-docker:
@if [ -z $$(which docker) ]; then \
echo "Missing \`docker\` client which is required for development"; \
exit 2; \
fi
.PHONY: docker-binary
docker-binary: BINDIR = ./rootfs/bin
docker-binary: GOFLAGS += -a -installsuffix cgo
docker-binary:
2017-01-23 22:09:48 +03:00
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o $(BINDIR)/prowd $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/deis/prow/cmd/prowd
2017-01-20 22:06:37 +03:00
.PHONY: docker-build
docker-build: check-docker docker-binary compress-binary
2017-01-20 23:19:13 +03:00
docker build --rm -t ${IMAGE} .
2017-01-20 22:06:37 +03:00
docker tag ${IMAGE} ${MUTABLE_IMAGE}
.PHONY: compress-binary
compress-binary: BINDIR = ./rootfs/bin
compress-binary:
@if [ -z $$(which upx) ]; then \
echo "Missing \`upx\` tool to compress binaries"; \
else \
upx --quiet ${BINDIR}/prowd; \
fi
2017-01-18 11:10:11 +03:00
.PHONY: test
test: build
test: TESTFLAGS += -race -v
test: test-unit
.PHONY: test-unit
test-unit:
$(GO) test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)
2017-02-10 01:27:59 +03:00
.PHONY: test-e2e
test-e2e:
./tests/e2e.sh
2017-01-18 11:10:11 +03:00
HAS_GLIDE := $(shell command -v glide;)
HAS_GOX := $(shell command -v gox;)
HAS_GIT := $(shell command -v git;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_GLIDE
go get -u github.com/Masterminds/glide
endif
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
ifndef HAS_GIT
$(error You must install git)
endif
glide install --strip-vendor
include versioning.mk