-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (67 loc) 路 2.07 KB
/
Copy pathMakefile
File metadata and controls
83 lines (67 loc) 路 2.07 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
.PHONY: build clean install test fmt lint run help
# Variables
BINARY_NAME=drim
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.BuildTime=${BUILD_TIME}"
# Default target
all: build
# Build the binary
build:
@echo "Building ${BINARY_NAME}..."
go build ${LDFLAGS} -o ${BINARY_NAME} .
@echo "Build complete: ${BINARY_NAME}"
# Build for all platforms
build-all: clean
@echo "Building for all platforms..."
GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY_NAME}_Linux_x86_64 .
GOOS=linux GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY_NAME}_Linux_arm64 .
GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY_NAME}_Darwin_x86_64 .
GOOS=darwin GOARCH=arm64 go build ${LDFLAGS} -o bin/${BINARY_NAME}_Darwin_arm64 .
GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o bin/${BINARY_NAME}_Windows_x86_64.exe .
@echo "All builds complete in bin/"
# Install the binary
install: build
@echo "Installing ${BINARY_NAME}..."
sudo cp ${BINARY_NAME} /usr/local/bin/
@echo "Installed to /usr/local/bin/${BINARY_NAME}"
# Clean build artifacts
clean:
@echo "Cleaning..."
rm -f ${BINARY_NAME}
rm -rf bin/
go clean
@echo "Clean complete"
# Run tests
test:
@echo "Running tests..."
go test -v ./...
# Format code
fmt:
@echo "Formatting code..."
go fmt ./...
# Run linter
lint:
@echo "Running linter..."
golangci-lint run ./...
# Run the application
run: build
./${BINARY_NAME}
# Download dependencies
deps:
@echo "Downloading dependencies..."
go mod download
go mod tidy
# Help
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " build-all - Build for all platforms"
@echo " install - Install the binary to /usr/local/bin"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " fmt - Format code"
@echo " lint - Run linter"
@echo " run - Build and run"
@echo " deps - Download dependencies"
@echo " help - Show this help message"