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

Remove some unused stuff from the devtools makefile #2136

Merged
merged 13 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Clean up some unused stuff from our makefiles [PR 2136](https://github.com/provenance-io/provenance/pull/2136).
77 changes: 46 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,65 @@
#!/usr/bin/make -f
export GO111MODULE=on

GO ?= go
# Find the go executable if it wasn't pre-set (e.g. via env var).
ifeq (,$(GO))
ifeq ($(OS),Windows_NT)
GO := $(shell where go.exe 2> NUL)
else
GO := $(shell command -v go 2> /dev/null)
endif
endif
# Make sure we have a working go executable since most stuff in here needs it.
ifeq ("$(shell $(GO) version > /dev/null || echo nogo)","nogo")
$(error Could not find go. Is it in PATH? $(GO))
endif
ifeq (,$(GOPATH))
GOPATH := $(shell $(GO) env GOPATH)
endif
BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build

WITH_LEDGER ?= true

# We used to use 'yes' on these flags, so at least for now, change 'yes' into 'true'
ifeq ($(WITH_LEDGER),yes)
WITH_LEDGER=true
endif

BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null)
BRANCH_PRETTY := $(subst /,-,$(BRANCH))
export CMTVERSION := $(shell $(GO) list -m github.com/cometbft/cometbft 2> /dev/null | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%h' 2> /dev/null)
# don't override user values
ifeq (,$(COMMIT))
COMMIT := unknown
endif
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
# If VERSION wasn't provided (e.g. via env var), look for a tag on HEAD.
VERSION := $(shell git describe --exact-match 2> /dev/null)
# If there isn't a tag, use the branch name and commit hash.
ifeq (,$(VERSION))
VERSION := $(BRANCH_PRETTY)-$(COMMIT)
VERSION := $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo nobranch))-$(COMMIT)
endif
endif

GOLANGCI_LINT=$(shell which golangci-lint)
ifeq ("$(wildcard $(GOLANGCI_LINT))","")
GOLANGCI_LINT = $(BINDIR)/golangci-lint
ifeq (,$(GOLANGCI_LINT))
GOLANGCI_LINT := $(shell which golangci-lint 2> /dev/null)
# If golangci-lint isn't found, use a common location and let whatever needs it fail on its own.
ifeq (,$(GOLANGCI_LINT))
GOLANGCI_LINT := $(BINDIR)/golangci-lint
endif
endif

HTTPS_GIT := https://github.com/provenance-io/provenance.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

# Only support go version 1.23
SUPPORTED_GO_MAJOR_VERSION = 1
SUPPORTED_GO_MINOR_VERSION = 23
GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
GO_VERSION_VALIDATION_ERR_MSG = Golang version $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION) is not supported, you must use $(SUPPORTED_GO_MAJOR_VERSION).$(SUPPORTED_GO_MINOR_VERSION)

# The below include contains the tools target.
include contrib/devtools/Makefile

#Identify the system and if gcc is available.
ifeq ($(OS),Windows_NT)
UNAME_S = 'windows_nt'
UNAME_M = 'unknown'
UNAME_S = windows_nt
UNAME_M = unknown
else
UNAME_S = $(shell uname -s | tr '[A-Z]' '[a-z]')
UNAME_M = $(shell uname -m | tr '[A-Z]' '[a-z]')
UNAME_S := $(shell uname -s | tr '[A-Z]' '[a-z]')
UNAME_M := $(shell uname -m | tr '[A-Z]' '[a-z]')
endif

ifeq ($(UNAME_S),windows_nt)
Expand All @@ -67,6 +76,8 @@ endif
# Build Flags/Tags
##############################

export CMTVERSION := $(shell $(GO) list -m github.com/cometbft/cometbft 2> /dev/null | sed 's:.* ::')

ifeq ($(WITH_LEDGER),true)
ifeq ($(UNAME_S),openbsd)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
Expand Down Expand Up @@ -178,7 +189,6 @@ RELEASE_PLAN=$(BUILDDIR)/plan-$(VERSION).json
RELEASE_CHECKSUM_NAME=sha256sum.txt
RELEASE_CHECKSUM=$(BUILDDIR)/$(RELEASE_CHECKSUM_NAME)

UNAME_M = $(shell uname -m)
ifeq ($(UNAME_S),darwin)
LIBWASMVM := $(LIBWASMVM).dylib
else ifeq ($(UNAME_S),linux)
Expand Down Expand Up @@ -209,7 +219,7 @@ build-release-checksum: $(RELEASE_CHECKSUM)

$(RELEASE_CHECKSUM):
cd $(BUILDDIR) && \
shasum -a 256 *.zip > $(RELEASE_CHECKSUM) && \
shasum -a 256 *.zip > $(RELEASE_CHECKSUM) && \
cd ..

.PHONY: build-release-plan
Expand Down Expand Up @@ -240,7 +250,7 @@ build-release-zip: $(RELEASE_ZIP)

