-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (73 loc) · 2.11 KB
/
Makefile
File metadata and controls
86 lines (73 loc) · 2.11 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
.PHONY: build clean install run test lint lint-fix fmt deps help
# Binary name
BINARY_NAME=createos
# Build directory
BUILD_DIR=bin
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
# Build the project
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v
# Build for multiple platforms
build-all:
@echo "Building for multiple platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64
GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64
GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe
# Install the binary to $GOPATH/bin
install:
@echo "Installing $(BINARY_NAME)..."
$(GOCMD) install
# Run the application
run:
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v
./$(BUILD_DIR)/$(BINARY_NAME)
# Run tests
test:
$(GOTEST) -v ./...
# Clean build files
clean:
@echo "Cleaning..."
$(GOCLEAN)
@rm -rf $(BUILD_DIR)
# Download dependencies
deps:
@echo "Downloading dependencies..."
$(GOMOD) download
$(GOMOD) tidy
# Format code
fmt:
@echo "Formatting code..."
$(GOCMD) fmt ./...
# Run linter
lint:
@echo "Running linter..."
golangci-lint run ./...
# Run linter and auto-fix issues
lint-fix:
@echo "Running linter with auto-fix..."
golangci-lint run --fix ./...
# Show help
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " build-all - Build for multiple platforms"
@echo " install - Install the binary to GOPATH/bin"
@echo " run - Build and run the application"
@echo " test - Run tests"
@echo " clean - Remove build artifacts"
@echo " deps - Download and tidy dependencies"
@echo " fmt - Format code"
@echo " lint - Run linter"
@echo " lint-fix - Run linter and auto-fix issues"
@echo " help - Show this help message"