-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (74 loc) · 2.72 KB
/
Makefile
File metadata and controls
92 lines (74 loc) · 2.72 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
BINARY_NAME=pulsard
BUILD_DIR=build
HOME_DIR=$(HOME)/.pulsar
VERSION ?= $(shell git describe --tags --always --dirty)
COMMIT := $(shell git rev-parse HEAD)
LDFLAGS := -X main.Version=$(VERSION) -X main.Commit=$(COMMIT)
.PHONY: all build clean install init start reset deps test lint fmt run fresh build-all
all: build
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
@go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/pulsard
build-all:
@echo "Building for all platforms..."
@mkdir -p $(BUILD_DIR)
@GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/pulsard
@GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/pulsard
@GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/pulsard
@GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/pulsard
@GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/pulsard
install: build
@echo "Installing $(BINARY_NAME)..."
@go install -ldflags "$(LDFLAGS)" ./cmd/pulsard
init: build
@echo "Initializing node..."
@./$(BUILD_DIR)/$(BINARY_NAME) init "test-node" --home $(HOME_DIR)
start: build
@echo "Starting node..."
@./$(BUILD_DIR)/$(BINARY_NAME) start --home $(HOME_DIR)
reset:
@echo "Resetting node data..."
@rm -rf $(HOME_DIR)
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@go clean
deps:
@echo "Downloading dependencies..."
@go mod download
@go mod tidy
test:
@echo "Running tests..."
@go test -v -race -coverprofile=coverage.out ./...
test-integration:
@echo "Running integration tests..."
@go test -v -tags integration ./tests/...
lint:
@echo "Running linters..."
@golangci-lint run
fmt:
@echo "Formatting code..."
@go fmt ./...
@goimports -w .
check: fmt lint test
run: build init start
fresh: reset run
help:
@echo "Available commands:"
@echo " build - Build the binary"
@echo " build-all - Build for all platforms"
@echo " install - Install the binary"
@echo " init - Initialize node"
@echo " start - Start node"
@echo " reset - Reset node data"
@echo " clean - Clean build artifacts"
@echo " deps - Download dependencies"
@echo " test - Run tests"
@echo " test-integration - Run integration tests"
@echo " lint - Run linters"
@echo " fmt - Format code"
@echo " check - Run fmt, lint and test"
@echo " run - Build, init and start"
@echo " fresh - Reset, init and start"
@echo " help - Show this help"