-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (102 loc) · 3.95 KB
/
Makefile
File metadata and controls
121 lines (102 loc) · 3.95 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
# EZFT - Easy File Transfer Tool Makefile
# Project information
PROJECT_NAME := ezft
MODULE_NAME := github.com/easzlab/ezft
BUILD_TIME := $(shell date +%Y-%m-%d\ %H:%M:%S)
BUILD_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
# Build configuration
BUILD_DIR := build
MAIN_FILE := cmd/main.go
BINARY_NAME := $(PROJECT_NAME)
BINARY_PATH := $(BUILD_DIR)/$(BINARY_NAME)
# Go configuration
GO := go
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
# Linker flags for version information
LDFLAGS := -ldflags "-X '$(MODULE_NAME)/internal/config.BuildTime=$(BUILD_TIME)' \
-X '$(MODULE_NAME)/internal/config.BuildCommit=$(BUILD_COMMIT)' \
-X '$(MODULE_NAME)/internal/config.BuildBranch=$(BUILD_BRANCH)' \
-s -w -extldflags -static"
# Default target
.PHONY: all
all: clean build
.PHONY: help
help: ## show help
@echo "Available targets: "
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: build
build: ## build the binary
@echo "Building $(PROJECT_NAME) v$(VERSION)..."
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 $(GO) build $(LDFLAGS) -o $(BINARY_PATH) $(MAIN_FILE)
@echo "✓ Build completed: $(BINARY_PATH)"
.PHONY: build-dev
build-dev: ## build the binary with debug info
@echo "Building $(PROJECT_NAME) for development..."
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 $(GO) build -race -o $(BINARY_PATH) $(MAIN_FILE)
@echo "✓ Development build completed: $(BINARY_PATH)"
.PHONY: build-linux
build-linux: ## build the binary for Linux
@echo "Building for Linux..."
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(MAIN_FILE)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 $(MAIN_FILE)
@echo "✓ Linux build completed"
.PHONY: build-windows
build-windows: ## build the binary for Windows
@echo "Building for Windows..."
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(MAIN_FILE)
@echo "✓ Windows build completed"
.PHONY: build-darwin
build-darwin: ## build the binary for macOS
@echo "Building for macOS..."
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 $(MAIN_FILE)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 $(MAIN_FILE)
@echo "✓ macOS builds completed"
.PHONY: build-all
build-all: build-linux build-windows build-darwin ## build the binary for all platforms
@echo "✓ All platform builds completed"
.PHONY: test
test: ## run tests
@echo "Running tests..."
$(GO) test -v ./...
@echo "✓ Tests completed"
.PHONY: test-cov
test-cov: ## run tests with coverage
@echo "Running tests with coverage..."
$(GO) test -v -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "✓ Coverage report generated: coverage.html"
.PHONY: e2e
e2e: build ## run end-to-end tests
@echo "Running end-to-end tests..."
@bash tests/e2e_test.sh
@echo "✓ End-to-end tests completed"
.PHONY: bench
bench: ## run benchmarks
@echo "Running benchmarks..."
$(GO) test -bench=. -benchmem tests/benchmark/basic_bench_test.go
$(GO) test -bench=. -benchmem tests/benchmark/concurrent_bench_test.go
@echo "✓ Benchmarks completed"
.PHONY: deps
deps: ## download dependencies
@echo "Downloading dependencies..."
$(GO) mod download
@echo "✓ Dependencies downloaded"
.PHONY: clean
clean: ## clean build artifacts
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@rm -f coverage.out coverage.html
@echo "✓ Clean completed"
.PHONY: update
update: ## update dependencies
@echo "Updating dependencies..."
@go get -u ./...
@go mod tidy
@echo "✓ Dependencies updated"