Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (102 loc) · 3.48 KB
/
Copy pathMakefile
File metadata and controls
122 lines (102 loc) · 3.48 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
122
.PHONY: build test clean install lint fmt vet help tft-venv tft-run
# Binary names
BINARIES = dpu-sim vmctl
# Build directory
BUILD_DIR = bin
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOTEST = $(GOCMD) test
GOCLEAN = $(GOCMD) clean
GOINSTALL = $(GOCMD) install
GOFMT = $(GOCMD) fmt
GOVET = $(GOCMD) vet
# Build all binaries
build: ## Build all binaries
@echo "Building binaries..."
@mkdir -p $(BUILD_DIR)
@for bin in $(BINARIES); do \
echo " Building $$bin..."; \
$(GOBUILD) -o $(BUILD_DIR)/$$bin ./cmd/$$bin; \
done
@echo "Build complete! Binaries are in $(BUILD_DIR)/"
# Run tests
test: ## Run tests
@echo "Running tests..."
$(GOTEST) -v -race -coverprofile=coverage.out ./...
@echo "Tests complete!"
# Run tests with coverage report
test-coverage: test ## Run tests and show coverage
$(GOCMD) tool cover -html=coverage.out
# Run integration tests (requires libvirt/docker)
test-integration: ## Run integration tests
$(GOTEST) -v -tags=integration ./...
# Clean build artifacts
clean: ## Clean build artifacts
@echo "Cleaning..."
$(GOCLEAN)
rm -rf $(BUILD_DIR)
rm -f coverage.out
@echo "Clean complete!"
# Install binaries to $GOPATH/bin
install: ## Install binaries to $GOPATH/bin
@echo "Installing binaries..."
@for bin in $(BINARIES); do \
echo " Installing $$bin..."; \
$(GOINSTALL) ./cmd/$$bin; \
done
@echo "Install complete!"
# Format code
fmt: ## Format code
@echo "Formatting code..."
$(GOFMT) ./...
@echo "Format complete!"
# Run go vet
vet: ## Run go vet
@echo "Running go vet..."
$(GOVET) ./...
@echo "Vet complete!"
# Run linter (requires golangci-lint)
lint: ## Run golangci-lint
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed. Install from: https://golangci-lint.run/usage/install/"; \
exit 1; \
fi
# Run all checks
check: fmt vet test ## Run all checks (fmt, vet, test)
# Cross-compile for multiple platforms
build-all: ## Cross-compile for Linux (amd64, arm64) and macOS
@echo "Cross-compiling binaries..."
@mkdir -p $(BUILD_DIR)
@for bin in $(BINARIES); do \
echo " Building $$bin for linux/amd64..."; \
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$$bin-linux-amd64 ./cmd/$$bin; \
echo " Building $$bin for linux/arm64..."; \
GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$$bin-linux-arm64 ./cmd/$$bin; \
echo " Building $$bin for darwin/amd64..."; \
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$$bin-darwin-amd64 ./cmd/$$bin; \
echo " Building $$bin for darwin/arm64..."; \
GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$$bin-darwin-arm64 ./cmd/$$bin; \
done
@echo "Cross-compile complete!"
# Download dependencies
deps: ## Download dependencies
@echo "Downloading dependencies..."
$(GOCMD) mod download
$(GOCMD) mod tidy
@echo "Dependencies downloaded!"
# Display help
help: ## Display this help message
@echo "DPU Simulator - Makefile commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Traffic flow tests (kubernetes-traffic-flow-tests auto-cloned; Kind or VM config)
CONFIG ?= config-kind-ovnk-offload.yaml
tft-venv: build ## Create TFT Python venv (needs Python >= 3.11; pass PYTHON= if needed)
./bin/dpu-sim tft venv --config "$(CONFIG)"
tft-run: build ## Run TFT via dpu-sim (set CONFIG=path/to.yaml; uses .tft-venv if present)
./bin/dpu-sim tft run --config "$(CONFIG)"
# Default target
.DEFAULT_GOAL := help