-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
75 lines (60 loc) · 1.66 KB
/
makefile
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
# Makefile for the GitSyncer Go application
# Go parameters
GO := go
APP_NAME := Hermes
SRC_DIR := ./cmd
BIN_DIR := bin
BUILD_DIR := build
.PHONY: all build run clean test fmt lint deps build-linux build-windows build-darwin build-all
all: build
# Build the application
build:
@echo "Building $(APP_NAME)..."
@mkdir -p $(BIN_DIR)
$(GO) build -o $(BIN_DIR)/$(APP_NAME) $(SRC_DIR)/main.go
# Run the application
run: build
@echo "Running $(APP_NAME)..."
./$(BIN_DIR)/$(APP_NAME)
# Clean build artifacts
clean:
@echo "Cleaning up..."
@rm -rf $(BIN_DIR)
@rm -rf $(BUILD_DIR)
# Run tests
test:
@echo "Running tests..."
$(GO) test ./...
# Install dependencies
deps:
@echo "Installing dependencies..."
$(GO) mod download
# Format code
fmt:
@echo "Formatting code..."
$(GO) fmt ./...
# Lint code
lint:
@echo "Linting code..."
@golangci-lint run || echo "Please install golangci-lint for linting"
# Generate code (if needed)
generate:
@echo "Generating code..."
$(GO) generate ./...
# Build for Linux
build-linux:
@echo "Building $(APP_NAME) for Linux..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build -o $(BUILD_DIR)/$(APP_NAME)_linux_amd64 $(SRC_DIR)/main.go
# Build for Windows
build-windows:
@echo "Building $(APP_NAME) for Windows..."
@mkdir -p $(BUILD_DIR)
GOOS=windows GOARCH=amd64 $(GO) build -o $(BUILD_DIR)/$(APP_NAME)_windows_amd64.exe $(SRC_DIR)/main.go
# Build for macOS
build-darwin:
@echo "Building $(APP_NAME) for macOS..."
@mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=amd64 $(GO) build -o $(BUILD_DIR)/$(APP_NAME)_darwin_amd64 $(SRC_DIR)/main.go
# Cross-compile for all platforms
build-all: build-linux build-windows build-darwin