feat: 初始提交 - Code Server Bridge完整实现
- OAuth认证系统(Gitea + Lua扩展) - Git自动化操作(本地/SSH远程) - 实时进度WebSocket推送 - 现代化Tab界面UI - Cobra CLI命令行(init/version/serve) - 完整构建系统(Makefile + Taskfile) - UPX压缩支持(体积减少70%)
This commit is contained in:
118
Makefile
Normal file
118
Makefile
Normal file
@@ -0,0 +1,118 @@
|
||||
.PHONY: all build build-linux build-windows clean dev help package upx
|
||||
|
||||
APP_NAME = code-server-bridge
|
||||
ENTRY = ./cmd/server
|
||||
OUTPUT_DIR = bin
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
BUILD_TIME = $(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
||||
GIT_COMMIT = $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
||||
|
||||
# Go build flags with version injection
|
||||
LDFLAGS = -ldflags "-s -w \
|
||||
-X 'main.Version=$(VERSION)' \
|
||||
-X 'main.BuildTime=$(BUILD_TIME)' \
|
||||
-X 'main.GitCommit=$(GIT_COMMIT)'"
|
||||
|
||||
# UPX settings
|
||||
UPX = upx
|
||||
UPX_FLAGS = --best --lzma
|
||||
|
||||
# Platforms
|
||||
LINUX_ARCHS = amd64 arm64
|
||||
WINDOWS_ARCHS = amd64
|
||||
|
||||
all: clean build-all upx
|
||||
|
||||
# Build for current platform
|
||||
build:
|
||||
@echo "Building $(APP_NAME) for current platform..."
|
||||
go build $(LDFLAGS) -o $(APP_NAME) $(ENTRY)
|
||||
@echo "Build complete: $(APP_NAME)"
|
||||
|
||||
# Build for Linux platforms
|
||||
build-linux:
|
||||
@echo "Building for Linux platforms..."
|
||||
@mkdir -p $(OUTPUT_DIR)
|
||||
@for arch in $(LINUX_ARCHS); do \
|
||||
echo "Building linux/$$arch..."; \
|
||||
GOOS=linux GOARCH=$$arch go build $(LDFLAGS) -o $(OUTPUT_DIR)/$(APP_NAME)-linux-$$arch $(ENTRY); \
|
||||
done
|
||||
@echo "Linux builds complete"
|
||||
|
||||
# Build for Windows platforms
|
||||
build-windows:
|
||||
@echo "Building for Windows platforms..."
|
||||
@mkdir -p $(OUTPUT_DIR)
|
||||
@for arch in $(WINDOWS_ARCHS); do \
|
||||
echo "Building windows/$$arch..."; \
|
||||
GOOS=windows GOARCH=$$arch go build $(LDFLAGS) -o $(OUTPUT_DIR)/$(APP_NAME)-windows-$$arch.exe $(ENTRY); \
|
||||
done
|
||||
@echo "Windows builds complete"
|
||||
|
||||
# Build for all platforms
|
||||
build-all: build-linux build-windows
|
||||
@echo "All platform builds complete"
|
||||
|
||||
# Package release
|
||||
package: build-all upx
|
||||
@echo "Packaging releases..."
|
||||
@mkdir -p releases
|
||||
@for arch in $(LINUX_ARCHS); do \
|
||||
tar -czf releases/$(APP_NAME)-$(VERSION)-linux-$$arch.tar.gz -C $(OUTPUT_DIR) $(APP_NAME)-linux-$$arch; \
|
||||
done
|
||||
@for arch in $(WINDOWS_ARCHS); do \
|
||||
cd $(OUTPUT_DIR) && zip -q ../releases/$(APP_NAME)-$(VERSION)-windows-$$arch.zip $(APP_NAME)-windows-$$arch.exe && cd ..; \
|
||||
done
|
||||
@echo "Packaging complete: releases/"
|
||||
|
||||
# Development mode
|
||||
dev:
|
||||
@echo "Running in development mode..."
|
||||
go run $(ENTRY)
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
@echo "Cleaning build artifacts..."
|
||||
@rm -rf $(OUTPUT_DIR) releases $(APP_NAME) $(APP_NAME).exe
|
||||
@echo "Clean complete"
|
||||
|
||||
# Run tests
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
go test -v ./...
|
||||
|
||||
# Install dependencies
|
||||
deps:
|
||||
@echo "Installing dependencies..."
|
||||
go mod download
|
||||
go mod tidy
|
||||
|
||||
# UPX Compression
|
||||
upx:
|
||||
@echo "Compressing binaries with UPX..."
|
||||
@if command -v $(UPX) > /dev/null 2>&1; then \
|
||||
for file in $(OUTPUT_DIR)/*; do \
|
||||
if [ -f "$$file" ]; then \
|
||||
echo "Compressing $$file..."; \
|
||||
$(UPX) $(UPX_FLAGS) "$$file" 2>/dev/null || echo "⚠️ UPX压缩失败: $$file"; \
|
||||
fi; \
|
||||
done; \
|
||||
echo "✅ UPX compression complete"; \
|
||||
else \
|
||||
echo "⚠️ UPX not found, skipping compression"; \
|
||||
echo "Install UPX: https://upx.github.io/"; \
|
||||
fi
|
||||
|
||||
# Display help
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@echo " make build - Build for current platform"
|
||||
@echo " make build-linux - Build for Linux (amd64, arm64)"
|
||||
@echo " make build-windows - Build for Windows (amd64)"
|
||||
@echo " make build-all - Build for all platforms"
|
||||
@echo " make upx - Compress binaries with UPX"
|
||||
@echo " make package - Build, compress and package releases"
|
||||
@echo " make dev - Run in development mode"
|
||||
@echo " make test - Run tests"
|
||||
@echo " make deps - Install dependencies"
|
||||
@echo " make clean - Clean build artifacts"
|
||||
Reference in New Issue
Block a user