Skip to content

Commit

Permalink
Add Go version checking to Makefile (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonsopko authored Mar 8, 2023
1 parent 9d46223 commit 7e8ff7e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,46 @@ all: download install
download:
git submodule update --init --recursive

install: lint check-network go.sum
install: check-version lint check-network go.sum
go install -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) ./cmd/bzed

build: check-network go.sum
build: check-version check-network go.sum
go build -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) -o $(BUILDDIR)/bzed ./cmd/bzed

build-win64: check-network go.sum
build-win64: check-version check-network go.sum
go build -buildmode=exe -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) -o $(BUILDDIR)/win64/bzed.exe ./cmd/bzed

.PHONY: build

build-linux: check-network go.sum
build-linux: check-version check-network go.sum
ifeq ($(OS), Linux)
GOOS=linux GOARCH=amd64 $(MAKE) build
else
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
endif

build-linux-arm64: check-network go.sum
build-linux-arm64: check-version check-network go.sum
ifeq ($(OS), Linux)
GOOS=linux GOARCH=arm64 $(MAKE) build
else
LEDGER_ENABLED=false GOOS=linux GOARCH=arm64 $(MAKE) build
endif

build-mac: check-network go.sum
build-mac: check-version check-network go.sum
ifeq ($(OS), Darwin)
GOOS=darwin GOARCH=amd64 $(MAKE) build
else
LEDGER_ENABLED=false GOOS=darwin GOARCH=amd64 $(MAKE) build
endif

build-mac-arm64: check-network go.sum
build-mac-arm64: check-version check-network go.sum
ifeq ($(OS), Darwin)
LEDGER_ENABLED=false GOOS=darwin GOARCH=arm64 $(MAKE) build
else
LEDGER_ENABLED=false GOOS=darwin GOARCH=arm64 $(MAKE) build
endif

build-all: lint all build-win64 build-mac build-mac-arm64 build-linux build-linux-arm64 compress-build
build-all: check-version lint all build-win64 build-mac build-mac-arm64 build-linux build-linux-arm64 compress-build

compress-build:
rm -rf $(BUILDDIR)/compressed
Expand Down Expand Up @@ -111,6 +111,13 @@ lint-ci:
@echo "--> Running linter for CI"
@nix run -f ./. lint-env -c lint-ci

# Add check to make sure we are using the proper Go version before proceeding with anything
check-version:
@if ! go version | grep -q "go1.19"; then \
echo "\033[0;31mERROR:\033[0m Go version 1.19 is required for compiling bzed. It looks like you are using" "$(shell go version) \nThere are potential consensus-breaking changes that can occur when running binaries compiled with different versions of Go. Please download Go version 1.19 and retry. Thank you!"; \
exit 1; \
fi

test-sim-nondeterminism: check-network
@echo "Running non-determinism test..."
@go test $(TEST_TAGS) -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
Expand Down

0 comments on commit 7e8ff7e

Please sign in to comment.