Skip to content

Commit

Permalink
Makefile: add
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Mar 14, 2016
1 parent f762460 commit 9a204c9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ _testmain.go
*.prof

# Vendoring
vendor/
vendor/

# Builds
build
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9a204c9

Please sign in to comment.