-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (66 loc) · 2.26 KB
/
Makefile
File metadata and controls
84 lines (66 loc) · 2.26 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
# AAMI Makefile
# Version information
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Build variables
BINARY_NAME := aami
BUILD_DIR := ./bin
CMD_DIR := ./cmd/aami
# Go settings
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
# LDFLAGS
LDFLAGS := -ldflags "-X github.com/fregataa/aami/internal/cli.Version=$(VERSION) \
-X github.com/fregataa/aami/internal/cli.Commit=$(COMMIT) \
-X github.com/fregataa/aami/internal/cli.BuildDate=$(DATE)"
.PHONY: all build clean test lint install help
all: build
## build: Build the binary
build:
@echo "Building $(BINARY_NAME) $(VERSION)..."
@mkdir -p $(BUILD_DIR)
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_DIR)
@echo "Built: $(BUILD_DIR)/$(BINARY_NAME)"
## build-all: Build for multiple platforms
build-all: build-linux build-darwin
build-linux:
@echo "Building for Linux..."
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(CMD_DIR)
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 $(CMD_DIR)
build-darwin:
@echo "Building for macOS..."
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 $(CMD_DIR)
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 $(CMD_DIR)
## clean: Remove build artifacts
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
@go clean
## test: Run tests
test:
go test -v ./...
## test-coverage: Run tests with coverage
test-coverage:
go test -v -cover -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
## lint: Run linter
lint:
golangci-lint run
## install: Install to /usr/local/bin
install: build
@echo "Installing to /usr/local/bin/$(BINARY_NAME)..."
@sudo cp $(BUILD_DIR)/$(BINARY_NAME) /usr/local/bin/$(BINARY_NAME)
@echo "Installed!"
## deps: Download dependencies
deps:
go mod download
go mod tidy
## help: Show this help message
help:
@echo "AAMI - AI Accelerator Monitoring Infrastructure"
@echo ""
@echo "Usage:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed 's/^/ /'
# Default target
.DEFAULT_GOAL := help