Skip to content

Commit

Permalink
Makefile: add for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jun 4, 2015
1 parent 8c48ca9 commit 7388e2b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -6,6 +6,7 @@
# Folders
_obj
_test
build

# Architecture specific extensions/prefixes
*.[568vq]
Expand All @@ -22,4 +23,4 @@ _testmain.go
*.exe
*.test
*.prof
marathon-forwarder
marathon-forwarder
46 changes: 46 additions & 0 deletions Makefile
@@ -0,0 +1,46 @@
TEST?=./...
NAME = $(shell awk -F\" '/^const Name/ { print $$2 }' main.go)
VERSION = $(shell awk -F\" '/^const Version/ { print $$2 }' main.go)
DEPS = $(shell go list -f '{{range .TestImports}}{{.}} {{end}}' ./...)

all: deps build

deps:
go get -d -v ./...
echo $(DEPS) | xargs -n1 go get -d

updatedeps:
go get -u -v ./...
echo $(DEPS) | xargs -n1 go get -d

build: deps
@mkdir -p bin/
go build -o bin/$(NAME)

test: deps
go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4
go vet $(TEST)

xcompile: deps test
# go get github.com/mitchellh/gox
@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
3 changes: 3 additions & 0 deletions main.go
Expand Up @@ -6,6 +6,9 @@ import (
"net/http"
)

const Name = "marathon-consul"
const Version = "0.1.0"

func main() {
config := config.New()
apiConfig, err := config.Registry.Config()
Expand Down

0 comments on commit 7388e2b

Please sign in to comment.