完成一个简易的全局skill、command管理器
This commit is contained in:
92
manager/Makefile
Normal file
92
manager/Makefile
Normal file
@@ -0,0 +1,92 @@
|
||||
.PHONY: all build build-all build-macos build-windows test clean install lint
|
||||
|
||||
# 变量
|
||||
BINARY_NAME := skillmgr
|
||||
BUILD_DIR := bin
|
||||
MAIN_PACKAGE := ./cmd/skillmgr
|
||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
||||
LDFLAGS := -ldflags "-s -w -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
|
||||
|
||||
# 默认目标
|
||||
all: build
|
||||
|
||||
# 构建当前平台
|
||||
build:
|
||||
@echo "=== 构建 $(BINARY_NAME) ==="
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PACKAGE)
|
||||
@echo "构建完成: $(BUILD_DIR)/$(BINARY_NAME)"
|
||||
|
||||
# 构建所有平台
|
||||
build-all: build-macos build-windows
|
||||
@echo ""
|
||||
@echo "=== 所有平台构建完成 ==="
|
||||
@find $(BUILD_DIR) -type f -name "$(BINARY_NAME)*" | sort
|
||||
|
||||
# 构建 macOS (Intel + Apple Silicon)
|
||||
build-macos:
|
||||
@echo "=== 构建 macOS (amd64) ==="
|
||||
@mkdir -p $(BUILD_DIR)/darwin-amd64
|
||||
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/darwin-amd64/$(BINARY_NAME) $(MAIN_PACKAGE)
|
||||
@echo "构建完成: $(BUILD_DIR)/darwin-amd64/$(BINARY_NAME)"
|
||||
@echo ""
|
||||
@echo "=== 构建 macOS (arm64) ==="
|
||||
@mkdir -p $(BUILD_DIR)/darwin-arm64
|
||||
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/darwin-arm64/$(BINARY_NAME) $(MAIN_PACKAGE)
|
||||
@echo "构建完成: $(BUILD_DIR)/darwin-arm64/$(BINARY_NAME)"
|
||||
|
||||
# 构建 Windows
|
||||
build-windows:
|
||||
@echo "=== 构建 Windows (amd64) ==="
|
||||
@mkdir -p $(BUILD_DIR)/windows-amd64
|
||||
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe $(MAIN_PACKAGE)
|
||||
@echo "构建完成: $(BUILD_DIR)/windows-amd64/$(BINARY_NAME).exe"
|
||||
|
||||
# 构建 Linux (可选)
|
||||
build-linux:
|
||||
@echo "=== 构建 Linux (amd64) ==="
|
||||
@mkdir -p $(BUILD_DIR)/linux-amd64
|
||||
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/linux-amd64/$(BINARY_NAME) $(MAIN_PACKAGE)
|
||||
@echo "构建完成: $(BUILD_DIR)/linux-amd64/$(BINARY_NAME)"
|
||||
|
||||
# 测试
|
||||
test:
|
||||
@echo "=== 运行测试 ==="
|
||||
./scripts/test.sh
|
||||
|
||||
# 单元测试(不使用脚本)
|
||||
test-unit:
|
||||
go test -v ./...
|
||||
|
||||
# 覆盖率测试
|
||||
test-coverage:
|
||||
go test -coverprofile=coverage.out ./...
|
||||
go tool cover -html=coverage.out -o coverage.html
|
||||
@echo "覆盖率报告: coverage.html"
|
||||
|
||||
# 清理
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
rm -f coverage.out coverage.html
|
||||
|
||||
# 安装到 $GOPATH/bin
|
||||
install: build
|
||||
cp $(BUILD_DIR)/$(BINARY_NAME) $(GOPATH)/bin/
|
||||
|
||||
# 代码检查
|
||||
lint:
|
||||
golangci-lint run ./...
|
||||
|
||||
# 格式化
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
# 依赖
|
||||
deps:
|
||||
go mod download
|
||||
go mod tidy
|
||||
|
||||
# 沙盒环境
|
||||
sandbox:
|
||||
./scripts/sandbox.sh
|
||||
Reference in New Issue
Block a user