From 9a204c9f684bdd5bf1fe30c03ca24ff60026c998 Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Mon, 14 Mar 2016 14:58:01 -0500 Subject: [PATCH] Makefile: add --- .gitignore | 5 ++++- Makefile | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 7bc7df1..ddd0368 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,7 @@ _testmain.go *.prof # Vendoring -vendor/ \ No newline at end of file +vendor/ + +# Builds +build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e5fa2b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +NAME = $(shell awk -F\" '/^const Name/ { print $$2 }' main.go) +VERSION = $(shell awk -F\" '/^const Version/ { print $$2 }' cmd/version.go) +TESTDEPS = $(shell go list -f '{{range .TestImports}}{{.}} {{end}}' $(shell glide novendor)) + +all: deps build + +deps: + glide install + echo $(TESTDEPS) | xargs -n1 go get + +updatedeps: + glide update + +build: deps + @mkdir -p bin/ + go build -o bin/$(NAME) + +test: deps + go test $(shell glide novendor) -timeout=30s -parallel=4 + go vet $(shell glide novendor) + +xcompile: deps test + @rm -rf build/ + @mkdir -p build + gox \ + -os="darwin" \ + -os="dragonfly" \ + -os="freebsd" \ + -os="linux" \ + -os="openbsd" \ + -os="solaris" \ + -os="windows" \ + -output="build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" + +package: xcompile + $(eval FILES := $(shell ls build)) + @mkdir -p build/tgz + for f in $(FILES); do \ + (cd $(shell pwd)/build && tar -zcvf tgz/$$f.tar.gz $$f); \ + echo $$f; \ + done + +.PHONY: all deps updatedeps build test xcompile package