chore: allow override of go binary in Makefile (#1660)

* chore: allow override of go binary in Makefile

* update build dir make commands with GO_BIN
This commit is contained in:
Robert Pirtle 2023-08-11 13:29:54 -07:00 committed by GitHub
parent 839dc80205
commit 23f0fe0667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 34 deletions

View File

@ -3,6 +3,8 @@
################################################################################ ################################################################################
PROJECT_NAME := kava# unique namespace for project PROJECT_NAME := kava# unique namespace for project
GO_BIN ?= go
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GIT_COMMIT := $(shell git rev-parse HEAD) GIT_COMMIT := $(shell git rev-parse HEAD)
GIT_COMMIT_SHORT := $(shell git rev-parse --short HEAD) GIT_COMMIT_SHORT := $(shell git rev-parse --short HEAD)
@ -26,8 +28,8 @@ VERSION := $(GIT_COMMIT_SHORT)
VERSION_NUMBER := $(VERSION) VERSION_NUMBER := $(VERSION)
endif endif
TENDERMINT_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') TENDERMINT_VERSION := $(shell $(GO_BIN) list -m github.com/tendermint/tendermint | sed 's:.* ::')
COSMOS_SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::') COSMOS_SDK_VERSION := $(shell $(GO_BIN) list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
.PHONY: print-git-info .PHONY: print-git-info
print-git-info: print-git-info:
@ -186,28 +188,28 @@ all: install
build: go.sum build: go.sum
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o out/$(shell go env GOOS)/kava.exe ./cmd/kava $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava.exe ./cmd/kava
else else
go build -mod=readonly $(BUILD_FLAGS) -o out/$(shell go env GOOS)/kava ./cmd/kava $(GO_BIN) build -mod=readonly $(BUILD_FLAGS) -o out/$(shell $(GO_BIN) env GOOS)/kava ./cmd/kava
endif endif
build-linux: go.sum build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
install: go.sum install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/kava $(GO_BIN) install -mod=readonly $(BUILD_FLAGS) ./cmd/kava
######################################## ########################################
### Tools & dependencies ### Tools & dependencies
go-mod-cache: go.sum go-mod-cache: go.sum
@echo "--> Download go modules to local cache" @echo "--> Download $(GO_BIN) modules to local cache"
@go mod download @$(GO_BIN) mod download
PHONY: go-mod-cache PHONY: go-mod-cache
go.sum: go.mod go.sum: go.mod
@echo "--> Ensuring dependencies have not been modified" @echo "--> Ensuring dependencies have not been modified"
@go mod verify @$(GO_BIN) mod verify
######################################## ########################################
### Linting ### Linting
@ -216,14 +218,14 @@ go.sum: go.mod
# This tool checks local markdown links as well. # This tool checks local markdown links as well.
# Set to exclude riot links as they trigger false positives # Set to exclude riot links as they trigger false positives
link-check: link-check:
@go get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3 @$(GO_BIN) get -u github.com/raviqqe/liche@f57a5d1c5be4856454cb26de155a65a4fd856ee3
liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*" liche -r . --exclude "^http://127.*|^https://riot.im/app*|^http://kava-testnet*|^https://testnet-dex*|^https://kava3.data.kava.io*|^https://ipfs.io*|^https://apps.apple.com*|^https://kava.quicksync.io*"
lint: lint:
golangci-lint run golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify $(GO_BIN) mod verify
.PHONY: lint .PHONY: lint
format: format:
@ -274,40 +276,40 @@ start:
# build dependency needed for cli tests # build dependency needed for cli tests
test-all: build test-all: build
# basic app tests # basic app tests
@go test ./app -v @$(GO_BIN) test ./app -v
# basic simulation (seed "4" happens to not unbond all validators before reaching 100 blocks) # basic simulation (seed "4" happens to not unbond all validators before reaching 100 blocks)
#@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h #@$(GO_BIN) test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
# other sim tests # other sim tests
#@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h #@$(GO_BIN) test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
#@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h #@$(GO_BIN) test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
# AppStateDeterminism does not use Seed flag # AppStateDeterminism does not use Seed flag
#@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h #@$(GO_BIN) test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
# run module tests and short simulations # run module tests and short simulations
test-basic: test test-basic: test
@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m @$(GO_BIN) test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
# other sim tests # other sim tests
@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m @$(GO_BIN) test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m @$(GO_BIN) test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
@# AppStateDeterminism does not use Seed flag @# AppStateDeterminism does not use Seed flag
@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m @$(GO_BIN) test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
# run end-to-end tests (local docker container must be built, see docker-build) # run end-to-end tests (local docker container must be built, see docker-build)
test-e2e: docker-build test-e2e: docker-build
go test -failfast -count=1 -v ./tests/e2e/... $(GO_BIN) test -failfast -count=1 -v ./tests/e2e/...
test: test:
@go test $$(go list ./... | grep -v 'contrib' | grep -v 'tests/e2e') @$(GO_BIN) test $$($(GO_BIN) list ./... | grep -v 'contrib' | grep -v 'tests/e2e')
# Run cli integration tests # Run cli integration tests
# `-p 4` to use 4 cores, `-tags cli_test` to tell go not to ignore the cli package # `-p 4` to use 4 cores, `-tags cli_test` to tell $(GO_BIN) not to ignore the cli package
# These tests use the `kvd` or `kvcli` binaries in the build dir, or in `$BUILDDIR` if that env var is set. # These tests use the `kvd` or `kvcli` binaries in the build dir, or in `$BUILDDIR` if that env var is set.
test-cli: build test-cli: build
@go test ./cli_test -tags cli_test -v -p 4 @$(GO_BIN) test ./cli_test -tags cli_test -v -p 4
# Run tests for migration cli command # Run tests for migration cli command
test-migrate: test-migrate:
@go test -v -count=1 ./migrate/... @$(GO_BIN) test -v -count=1 ./migrate/...
# Kick start lots of sims on an AWS cluster. # Kick start lots of sims on an AWS cluster.
# This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3 # This submits an AWS Batch job to run a lot of sims, each within a docker image. Results are uploaded to S3

View File

@ -27,10 +27,11 @@ DIRS := $(BUILD_CACHE_DIR) $(BIN_DIR)
################################################################################ ################################################################################
### Tool Versions ### ### Tool Versions ###
################################################################################ ################################################################################
GO_BIN ?= go
PROTOC_VERSION ?= v21.9 PROTOC_VERSION ?= v21.9
BUF_VERSION ?= v1.9.0 BUF_VERSION ?= v1.9.0
PROTOC_GEN_GOCOSMOS_VERSION ?= v0.3.1 PROTOC_GEN_GOCOSMOS_VERSION ?= v0.3.1
PROTOC_GEN_GRPC_GATEWAY_VERSION ?= $(shell go list -m github.com/grpc-ecosystem/grpc-gateway| sed 's:.* ::') PROTOC_GEN_GRPC_GATEWAY_VERSION ?= $(shell $(GO_BIN) list -m github.com/grpc-ecosystem/grpc-gateway| sed 's:.* ::')
PROTOC_GEN_DOC_VERSION ?= v1.5.1 PROTOC_GEN_DOC_VERSION ?= v1.5.1
SWAGGER_COMBINE_VERSION ?= v1.4.0 SWAGGER_COMBINE_VERSION ?= v1.4.0
@ -115,7 +116,7 @@ $(PROTOC_GEN_GOCOSMOS_VERSION_FILE):
git clone -q https://github.com/regen-network/cosmos-proto.git; \ git clone -q https://github.com/regen-network/cosmos-proto.git; \
cd cosmos-proto; \ cd cosmos-proto; \
git checkout -q $(PROTOC_GEN_GOCOSMOS_VERSION); \ git checkout -q $(PROTOC_GEN_GOCOSMOS_VERSION); \
GOBIN=$(ROOT_DIR)/$(BIN_DIR) go install ./protoc-gen-gocosmos GOBIN=$(ROOT_DIR)/$(BIN_DIR) $(GO_BIN) install ./protoc-gen-gocosmos
@rm -rf $(BUILD_CACHE_DIR)/protoc-gen-gocosmos @rm -rf $(BUILD_CACHE_DIR)/protoc-gen-gocosmos
PROTOC_GEN_GOCOSMOS := $(BIN_DIR)/protoc-gen-gocosmos PROTOC_GEN_GOCOSMOS := $(BIN_DIR)/protoc-gen-gocosmos
@ -138,8 +139,8 @@ $(PROTOC_GEN_GRPC_GATEWAY_VERSION_FILE):
git clone -q https://github.com/grpc-ecosystem/grpc-gateway.git; \ git clone -q https://github.com/grpc-ecosystem/grpc-gateway.git; \
cd grpc-gateway; \ cd grpc-gateway; \
git checkout -q $(PROTOC_GEN_GRPC_GATEWAY_VERSION); \ git checkout -q $(PROTOC_GEN_GRPC_GATEWAY_VERSION); \
GOBIN=$(ROOT_DIR)/$(BIN_DIR) go install ./protoc-gen-grpc-gateway; \ GOBIN=$(ROOT_DIR)/$(BIN_DIR) $(GO_BIN) install ./protoc-gen-grpc-gateway; \
GOBIN=$(ROOT_DIR)/$(BIN_DIR) go install ./protoc-gen-swagger GOBIN=$(ROOT_DIR)/$(BIN_DIR) $(GO_BIN) install ./protoc-gen-swagger
@rm -rf $(BUILD_CACHE_DIR)/protoc-gen-grpc-gateway @rm -rf $(BUILD_CACHE_DIR)/protoc-gen-grpc-gateway
PROTOC_GEN_GRPC_GATEWAY := $(BIN_DIR)/protoc-gen-grpc-gateway PROTOC_GEN_GRPC_GATEWAY := $(BIN_DIR)/protoc-gen-grpc-gateway

View File

@ -1,4 +1,5 @@
RSYNC_BIN ?= rsync RSYNC_BIN ?= rsync
GO_BIN ?= go
# #
# Versioning for google protobuf dependencies (any, http, etc) and # Versioning for google protobuf dependencies (any, http, etc) and
@ -13,12 +14,12 @@ PROTOBUF_ANY_DOWNLOAD_URL = https://raw.githubusercontent.com/protocolbuffers/pr
# #
# Proto dependencies under go.mod # Proto dependencies under go.mod
# #
GOGO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/gogo/protobuf) GOGO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/gogo/protobuf)
TENDERMINT_PATH := $(shell go list -m -f '{{.Dir}}' github.com/tendermint/tendermint) TENDERMINT_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/tendermint/tendermint)
COSMOS_PROTO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/cosmos-proto) COSMOS_PROTO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/cosmos-proto)
COSMOS_SDK_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/cosmos-sdk) COSMOS_SDK_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/cosmos-sdk)
IBC_GO_PATH := $(shell go list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v6) IBC_GO_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/cosmos/ibc-go/v6)
ETHERMINT_PATH := $(shell go list -m -f '{{.Dir}}' github.com/evmos/ethermint) ETHERMINT_PATH := $(shell $(GO_BIN) list -m -f '{{.Dir}}' github.com/evmos/ethermint)
# #
# Common target directories # Common target directories