Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
dim committed Feb 9, 2017
1 parent 6a9af13 commit 3febc3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pkg/
vendor/
.glide/
bin/
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
SRC=$(shell find . -name '*.go' -not -path '*vendor*')
PKG=$(shell glide nv)
VERSION=0.1.2

TARGET_PKG=$(patsubst cmd/%/main.go,bin/%,$(wildcard cmd/*/main.go))
TARGET_OS=linux darwin
TARGET_ARCH=amd64 386
TARGETS=$(foreach pkg,$(TARGET_PKG),$(foreach os,$(TARGET_OS),$(foreach arch,$(TARGET_ARCH),$(pkg)-$(os)-$(arch))))
ARCHIVES=$(foreach t,$(TARGETS),$(t).zip)

default: vet test

Expand All @@ -9,20 +15,18 @@ test:
vet:
go vet $(PKG)

pkg-deps:
go get github.com/mitchellh/gox

pkg: pkg-deps \
pkg/release/grpc-health_${VERSION}_linux_amd64.zip
build: $(TARGETS)
dist: $(ARCHIVES)

.PHONY: test vet errcheck deps pkg
.PHONY: test vet errcheck deps build dist

# ---------------------------------------------------------------------

pkg/build/linux/amd64/grpc-health: cmd/grpc-health/main.go
mkdir -p $(dir $@)
gox -osarch="linux/amd64" -output $@ ./$(dir $<)
bin/grpc-health-%.zip: bin/grpc-health-%
zip -j $@ $<

pkg/release/grpc-health_${VERSION}_linux_amd64.zip: pkg/build/linux/amd64/grpc-health
mkdir -p $(dir $@)
zip -9 -j $@ $<
bin/grpc-health-%: $(SRC)
@mkdir -p $(dir $@)
$(eval os := $(word 3, $(subst -, ,$@)))
$(eval arch := $(word 4, $(subst -, ,$@)))
CGO_ENABLED=0 GOOS=$(os) GOARCH=$(arch) go build -o $@ $(patsubst bin/%-$(os)-$(arch),cmd/%/main.go,$@)

0 comments on commit 3febc3c

Please sign in to comment.