Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Go version checking to Makefile #99

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@ BUILD_FLAGS := -ldflags '$(ldflags)'

all: install

build: go.sum
build: check-go-version go.sum
ifeq ($(OS), Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/decentrd.exe ./cmd/decentrd
else
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/decentrd ./cmd/decentrd
endif

install: go.sum
install: check-go-version go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/decentrd

linux: go.sum
linux: check-go-version go.sum
GOOS=linux GOARCH=amd64 $(MAKE) build

# Add check to make sure we are using the proper Go version before proceeding with anything
check-go-version:
@if ! go version | grep -q "go1.19"; then \
echo "\033[0;31mERROR:\033[0m Go version 1.19 is required for compiling decentrd. 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

### tools ###

clean:
Expand Down Expand Up @@ -64,9 +71,9 @@ containerProtoGen=decentr-buildtools-protogen
containerProtoSwaggerGen=decentr-buildtools-protoswaggergen
containerProtoFmt=decentr-buildtools-protofmt

proto-all: proto-lint proto-gen
proto-all: check-go-version proto-lint proto-gen

proto-gen:
proto-gen: check-go-version
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(buildtools) \
sh ./scripts/protocgen.sh; fi
Expand Down