-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (78 loc) · 2.61 KB
/
Copy pathMakefile
File metadata and controls
100 lines (78 loc) · 2.61 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
.PHONY: all build build-cli build-gui test lint vet clean run-cli install
# Version info
VERSION ?= 1.0.0
BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Go build flags
LDFLAGS := -s -w -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT)
# Directories
CMD_DIR := ./cmd
DIST_DIR := ./dist
# Default target
all: build
# Build both CLI and GUI
build: build-cli build-gui
# Build CLI binary
build-cli:
@echo "Building CLI binary..."
go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/scantool-cli $(CMD_DIR)/scantool-cli
# Build GUI binary
build-gui:
@echo "Building GUI binary..."
go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/scantool $(CMD_DIR)/scantool
# Cross-compile for all platforms
build-all:
@echo "Building for Windows amd64..."
GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/scantool-windows-amd64.exe $(CMD_DIR)/scantool-cli
@echo "Building for Linux amd64..."
GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/scantool-linux-amd64 $(CMD_DIR)/scantool-cli
@echo "Building for macOS amd64..."
GOOS=darwin GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/scantool-darwin-amd64 $(CMD_DIR)/scantool-cli
@echo "Building for macOS arm64..."
GOOS=darwin GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o $(DIST_DIR)/scantool-darwin-arm64 $(CMD_DIR)/scantool-cli
# Run CLI with example target
run-cli:
go run $(CMD_DIR)/scantool-cli alive --target 127.0.0.1 --quiet
# Run GUI
run-gui:
go run $(CMD_DIR)/scantool
# Run tests
test:
go test -v -race -coverprofile=coverage.out ./...
# Run tests with coverage report
test-cover: test
go tool cover -html=coverage.out -o coverage.html
# Run vet
vet:
go vet ./...
# Run static analysis
lint:
golangci-lint run ./...
# Fuzz test IP parser
fuzz:
go test -fuzz=FuzzParseTarget -fuzztime=30s ./internal/netutil/
# Format code
fmt:
go fmt ./...
gofumpt -w .
# Install CLI binary
install:
go install -ldflags="$(LDFLAGS)" $(CMD_DIR)/scantool-cli
# Clean build artifacts
clean:
rm -rf $(DIST_DIR)
rm -f coverage.out coverage.html
# Tidy dependencies
tidy:
go mod tidy
# Download dependencies
deps:
go mod download
# Generate and verify
verify: vet test
# Create release archives
release: build-all
cd $(DIST_DIR) && tar -czf scantool-linux-amd64.tar.gz scantool-linux-amd64
cd $(DIST_DIR) && tar -czf scantool-darwin-amd64.tar.gz scantool-darwin-amd64
cd $(DIST_DIR) && tar -czf scantool-darwin-arm64.tar.gz scantool-darwin-arm64
cd $(DIST_DIR) && zip scantool-windows-amd64.zip scantool-windows-amd64.exe