Skip to content

Commit 4f3cff5

Browse files
committed
[FAB-3120] Add Makefile targets for binary release(s)
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 <[email protected]>
1 parent 118f82f commit 4f3cff5

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

Makefile

+50
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ PROTOS = $(shell git ls-files *.proto | grep -v vendor)
7878
MSP_SAMPLECONFIG = $(shell git ls-files msp/sampleconfig/*)
7979
PROJECT_FILES = $(shell git ls-files)
8080
IMAGES = peer orderer ccenv javaenv buildenv testenv zookeeper kafka couchdb
81+
RELEASE_PLATFORMS = windows-amd64 darwin-amd64 linux-amd64 linux-ppc64le linux-s390x
82+
RELEASE_PKGS = configtxgen cryptogen
8183

8284
pkgmap.configtxgen := $(PKGNAME)/common/configtx/tool/configtxgen
8385
pkgmap.peer := $(PKGNAME)/peer
8486
pkgmap.orderer := $(PKGNAME)/orderer
8587
pkgmap.block-listener := $(PKGNAME)/examples/events/block-listener
88+
pkgmap.cryptogen := $(PKGNAME)/common/tools/cryptogen
8689

8790
include docker-env.mk
8891

@@ -266,6 +269,49 @@ build/%.tar.bz2:
266269
@echo "Creating $@"
267270
@tar -jc $^ > $@
268271

272+
# builds release packages for the host platform
273+
release: $(patsubst %,release/%, $(shell go env GOOS)-$(shell go env GOARCH))
274+
275+
# builds release packages for all target platforms
276+
release-all: $(patsubst %,release/%, $(RELEASE_PLATFORMS))
277+
278+
release/windows-amd64: GOOS=windows
279+
release/windows-amd64: GOARCH=amd64
280+
release/windows-amd64: GO_TAGS+= nopkcs11
281+
release/windows-amd64: $(patsubst %,release/windows-amd64/%, $(RELEASE_PKGS))
282+
283+
release/darwin-amd64: GOOS=darwin
284+
release/darwin-amd64: GOARCH=amd64
285+
release/darwin-amd64: GO_TAGS+= nopkcs11
286+
release/darwin-amd64: $(patsubst %,release/darwin-amd64/%, $(RELEASE_PKGS))
287+
288+
release/linux-amd64: GOOS=linux
289+
release/linux-amd64: GOARCH=amd64
290+
release/linux-amd64: GO_TAGS+= nopkcs11
291+
release/linux-amd64: $(patsubst %,release/linux-amd64/%, $(RELEASE_PKGS))
292+
293+
release/linux-ppc64le: GOOS=linux
294+
release/linux-ppc64le: GOARCH=ppc64le
295+
release/linux-ppc64le: GO_TAGS+= nopkcs11
296+
release/linux-ppc64le: $(patsubst %,release/linux-ppc64le/%, $(RELEASE_PKGS))
297+
298+
release/linux-s390x: GOOS=linux
299+
release/linux-s390x: GOARCH=s390x
300+
release/linux-s390x: GO_TAGS+= nopkcs11
301+
release/linux-s390x: $(patsubst %,release/linux-s390x/%, $(RELEASE_PKGS))
302+
303+
release/%/configtxgen: $(PROJECT_FILES)
304+
@echo "Building $@ for $(GOOS)-$(GOARCH)"
305+
mkdir -p $(@D)
306+
$(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F))
307+
@touch $@
308+
309+
release/%/cryptogen: $(PROJECT_FILES)
310+
@echo "Building $@ for $(GOOS)-$(GOARCH)"
311+
mkdir -p $(@D)
312+
$(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F))
313+
@touch $@
314+
269315
.PHONY: protos
270316
protos: buildenv
271317
@$(DRUN) $(DOCKER_NS)/fabric-buildenv:$(DOCKER_TAG) ./scripts/compile_protos.sh
@@ -285,6 +331,10 @@ clean: docker-clean unit-test-clean
285331
dist-clean: clean gotools-clean
286332
-@rm -rf /var/hyperledger/* ||:
287333

334+
.PHONY: release-clean
335+
release-clean:
336+
-@rm -rf release
337+
288338
.PHONY: unit-test-clean
289339
unit-test-clean:
290340
cd unit-test && docker-compose down

0 commit comments

Comments
 (0)