Skip to content

Commit

Permalink
[BUILD] Simplify go install
Browse files Browse the repository at this point in the history
We currently define a near-duplicate directive for compiling
the block-listener, when the only special case is really
the pkg path.  Therefore, lets simply define a bin-to-pkg
map and condense the rules for simpliciy.

Change-Id: Ie395bc5de25788f58d183a230fc2d59ec1a147b1
Signed-off-by: Greg Haskins <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Nov 14, 2016
1 parent 943391b commit a66221e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ JAVASHIM_DEPS = $(shell git ls-files core/chaincode/shim/java)
PROJECT_FILES = $(shell git ls-files)
IMAGES = src ccenv peer javaenv orderer

pkgmap.peer := $(PKGNAME)/peer
pkgmap.orderer := $(PKGNAME)/orderer
pkgmap.block-listener := $(PKGNAME)/examples/events/block-listener

all: peer orderer checks

Expand Down Expand Up @@ -144,7 +147,8 @@ build/docker/bin/%: build/image/src/.dummy $(PROJECT_FILES)
--user=$(UID) \
-v $(abspath build/docker/bin):/opt/gopath/bin \
-v $(abspath build/docker/pkg):/opt/gopath/pkg \
hyperledger/fabric-src:$(DOCKER_TAG) go install -ldflags "$(GO_LDFLAGS)" $(PKGNAME)/$(TARGET)
hyperledger/fabric-src:$(DOCKER_TAG) \
go install -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F))
@touch $@

build/bin:
Expand All @@ -154,16 +158,10 @@ build/bin:
build/bin/peer: build/image/ccenv/.dummy build/image/javaenv/.dummy
build/image/peer/.dummy: build/image/ccenv/.dummy build/image/javaenv/.dummy

build/bin/block-listener:
@mkdir -p $(@D)
$(CGO_FLAGS) GOBIN=$(abspath $(@D)) go install $(PKGNAME)/examples/events/block-listener
@echo "Binary available as $@"
@touch $@

build/bin/%: $(PROJECT_FILES)
@mkdir -p $(@D)
@echo "$@"
$(CGO_FLAGS) GOBIN=$(abspath $(@D)) go install -ldflags "$(GO_LDFLAGS)" $(PKGNAME)/$(@F)
$(CGO_FLAGS) GOBIN=$(abspath $(@D)) go install -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F))
@echo "Binary available as $@"
@touch $@

Expand Down

0 comments on commit a66221e

Please sign in to comment.