You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

103 lines
3.0 KiB

GO = go
APP_NAME = wormhole-client
VERSION = v1.0.0
LDFLAGS = -ldflags "-X main.version=$(VERSION) -X main.buildTime=$(shell date -u '+%Y-%m-%d_%H:%M:%S')"
.PHONY: all build clean deps test run install uninstall lint coverage fmt vet check dmg dmg-macos
all: clean deps build
deps:
$(GO) mod download
$(GO) mod tidy
build:
$(GO) build $(LDFLAGS) -o bin/$(APP_NAME) cmd/wormhole-client/main.go
# 格式化代码
fmt:
$(GO) fmt ./...
# 静态分析
vet:
$(GO) vet ./...
# 代码检查 (需要安装 golangci-lint)
lint:
@which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run
# 运行测试并生成覆盖率报告
coverage:
$(GO) test -v -race -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# 完整的代码检查
check: fmt vet lint test
run-http: build
./bin/$(APP_NAME) -config configs/client.yaml -mode http
run-global: build
sudo ./bin/$(APP_NAME) -config configs/client.yaml -mode global
run-transparent: build
sudo ./bin/$(APP_NAME) -config configs/client.yaml -mode transparent
test:
$(GO) test -v ./...
clean:
rm -rf bin/ coverage.out coverage.html
install: build
sudo cp bin/$(APP_NAME) /usr/local/bin/
uninstall:
sudo rm -f /usr/local/bin/$(APP_NAME)
# macOS DMG 安装包构建
dmg-macos:
@echo "🍎 Building macOS DMG installer..."
@if [ "$(shell uname)" != "Darwin" ]; then \
echo "❌ DMG building is only supported on macOS"; \
exit 1; \
fi
chmod +x scripts/build-dmg.sh
./scripts/build-dmg.sh
@echo "✅ macOS DMG installer created in build/ directory"
# 通用 DMG 构建 (检测平台)
dmg:
@if [ "$(shell uname)" = "Darwin" ]; then \
$(MAKE) dmg-macos; \
else \
echo "❌ DMG building is only supported on macOS"; \
echo " You are on: $(shell uname)"; \
echo "ℹ Please use a macOS system to build DMG installers"; \
exit 1; \
fi
help:
@echo "Available targets:"
@echo " build - Build the client binary"
@echo " fmt - Format Go code"
@echo " vet - Run Go vet"
@echo " lint - Run golangci-lint"
@echo " test - Run tests"
@echo " coverage - Run tests with coverage report"
@echo " check - Run all code quality checks"
@echo " run-http - Run HTTP proxy mode"
@echo " run-global - Run global proxy mode (needs sudo)"
@echo " run-transparent - Run transparent proxy mode (needs sudo)"
@echo " clean - Clean build artifacts"
@echo " deps - Download dependencies"
@echo " install - Install to /usr/local/bin"
@echo " uninstall - Remove from /usr/local/bin"
@echo " dmg - Build macOS DMG installer (macOS only)"
@echo " dmg-macos - Build macOS DMG installer (macOS only)"
@echo ""
@echo "GUI Access:"
@echo " After starting, access the web GUI at:"
@echo " http://127.0.0.1:8080/gui"