-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (103 loc) · 3.28 KB
/
Copy pathMakefile
File metadata and controls
122 lines (103 loc) · 3.28 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Makefile for MCP-TUI
BINARY_NAME=mcp-tui
VERSION?=dev
BUILD_DIR=bin
DIST_DIR=dist
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
# Build flags
LDFLAGS=-ldflags "-X main.version=$(VERSION)"
.PHONY: all build clean test coverage lint fmt vet deps install dev release help
# Default target
all: clean deps lint test build
# Build the binary
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) .
# Clean build artifacts
clean:
@echo "Cleaning..."
$(GOCLEAN)
@rm -rf $(BUILD_DIR) $(DIST_DIR)
# Run tests
test:
@echo "Running tests..."
$(GOTEST) -v ./...
# Run tests with coverage
coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
# Lint code
lint:
@echo "Running linter..."
@which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && $(GOGET) github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run
# Format code
fmt:
@echo "Formatting code..."
$(GOFMT) ./...
# Vet code
vet:
@echo "Vetting code..."
$(GOCMD) vet ./...
# Download dependencies
deps:
@echo "Downloading dependencies..."
$(GOMOD) download
$(GOMOD) tidy
# Install binary to local bin
install: build
@echo "Installing $(BINARY_NAME) to ~/.local/bin..."
@mkdir -p ~/.local/bin
@cp $(BUILD_DIR)/$(BINARY_NAME) ~/.local/bin/
# Development build with debug info
dev:
@echo "Building development version..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -gcflags="all=-N -l" -o $(BUILD_DIR)/$(BINARY_NAME) .
# Cross-platform release builds
release:
@echo "Building release binaries..."
@mkdir -p $(DIST_DIR)
@echo "Building for Linux..."
@GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME)-linux-amd64 .
@GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME)-linux-arm64 .
@echo "Building for macOS..."
@GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME)-darwin-amd64 .
@GOOS=darwin GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME)-darwin-arm64 .
@echo "Building for Windows..."
@GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME)-windows-amd64.exe .
# Run test servers
test-servers:
@echo "Testing with problematic servers..."
@chmod +x test-servers/test-bad-servers.sh
@./test-servers/test-bad-servers.sh
# Development server (runs the TUI in development mode)
run: build
@./$(BUILD_DIR)/$(BINARY_NAME)
# Help
help:
@echo "Available targets:"
@echo " all - Clean, deps, lint, test, and build"
@echo " build - Build the binary"
@echo " clean - Clean build artifacts"
@echo " test - Run tests"
@echo " coverage - Run tests with coverage"
@echo " lint - Run linter"
@echo " fmt - Format code"
@echo " vet - Vet code"
@echo " deps - Download dependencies"
@echo " install - Install binary to ~/.local/bin"
@echo " dev - Build development version"
@echo " release - Build cross-platform release binaries"
@echo " test-servers - Test with problematic MCP servers"
@echo " run - Build and run the TUI"
@echo " help - Show this help"