-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (77 loc) · 2.4 KB
/
Makefile
File metadata and controls
95 lines (77 loc) · 2.4 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
87
88
89
90
91
92
93
94
95
.PHONY: build build-all clean install test
# Binary name
BINARY_NAME=now-sc
VERSION?=1.0.0
# Build directory
BUILD_DIR=bin
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
# Main package path
MAIN_PATH=./cmd/now-sc
# Build the binary for current platform
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v $(MAIN_PATH)
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
# Build for all platforms
build-all: clean
@echo "Building for all platforms..."
@mkdir -p $(BUILD_DIR)
# Linux AMD64
@echo "Building for Linux AMD64..."
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 -v $(MAIN_PATH)
# Linux ARM64
@echo "Building for Linux ARM64..."
GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 -v $(MAIN_PATH)
# macOS AMD64
@echo "Building for macOS AMD64..."
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 -v $(MAIN_PATH)
# macOS ARM64 (Apple Silicon)
@echo "Building for macOS ARM64..."
GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 -v $(MAIN_PATH)
# Windows AMD64
@echo "Building for Windows AMD64..."
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe -v $(MAIN_PATH)
@echo "Build complete for all platforms!"
@ls -lh $(BUILD_DIR)
# Clean build artifacts
clean:
@echo "Cleaning..."
@$(GOCLEAN)
@rm -rf $(BUILD_DIR)
@echo "Clean complete!"
# Install dependencies
deps:
@echo "Installing dependencies..."
@$(GOMOD) download
@$(GOMOD) tidy
@echo "Dependencies installed!"
# Install binary to GOPATH/bin
install: build
@echo "Installing $(BINARY_NAME)..."
@cp $(BUILD_DIR)/$(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
@echo "Installation complete!"
# Run tests
test:
@echo "Running tests..."
@$(GOTEST) -v ./...
# Run the application
run:
@$(GOCMD) run $(MAIN_PATH)
# Display help
help:
@echo "Available targets:"
@echo " build - Build binary for current platform"
@echo " build-all - Build binaries for all platforms"
@echo " clean - Remove build artifacts"
@echo " deps - Install dependencies"
@echo " install - Install binary to GOPATH/bin"
@echo " test - Run tests"
@echo " run - Run the application"
@echo " help - Display this help message"