$(RELEASE_ZIP): $(RELEASE_PIO) $(RELEASE_WASM)
cd $(BUILDDIR) && \
zip -u $(RELEASE_ZIP_NAME) bin/$(LIBWASMVM) bin/provenanced && \
zip -u $(RELEASE_ZIP_NAME) bin/$(LIBWASMVM) bin/provenanced && \
cd ..

# gon packages the zip wrong. need bin/provenanced and bin/libwasmvm
Expand Down Expand Up @@ -309,10 +319,15 @@ get-valid-sections:

.PHONY: go-mod-cache go.sum lint clean format check-built linkify update-tocs get-valid-sections

# Only support go version 1.23
SUPPORTED_GO_MAJOR_VERSION = 1
SUPPORTED_GO_MINOR_VERSION = 23
GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)

validate-go-version: ## Validates the installed version of go against Provenance's minimum requirement.
@if [ "$(GO_MAJOR_VERSION)" -ne $(SUPPORTED_GO_MAJOR_VERSION) ] || [ "$(GO_MINOR_VERSION)" -ne $(SUPPORTED_GO_MINOR_VERSION) ]; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)'; \
echo 'Golang version $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION) is not supported, you must use $(SUPPORTED_GO_MAJOR_VERSION).$(SUPPORTED_GO_MINOR_VERSION).'; \
exit 1; \
fi

Expand Down Expand Up @@ -482,7 +497,7 @@ proto-gen:
sh ./scripts/protocgen.sh; \
fi
mv .go.mod.bak go.mod
$(GO)go mod tidy
$(GO) mod tidy

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
Expand Down Expand Up @@ -514,11 +529,11 @@ proto-lint:

proto-check-breaking:
@echo "Check breaking Protobuf files"
$(DOCKER_BUF) breaking proto --against $(HTTPS_GIT)#branch=main,subdir=proto --error-format=json
$(DOCKER_BUF) breaking proto --against '$(HTTPS_GIT)#branch=main,subdir=proto' --error-format=json

proto-check-breaking-third-party:
@echo "Check breaking Protobuf files"
$(DOCKER_BUF) breaking third_party/proto --against $(HTTPS_GIT)#branch=main,subdir=third_party/proto --error-format=json
@echo "Check breaking 3rd party Protobuf files"
$(DOCKER_BUF) breaking third_party/proto --against '$(HTTPS_GIT)#branch=main,subdir=third_party/proto' --error-format=json

proto-update-check:
@echo "Checking for third_party Protobuf updates"
Expand Down
49 changes: 4 additions & 45 deletions contrib/devtools/Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
########################################
### Developer Tools
###
# Find OS and Go environment
# GO contains the Go binary
# FS contains the OS file separator
###
ifeq ($(OS),Windows_NT)
GO := $(shell where go.exe 2> NUL)
FS := "\\"
else
GO := $(shell command -v go 2> /dev/null)
FS := "/"
endif

ifeq ($(GO),)
$(error could not find go. Is it in PATH? $(GO))
endif

###############################################################################
### Functions ###
###############################################################################

go_get = $(if $(findstring Windows_NT,$(OS)),\
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\
,\
mkdir -p $(GITHUBDIR)$(FS)$(1) &&\
(test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\
)\
cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3)

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd)


###############################################################################
### Tools ###
###############################################################################

PREFIX ?= /usr/local
BIN ?= $(PREFIX)/bin
UNAME_S ?= $(shell uname -s)
UNAME_M ?= $(shell uname -m)

GOPATH ?= $(shell $(GO) env GOPATH)
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com
### runsim --------> Used by some of the simulation targets.
### golangci-lint --> Used to lint our go code.

BUF_VERSION ?= 0.11.0

TOOLS_DESTDIR ?= $(GOPATH)/bin
RUNSIM = $(TOOLS_DESTDIR)/runsim
Expand Down
9 changes: 1 addition & 8 deletions sims.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/make -f

########################################
### Simulations
###
Expand All @@ -18,8 +16,6 @@
### SIM_BLOCK_SIZE: The size of blocks to use for test-sim-benchmark or test-sim-profile. Default is 200.
### SIM_COMMIT: Whether to commit during test-sim-benchmark or test-sim-profile. Default is true.

GO ?= go
BINDIR ?= $(GOPATH)/bin
SIMAPP = ./app
DB_BACKEND ?= goleveldb
ifneq ($(DB_BACKEND),goleveldb)
Expand All @@ -30,11 +26,8 @@ endif
# Runsim creates a command string, then does a split on " " to turn it into args.
# With two tags, e.g. -tags 'foo bar', you'd end up with three args, "-tags", "'foo", and "bar'", and it'll get confused.
# But we CAN provide a single tag in the -SimAppPkg value in order to trick it into including it in the `go test` commands.
# We need to provide the -DBBackend flag to the runsim tests too, and use the same hack.
# We provide the -DBBackend flag to the runsim tests using this same -SimAppPkg hack.
SIMAPP += -DBBackend=$(DB_BACKEND)
ifneq ($(db_tag),)
SIMAPP += -tags $(db_tag)
endif

SIM_GENESIS ?= ${HOME}/.provenanced/config/genesis.json

Expand Down
Loading