Skip to content

Commit

Permalink
[FAB-3120] Add Makefile targets for binary release(s)
Browse files Browse the repository at this point in the history
In order for users to make use of any tools provided as
paer of fabric, they are required to clone the repo and
then build the tools.  This is not a very friendly
experience and is actually nearly impossible to do
on a Windows based system.  This is the first of several
tasks to help improve that.  This change provides the
following:

- adds RELEASE_PLATFORMS and RELEASE_PKGS variables which
are used to determine which packages to build and for which
target platforms

- adds targets for the specific platforms and packages which
leverage the Go compiler's ability to cross-compile for various
platforms

- target platforms: windows, macos, linux, power, z

- target packages:  configtxgen and cryptogen

The hope is that each of the platform specific CI's
will include a job which runs the release target for
its underlying platform (make release) and that
we build Windows and macOS binaries as part of the
x86_64 builds

Change-Id: Idd0e6c24d50d86432c5c9d62fe913e6836e98b26
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Apr 12, 2017
1 parent 118f82f commit 4f3cff5
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ PROTOS = $(shell git ls-files *.proto | grep -v vendor)
MSP_SAMPLECONFIG = $(shell git ls-files msp/sampleconfig/*)
PROJECT_FILES = $(shell git ls-files)
IMAGES = peer orderer ccenv javaenv buildenv testenv zookeeper kafka couchdb
RELEASE_PLATFORMS = windows-amd64 darwin-amd64 linux-amd64 linux-ppc64le linux-s390x
RELEASE_PKGS = configtxgen cryptogen

pkgmap.configtxgen := $(PKGNAME)/common/configtx/tool/configtxgen
pkgmap.peer := $(PKGNAME)/peer
pkgmap.orderer := $(PKGNAME)/orderer
pkgmap.block-listener := $(PKGNAME)/examples/events/block-listener
pkgmap.cryptogen := $(PKGNAME)/common/tools/cryptogen

include docker-env.mk

Expand Down Expand Up @@ -266,6 +269,49 @@ build/%.tar.bz2:
@echo "Creating $@"
@tar -jc $^ > $@

# builds release packages for the host platform
release: $(patsubst %,release/%, $(shell go env GOOS)-$(shell go env GOARCH))

# builds release packages for all target platforms
release-all: $(patsubst %,release/%, $(RELEASE_PLATFORMS))

release/windows-amd64: GOOS=windows
release/windows-amd64: GOARCH=amd64
release/windows-amd64: GO_TAGS+= nopkcs11
release/windows-amd64: $(patsubst %,release/windows-amd64/%, $(RELEASE_PKGS))

release/darwin-amd64: GOOS=darwin
release/darwin-amd64: GOARCH=amd64
release/darwin-amd64: GO_TAGS+= nopkcs11
release/darwin-amd64: $(patsubst %,release/darwin-amd64/%, $(RELEASE_PKGS))

release/linux-amd64: GOOS=linux
release/linux-amd64: GOARCH=amd64
release/linux-amd64: GO_TAGS+= nopkcs11
release/linux-amd64: $(patsubst %,release/linux-amd64/%, $(RELEASE_PKGS))

release/linux-ppc64le: GOOS=linux
release/linux-ppc64le: GOARCH=ppc64le
release/linux-ppc64le: GO_TAGS+= nopkcs11
release/linux-ppc64le: $(patsubst %,release/linux-ppc64le/%, $(RELEASE_PKGS))

release/linux-s390x: GOOS=linux
release/linux-s390x: GOARCH=s390x
release/linux-s390x: GO_TAGS+= nopkcs11
release/linux-s390x: $(patsubst %,release/linux-s390x/%, $(RELEASE_PKGS))

release/%/configtxgen: $(PROJECT_FILES)
@echo "Building $@ for $(GOOS)-$(GOARCH)"
mkdir -p $(@D)
$(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F))
@touch $@

release/%/cryptogen: $(PROJECT_FILES)
@echo "Building $@ for $(GOOS)-$(GOARCH)"
mkdir -p $(@D)
$(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F))
@touch $@

.PHONY: protos
protos: buildenv
@$(DRUN) $(DOCKER_NS)/fabric-buildenv:$(DOCKER_TAG) ./scripts/compile_protos.sh
Expand All @@ -285,6 +331,10 @@ clean: docker-clean unit-test-clean
dist-clean: clean gotools-clean
-@rm -rf /var/hyperledger/* ||:

.PHONY: release-clean
release-clean:
-@rm -rf release

.PHONY: unit-test-clean
unit-test-clean:
cd unit-test && docker-compose down

0 comments on commit 4f3cff5

Please sign in to comment.