-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (55 loc) · 1.76 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Makefile for building and linting Go project
# Basic project settings
BINARY_NAME=wasmstationd
BUILD_DIR=./build
SOURCE_DIR=./cmd/wasmstationd
# Go commands
GO_BUILD=go build
GO_INSTALL=go install
GO_CLEAN=go clean
GO_TEST=go test
# Versioning
VERSION ?= $(shell git describe --tags `git rev-list --tags --max-count=1`)
COMMIT := $(shell git log -1 --format='%H')
TMVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
# Build tags
build_tags = netgo
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
# Linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=evm-station \
-X github.com/cosmos/cosmos-sdk/version.AppName=$(BINARY_NAME) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION)
# Linter settings
GOLINT=golangci-lint
LINT_OPTIONS=--enable-all
ifeq ($(VERSION),1.0.0)
LINT_OPTIONS+=--disable=errcheck
endif
# Default target
default: build
# Build the project
build: go.sum
@echo "Building $(BINARY_NAME) binary..."
$(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME) $(SOURCE_DIR)
# Install the binary
install:
@echo "Installing $(BINARY_NAME) binary..."
$(GO_INSTALL) -tags "$(build_tags)" -ldflags '$(ldflags)' $(SOURCE_DIR)
# Run tests
test:
@echo "Running tests..."
$(GO_TEST) ./...
# Clean build artifacts
clean:
@echo "Cleaning up old versions..."
$(GO_CLEAN)
rm -f $(BUILD_DIR)/$(BINARY_NAME)
# Lint the project
lint:
@echo "Running linter..."
$(GOLINT) run $(LINT_OPTIONS)
.PHONY: default build install test clean lint