-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (69 loc) · 2.2 KB
/
Makefile
File metadata and controls
81 lines (69 loc) · 2.2 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
.PHONY: all build clean test install fmt vet lint help
# Variables
BINARY_NAME=go-bindiff-struct
BIN_DIR=bin
CMD_DIR=cmd/go-bindiff-struct
GO=go
GOFLAGS=-v
# Default target
all: build
# Build the binary
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BIN_DIR)
$(GO) build $(GOFLAGS) -o $(BIN_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
@echo "Build complete: $(BIN_DIR)/$(BINARY_NAME)"
# Install the binary to GOPATH/bin
install:
@echo "Installing $(BINARY_NAME)..."
$(GO) install $(GOFLAGS) ./$(CMD_DIR)
@echo "Installation complete"
# Run tests
test:
@echo "Running tests..."
$(GO) test -v ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GO) test -v -coverprofile=coverage.txt -covermode=atomic ./...
$(GO) tool cover -html=coverage.txt -o coverage.html
@echo "Coverage report generated: coverage.html"
# Format code
fmt:
@echo "Formatting code..."
$(GO) fmt ./...
# Run go vet
vet:
@echo "Running go vet..."
$(GO) vet ./...
# Run all checks
check: fmt vet test
# Build for multiple platforms
build-all:
@echo "Building for multiple platforms..."
@mkdir -p $(BIN_DIR)
GOOS=linux GOARCH=amd64 $(GO) build -o $(BIN_DIR)/$(BINARY_NAME)-linux-amd64 ./$(CMD_DIR)
GOOS=darwin GOARCH=amd64 $(GO) build -o $(BIN_DIR)/$(BINARY_NAME)-darwin-amd64 ./$(CMD_DIR)
GOOS=darwin GOARCH=arm64 $(GO) build -o $(BIN_DIR)/$(BINARY_NAME)-darwin-arm64 ./$(CMD_DIR)
GOOS=windows GOARCH=amd64 $(GO) build -o $(BIN_DIR)/$(BINARY_NAME)-windows-amd64.exe ./$(CMD_DIR)
@echo "Multi-platform build complete"
# Clean build artifacts
clean:
@echo "Cleaning..."
rm -rf $(BIN_DIR)
rm -f coverage.txt coverage.html
$(GO) clean
@echo "Clean complete"
# Show help
help:
@echo "Available targets:"
@echo " make build - Build the binary"
@echo " make install - Install to GOPATH/bin"
@echo " make test - Run tests"
@echo " make test-coverage - Run tests with coverage"
@echo " make fmt - Format code"
@echo " make vet - Run go vet"
@echo " make check - Run fmt, vet, and test"
@echo " make build-all - Build for multiple platforms"
@echo " make clean - Remove build artifacts"
@echo " make help - Show this help"