Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (58 loc) · 1.69 KB
/
Copy pathMakefile
File metadata and controls
71 lines (58 loc) · 1.69 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
.PHONY: build build-server build-all clean test run
# Variables
BINARY_NAME=fx
VERSION=0.1.0
BUILD_DIR=dist
# Build flags
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
# Default target
all: build
# Build for current platform
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p bin
@go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/fx
build-server:
@echo "Building $(BINARY_NAME) server..."
@mkdir -p bin
@go build $(LDFLAGS) -o bin/$(BINARY_NAME)-server ./cmd/server
# Build for all platforms
build-all: clean
@echo "Building for all platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/fx
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/fx
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/fx
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/fx
@echo "Build complete! Binaries in $(BUILD_DIR)/"
# Clean
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR) bin/ $(BINARY_NAME) $(BINARY_NAME)-server server
@go clean
@echo "Clean complete!"
# Run tests
test:
@echo "Running tests..."
@go test -v -race -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
@echo "Tests complete! Coverage report: coverage.html"
# Run
run:
@go run ./cmd/fx
# Install dependencies
deps:
@echo "Downloading dependencies..."
@go mod download
@go mod tidy
@echo "Dependencies installed!"
# Format code
fmt:
@echo "Formatting code..."
@gofmt -s -w .
@echo "Format complete!"
# Lint
lint:
@echo "Running linter..."
@golangci-lint run
@echo "Lint complete!"