-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
182 lines (157 loc) Β· 5.68 KB
/
Copy pathMakefile
File metadata and controls
182 lines (157 loc) Β· 5.68 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Warcraft Logs CLI Makefile
.PHONY: build clean install uninstall test help dev container-build container-run container-shell
# Binary name
BINARY_NAME=wclogs
# Build directory
BUILD_DIR=build
# Container settings
CONTAINER_NAME=wclogs-cli
IMAGE_NAME=wclogs-cli
CONTAINER_TOOL := $(shell which podman 2>/dev/null || which docker 2>/dev/null || echo "container-tool-not-found")
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOMOD=$(GOCMD) mod
# Default target
all: build
# Build the binary
build:
@echo "π¨ Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v
# Build for current directory (quick build)
build-local:
@echo "π¨ Building $(BINARY_NAME) in current directory..."
$(GOBUILD) -o $(BINARY_NAME) -v
# Install dependencies
deps:
@echo "π¦ Installing dependencies..."
$(GOMOD) tidy
$(GOMOD) download
# Run tests
test:
@echo "π§ͺ Running tests..."
$(GOTEST) -v ./...
# Clean build artifacts
clean:
@echo "π§Ή Cleaning..."
$(GOCLEAN)
rm -rf $(BUILD_DIR)
rm -f $(BINARY_NAME)
# Install globally (Unix/Linux/macOS)
install: build
@echo "π¦ Installing $(BINARY_NAME) to /usr/local/bin..."
@if [ "$$(id -u)" -ne 0 ]; then \
echo "β οΈ Installing to /usr/local/bin requires sudo"; \
sudo cp $(BUILD_DIR)/$(BINARY_NAME) /usr/local/bin/; \
else \
cp $(BUILD_DIR)/$(BINARY_NAME) /usr/local/bin/; \
fi
@echo "β
$(BINARY_NAME) installed successfully!"
@echo "π You can now run '$(BINARY_NAME)' from anywhere"
# Uninstall from system
uninstall:
@echo "ποΈ Removing $(BINARY_NAME) from /usr/local/bin..."
@if [ "$$(id -u)" -ne 0 ]; then \
echo "β οΈ Removing from /usr/local/bin requires sudo"; \
sudo rm -f /usr/local/bin/$(BINARY_NAME); \
else \
rm -f /usr/local/bin/$(BINARY_NAME); \
fi
@echo "β
$(BINARY_NAME) uninstalled successfully!"
# Development mode - build and run with config
dev: build-local
@echo "π Starting development mode..."
@echo "π Run './$(BINARY_NAME) config' to set up credentials first"
@echo "π‘ Try: './$(BINARY_NAME) --help'"
@echo "π‘ Example: './$(BINARY_NAME) damage ABC123 last'"
# Quick setup for new users
setup: deps build
@echo "π― Setup complete! Next steps:"
@echo "1οΈβ£ Get API credentials from: https://www.warcraftlogs.com/api/clients"
@echo "2οΈβ£ Run: ./$(BUILD_DIR)/$(BINARY_NAME) config"
@echo "3οΈβ£ Start analyzing: ./$(BUILD_DIR)/$(BINARY_NAME) --help"
@echo ""
@echo "π‘ To install globally: make install"
# Build for multiple platforms
build-all: clean
@echo "π Building for multiple platforms..."
@mkdir -p $(BUILD_DIR)
# Linux
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64
# macOS
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64
GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64
# Windows
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe
@echo "β
Built for all platforms in $(BUILD_DIR)/"
# Container targets
container-build:
@if [ "$(CONTAINER_TOOL)" = "container-tool-not-found" ]; then \
echo "β Neither podman nor docker found. Please install one of them."; \
exit 1; \
fi
@echo "π³ Building container image with $(notdir $(CONTAINER_TOOL))..."
$(CONTAINER_TOOL) build -t $(IMAGE_NAME) .
container-run: container-build
@echo "π Running $(BINARY_NAME) in container with $(notdir $(CONTAINER_TOOL))..."
@echo "π‘ Your ~/.wclogs.yaml will be mounted for config (if it exists)"
@if [ -f "$(HOME)/.wclogs.yaml" ]; then \
$(CONTAINER_TOOL) run --rm -it \
-v $(HOME)/.wclogs.yaml:/home/wclogs/.wclogs.yaml:ro \
$(IMAGE_NAME) $(ARGS); \
else \
$(CONTAINER_TOOL) run --rm -it $(IMAGE_NAME) $(ARGS); \
fi
container-shell: container-build
@echo "π Opening shell in container with $(notdir $(CONTAINER_TOOL))..."
@if [ -f "$(HOME)/.wclogs.yaml" ]; then \
$(CONTAINER_TOOL) run --rm -it \
-v $(HOME)/.wclogs.yaml:/home/wclogs/.wclogs.yaml:ro \
--entrypoint /bin/sh \
$(IMAGE_NAME); \
else \
$(CONTAINER_TOOL) run --rm -it \
--entrypoint /bin/sh \
$(IMAGE_NAME); \
fi
container-clean:
@if [ "$(CONTAINER_TOOL)" = "container-tool-not-found" ]; then \
echo "β Neither podman nor docker found."; \
exit 1; \
fi
@echo "π§Ή Cleaning container images with $(notdir $(CONTAINER_TOOL))..."
$(CONTAINER_TOOL) rmi $(IMAGE_NAME) 2>/dev/null || true
# Show help
help:
@echo "π‘οΈ Warcraft Logs CLI - Build Commands"
@echo ""
@echo "π Native Build Targets:"
@echo " build Build binary to $(BUILD_DIR)/"
@echo " build-local Build binary to current directory"
@echo " build-all Build for multiple platforms"
@echo " install Install binary globally (requires sudo)"
@echo " uninstall Remove binary from system"
@echo " deps Install Go dependencies"
@echo " test Run all tests"
@echo " clean Remove build artifacts"
@echo " dev Quick development setup"
@echo " setup Complete setup for new users"
@echo ""
@echo "π³ Container Targets (using $(notdir $(CONTAINER_TOOL))):"
@echo " container-build Build container image"
@echo " container-run Run wclogs in container"
@echo " container-shell Open shell in container"
@echo " container-clean Remove container images"
@echo ""
@echo "π Quick start:"
@echo " make setup # Native setup"
@echo " make container-run # Container setup"
@echo ""
@echo "π Container Examples:"
@echo " make container-run ARGS='config'"
@echo " make container-run ARGS='config'"
@echo " make container-run ARGS='damage ABC123 5'"
@echo " make container-run ARGS='damage ABC123 last'"