-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (60 loc) · 1.89 KB
/
Makefile
File metadata and controls
72 lines (60 loc) · 1.89 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
.PHONY: build install clean run test bench deps lint
# Binary name
BINARY_NAME=burnmail
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-s -w -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)
# Build the project (optimized)
build:
@echo "Building $(BINARY_NAME) $(VERSION)..."
go build -o $(BINARY_NAME) -ldflags="$(LDFLAGS)" -trimpath .
@echo "Binary size: $$(du -h $(BINARY_NAME) | cut -f1)"
# Build for development (with debug symbols)
build-dev:
go build -o $(BINARY_NAME) .
# Install to /usr/local/bin
install: build
sudo mv $(BINARY_NAME) /usr/local/bin/
# Build for multiple platforms
build-all:
@echo "Building for multiple platforms..."
GOOS=linux GOARCH=amd64 go build -o $(BINARY_NAME)-linux-amd64 -ldflags="$(LDFLAGS)" -trimpath .
GOOS=linux GOARCH=arm64 go build -o $(BINARY_NAME)-linux-arm64 -ldflags="$(LDFLAGS)" -trimpath .
GOOS=darwin GOARCH=amd64 go build -o $(BINARY_NAME)-darwin-amd64 -ldflags="$(LDFLAGS)" -trimpath .
GOOS=darwin GOARCH=arm64 go build -o $(BINARY_NAME)-darwin-arm64 -ldflags="$(LDFLAGS)" -trimpath .
GOOS=windows GOARCH=amd64 go build -o $(BINARY_NAME)-windows-amd64.exe -ldflags="$(LDFLAGS)" -trimpath .
@echo "Build complete. Binary sizes:"
@du -h $(BINARY_NAME)-*
# Clean build artifacts
clean:
go clean
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME)-*
rm -f ~/.burnmail-cache.json
# Run the application
run:
go run main.go
# Run tests
test:
go test -v -race -cover ./...
# Run benchmarks
bench:
go test -bench=. -benchmem ./...
# Run linter
lint:
go vet ./...
gofmt -s -w .
# Download dependencies
deps:
go mod download
go mod tidy
go mod verify
# Show binary info
info:
@echo "Version: $(VERSION)"
@echo "Build Time: $(BUILD_TIME)"
@if [ -f $(BINARY_NAME) ]; then \
echo "Binary: $(BINARY_NAME)"; \
ls -lh $(BINARY_NAME); \
file $(BINARY_NAME); \
fi