Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (53 loc) · 2.05 KB
/
Copy pathMakefile
File metadata and controls
62 lines (53 loc) · 2.05 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
# 版本信息
VERSION ?= $(shell git describe --tags --always)
LDFLAGS := -s -w -X 'gost-panel/internal/config.Version=$(VERSION)'
.PHONY: all build build-web build-server clean dev help release
# 默认目标
all: build
# 帮助信息
help:
@echo "Available commands:"
@echo " make build - Build both web and server"
@echo " make build-web - Build web frontend only"
@echo " make build-server - Build server backend only"
@echo " make dev - Run in development mode"
@echo " make run - Build web and run server"
@echo " make clean - Clean build artifacts"
@echo " make release - Build multi-platform release"
@echo ""
@echo "💡 Tip for Windows users: Run these commands in Git Bash or WSL for compatibility."
# 完整构建
build: build-web build-server
@echo "Build complete! Binary: gost-panel"
# 构建前端
build-web:
@echo "Building web..."
cd web && npm install && npm run build
@echo "Web build complete"
# 构建后端(包含嵌入的前端)
build-server:
@echo "Building server..."
go build -ldflags="$(LDFLAGS)" -o gost-panel cmd/server/main.go
@echo "Server build complete"
# 运行(构建前端并启动后端)
run: build-web
@echo "Starting server..."
go run cmd/server/main.go
# 构建多平台发布版本
release: build-web
@echo "Building release binaries..."
GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o gost-panel-linux-amd64 cmd/server/main.go
GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o gost-panel-linux-arm64 cmd/server/main.go
GOOS=darwin GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o gost-panel-darwin-amd64 cmd/server/main.go
GOOS=darwin GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o gost-panel-darwin-arm64 cmd/server/main.go
GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o gost-panel-windows-amd64.exe cmd/server/main.go
@echo "Release build complete"
# 清理构建产物
clean:
@echo "Cleaning artifacts..."
rm -f gost-panel
rm -f gost-panel.exe
rm -f main
rm -f main.exe
rm -rf internal/router/dist
rm -rf web/dist