Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (63 loc) · 1.54 KB
/
Copy pathMakefile
File metadata and controls
84 lines (63 loc) · 1.54 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
# Makefile for bd_bot project
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
GOFMT=gofmt
# Directories
CMD_DIR=./cmd/app
INTERNAL_DIR=./internal
BUILD_DIR=./build
# Binary output
BINARY_NAME=bd_bot
BINARY_LINUX=$(BINARY_NAME)_linux
BINARY_DARWIN=$(BINARY_NAME)_darwin
BINARY_WIN=$(BINARY_NAME)_windows.exe
# Packages
PKG=5mdt/bd_bot/...
# Ensure build directory exists
$(shell mkdir -p $(BUILD_DIR))
.PHONY: all test vet fmt clean build build-linux build-darwin build-windows build-all deps pre-commit docker-build docker-run ci
# Default target
all: fmt vet test build
# Run tests
test:
$(GOTEST) $(PKG)
# Run code quality checks
vet:
$(GOVET) $(PKG)
# Format code
fmt:
$(GOFMT) -w .
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR)
# Install dependencies
deps:
$(GOCMD) mod tidy
$(GOCMD) mod download
# Run pre-commit hooks
pre-commit:
pre-commit run --all-files
# Build for current platform
build:
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_DIR)
# Build for Linux
build-linux:
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_LINUX) $(CMD_DIR)
# Build for macOS
build-darwin:
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_DARWIN) $(CMD_DIR)
# Build for Windows
build-windows:
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_WIN) $(CMD_DIR)
# Build for all platforms
build-all: build-linux build-darwin build-windows
# Docker-related tasks
docker-build:
docker build -t bd_bot .
docker-run:
docker run -it --rm bd_bot
# CI tasks
ci: deps fmt vet test build