-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ComputerKeeda/feature/external-seq/espress…
…o-develop Add Makefile for build and lint operations
- Loading branch information
Showing
2 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ release/ | |
*.log | ||
*.ign | ||
/.trunk | ||
/.idea | ||
/.idea | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Makefile for building and linting Go project | ||
|
||
# Basic project settings | ||
BINARY_NAME=junction-jip-2 | ||
BUILD_DIR=./build | ||
SOURCE_DIR=./cmd/junctiond | ||
CHECKSUM_FILE=$(BUILD_DIR)/checksums.txt | ||
|
||
# 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=junction \ | ||
-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 for the current architecture | ||
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) $(CHECKSUM_FILE) | ||
|
||
# Lint the project | ||
lint: | ||
@echo "Running linter..." | ||
$(GOLINT) run $(LINT_OPTIONS) | ||
|
||
# Print system information | ||
print-system: | ||
@echo "System architecture: $(shell uname -s)/$(shell uname -m)" | ||
|
||
# Build the project for different architectures and generate checksums | ||
build-all: go.sum | ||
@echo "Building $(BINARY_NAME) for different architectures..." | ||
rm -f $(CHECKSUM_FILE) | ||
GOOS=linux GOARCH=amd64 $(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(SOURCE_DIR) | ||
@shasum -a 256 $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 >> $(CHECKSUM_FILE) | ||
GOOS=linux GOARCH=arm64 $(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 $(SOURCE_DIR) | ||
@shasum -a 256 $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 >> $(CHECKSUM_FILE) | ||
GOOS=darwin GOARCH=amd64 $(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 $(SOURCE_DIR) | ||
@shasum -a 256 $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 >> $(CHECKSUM_FILE) | ||
GOOS=darwin GOARCH=arm64 $(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 $(SOURCE_DIR) | ||
@shasum -a 256 $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 >> $(CHECKSUM_FILE) | ||
GOOS=windows GOARCH=amd64 $(GO_BUILD) -tags "$(build_tags)" -ldflags '$(ldflags)' -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(SOURCE_DIR) | ||
@shasum -a 256 $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe >> $(CHECKSUM_FILE) | ||
|
||
.PHONY: default build install test clean lint print-system build-all |