Allow setting custom go binary when building (#254)

To use, just pass set the path to the go bin you want to use in
the GOBIN env variable:

`GOBIN=/my/bin/go make`.
This commit is contained in:
Franck R 2022-06-03 11:55:11 +10:00 committed by GitHub
parent ca595277e6
commit 4da7fea78a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 12 deletions

View File

@ -6,6 +6,8 @@ CC_PREFIX := github.com/status-im/go-waku
SHELL := bash # the shell used internally by Make SHELL := bash # the shell used internally by Make
GOBIN ?= $(shell which go)
.PHONY: all build lint test coverage build-example static-library dynamic-library test-c test-c-template mobile-android mobile-ios .PHONY: all build lint test coverage build-example static-library dynamic-library test-c test-c-template mobile-android mobile-ios
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
@ -39,23 +41,23 @@ all: build
deps: lint-install deps: lint-install
build: build:
go build $(BUILD_FLAGS) -o build/waku waku.go ${GOBIN} build $(BUILD_FLAGS) -o build/waku waku.go
vendor: vendor:
go mod tidy ${GOBIN} mod tidy
lint-install: lint-install:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
bash -s -- -b $(shell go env GOPATH)/bin v1.41.1 bash -s -- -b $(shell ${GOBIN} env GOPATH)/bin v1.41.1
lint: lint:
@echo "lint" @echo "lint"
@golangci-lint --exclude=SA1019 run ./... --deadline=5m @golangci-lint --exclude=SA1019 run ./... --deadline=5m
test: test:
go test ./waku/... -coverprofile=${GO_TEST_OUTFILE}.tmp ${GOBIN} test ./waku/... -coverprofile=${GO_TEST_OUTFILE}.tmp
cat ${GO_TEST_OUTFILE}.tmp | grep -v ".pb.go" > ${GO_TEST_OUTFILE} cat ${GO_TEST_OUTFILE}.tmp | grep -v ".pb.go" > ${GO_TEST_OUTFILE}
go tool cover -html=${GO_TEST_OUTFILE} -o ${GO_HTML_COV} ${GOBIN} tool cover -html=${GO_TEST_OUTFILE} -o ${GO_HTML_COV}
_before-cc: _before-cc:
CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} ./coverage/cc-test-reporter before-build CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} ./coverage/cc-test-reporter before-build
@ -66,12 +68,12 @@ _after-cc:
test-ci: _before-cc test _after-cc test-ci: _before-cc test _after-cc
generate: generate:
go generate ./waku/v2/protocol/pb/generate.go ${GOBIN} generate ./waku/v2/protocol/pb/generate.go
go generate ./waku/persistence/migrations/sql ${GOBIN} generate ./waku/persistence/migrations/sql
coverage: coverage:
go test -count 1 -coverprofile=coverage.out ./... ${GOBIN} test -count 1 -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o=coverage.html ${GOBIN} tool cover -html=coverage.out -o=coverage.html
# build a docker image for the fleet # build a docker image for the fleet
docker-image: DOCKER_IMAGE_TAG ?= latest docker-image: DOCKER_IMAGE_TAG ?= latest
@ -96,7 +98,7 @@ build-example: build-example-basic2 build-example-chat-2 build-example-filter2 b
static-library: static-library:
@echo "Building static library..." @echo "Building static library..."
go build \ ${GOBIN} build \
-buildmode=c-archive \ -buildmode=c-archive \
-o ./build/lib/libgowaku.a \ -o ./build/lib/libgowaku.a \
./library/ ./library/
@ -105,7 +107,7 @@ static-library:
dynamic-library: dynamic-library:
@echo "Building shared library..." @echo "Building shared library..."
$(GOBIN_SHARED_LIB_CFLAGS) $(GOBIN_SHARED_LIB_CGO_LDFLAGS) go build \ $(GOBIN_SHARED_LIB_CFLAGS) $(GOBIN_SHARED_LIB_CGO_LDFLAGS) ${GOBIN} build \
-buildmode=c-shared \ -buildmode=c-shared \
-o ./build/lib/libgowaku.$(GOBIN_SHARED_LIB_EXT) \ -o ./build/lib/libgowaku.$(GOBIN_SHARED_LIB_EXT) \
./library/ ./library/
@ -128,4 +130,4 @@ mobile-ios:
gomobile init && \ gomobile init && \
gomobile bind -target=ios -ldflags="-s -w" -o ./build/lib/Gowaku.xcframework ./mobile gomobile bind -target=ios -ldflags="-s -w" -o ./build/lib/Gowaku.xcframework ./mobile
@echo "IOS library built:" @echo "IOS library built:"
@ls -la ./build/lib/*.xcframework @ls -la ./build/lib/*.xcframework