2024-02-01 04:48:40 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
|
|
|
DOCKER := $(shell which docker)
|
|
|
|
|
2024-04-01 09:57:26 +00:00
|
|
|
LACONIC_BINARY = laconicd
|
2024-02-01 04:48:40 +00:00
|
|
|
|
|
|
|
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
COMMIT := $(shell git log -1 --format='%H')
|
|
|
|
|
|
|
|
# don't override user values
|
|
|
|
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
|
|
|
|
ifeq (,$(VERSION))
|
|
|
|
VERSION := $(BRANCH)-$(COMMIT)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Update the ldflags with the app, client & server names
|
|
|
|
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=laconic \
|
|
|
|
-X github.com/cosmos/cosmos-sdk/version.AppName=$(LACONIC_BINARY) \
|
|
|
|
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
|
|
|
|
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
|
|
|
|
|
|
|
|
BUILD_FLAGS := -ldflags '$(ldflags)'
|
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
BUILDDIR ?= $(CURDIR)/build
|
|
|
|
|
2024-02-01 04:48:40 +00:00
|
|
|
###########
|
|
|
|
# Install #
|
|
|
|
###########
|
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
go.sum: go.mod
|
|
|
|
echo "Ensure dependencies have not been modified ..." >&2
|
|
|
|
go mod verify
|
|
|
|
go mod tidy
|
|
|
|
|
|
|
|
BUILD_TARGETS := build install
|
|
|
|
|
|
|
|
build: BUILD_ARGS=-o $(BUILDDIR)/
|
|
|
|
build-linux:
|
|
|
|
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
|
2024-02-01 04:48:40 +00:00
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
|
2024-04-01 09:57:26 +00:00
|
|
|
@echo "--> installing laconicd"
|
2024-03-07 05:10:41 +00:00
|
|
|
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...
|
2024-02-01 04:48:40 +00:00
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
$(BUILDDIR)/:
|
|
|
|
mkdir -p $(BUILDDIR)/
|
|
|
|
|
|
|
|
all: install
|
|
|
|
|
|
|
|
.PHONY: build build-linux install
|
2024-02-01 04:48:40 +00:00
|
|
|
|
|
|
|
##################
|
|
|
|
### Protobuf ###
|
|
|
|
##################
|
|
|
|
|
|
|
|
protoVer=0.14.0
|
|
|
|
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
|
|
|
|
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
|
|
|
|
|
|
|
|
proto-all: proto-format proto-lint proto-gen
|
|
|
|
|
|
|
|
proto-gen:
|
|
|
|
@echo "Generating protobuf files..."
|
|
|
|
@$(protoImage) sh ./scripts/protocgen.sh
|
|
|
|
@go mod tidy
|
|
|
|
|
|
|
|
proto-format:
|
|
|
|
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
|
|
|
|
|
|
|
|
proto-lint:
|
|
|
|
@$(protoImage) buf lint proto/ --error-format=json
|
|
|
|
|
|
|
|
.PHONY: proto-all proto-gen proto-format proto-lint
|
|
|
|
|
|
|
|
#################
|
|
|
|
### Linting ###
|
|
|
|
#################
|
|
|
|
|
|
|
|
golangci_lint_cmd=golangci-lint
|
|
|
|
golangci_version=v1.51.2
|
|
|
|
|
|
|
|
lint:
|
|
|
|
@echo "--> Running linter"
|
|
|
|
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
|
|
|
|
@$(golangci_lint_cmd) run ./... --timeout 15m
|
|
|
|
|
|
|
|
lint-fix:
|
|
|
|
@echo "--> Running linter and fixing issues"
|
|
|
|
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
|
|
|
|
@$(golangci_lint_cmd) run ./... --fix --timeout 15m
|
|
|
|
|
|
|
|
.PHONY: lint lint-fix
|
2024-02-29 11:54:35 +00:00
|
|
|
|
|
|
|
#################
|
|
|
|
### Tests ###
|
|
|
|
#################
|
|
|
|
|
|
|
|
test-integration:
|
|
|
|
$(MAKE) -C tests test-integration
|
2024-03-04 11:16:09 +00:00
|
|
|
|
|
|
|
test-e2e:
|
|
|
|
$(MAKE) -C tests test-e2e
|
2024-03-07 09:11:53 +00:00
|
|
|
|
|
|
|
test-unit:
|
|
|
|
go test ./utils/... ./cmd/... -mod=readonly -test.v
|