Files
BlueArchiveToolkit/Makefile
T
nyaKazuha 13b0bd5b45
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s
fix(release):完善当前分发证明与质量门禁
2026-09-14 06:39:47 +08:00

203 lines
7.1 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
.PHONY: help build build-ffi test clean check check-docs format fmt lint ci ci-check install dev docker-build docker-up docker-down official-smoke bat-api-local-live-smoke build-go build-go-api build-go-cli test-go test-go-api test-go-ffi test-go-all
# 默认目标
.DEFAULT_GOAL := help
# 颜色输出
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
NC := \033[0m # No Color
help: ## 显示帮助信息
@echo "$(BLUE)BlueArchive Toolkit - Makefile 命令$(NC)"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}'
# ============================================================================
# 构建相关
# ============================================================================
build: build-rust build-go ## 构建所有组件
build-rust: ## 构建 Rust 组件
@echo "$(BLUE)Building Rust workspace...$(NC)"
cargo build --release --workspace
build-ffi: ## 构建 bat-ffi release 库(cgo 链接依赖)
@echo "$(BLUE)Building bat-ffi (release)...$(NC)"
cargo build --release -p bat-ffi
build-go: build-go-api ## 构建 Go 默认产物(bat-api bootstrap/分发;同步 CLI 请用 Rust bat
build-go-api: ## 构建 bat-api(资源 bootstrap/分发 HTTP,无 FFI
@echo "$(BLUE)Building bat-api (resource bootstrap + distribution)...$(NC)"
@mkdir -p bin
go build -o bin/bat-api ./cmd/bat-api
build-go-cli: build-ffi ## 构建试验性 Go CLI → bin/bat-go(禁止命名为 bat
@echo "$(BLUE)Building experimental Go CLI as bin/bat-go...$(NC)"
@mkdir -p bin
@if [ -f cmd/bat/main.go ]; then \
go build -o bin/bat-go ./cmd/bat; \
else \
echo "$(YELLOW)experimental cmd/bat missing, skipping...$(NC)"; \
fi
install: build-go-api ## 安装 bat-api 到 GOPATH/bin(不安装名为 bat 的 Go 二进制)
@echo "$(BLUE)Installing bat-api...$(NC)"
go install ./cmd/bat-api
# ============================================================================
# 测试相关
# ============================================================================
test: test-rust test-go ## 运行所有测试
test-rust: ## 运行 Rust 测试
@echo "$(BLUE)Running Rust tests...$(NC)"
cargo test --workspace
test-go: test-go-api ## 默认 Go 门禁(无 FFI;见 GO_STATUS.md
test-go-api: ## 纯 Go 测试:internal/api + backendrpc
@echo "$(BLUE)Running pure Go tests (api + backendrpc)...$(NC)"
go test ./internal/api/... ./internal/backendrpc/...
test-go-ffi: build-ffi ## 含 FFI/试验 CLI 的 Go 测试
@echo "$(BLUE)Running Go tests including FFI packages...$(NC)"
go test ./...
test-go-all: test-go-api test-go-ffi ## 全部 Go 测试
bench: ## 运行性能基准测试
@echo "$(BLUE)Running benchmarks...$(NC)"
cargo bench --workspace
go test -bench=. -benchmem ./...
official-smoke: ## 运行真实官方全量拉取 smoke(默认写入 /tmp 隔离目录)
@echo "$(BLUE)Running official full pull smoke...$(NC)"
./scripts/official-full-pull-smoke.sh
bat-api-local-live-smoke: ## 在同一临时主机环境联调 Rust bat.sock 与 Go bat-api
@echo "$(BLUE)Running local bat/bat-api live smoke...$(NC)"
./scripts/bat-api-local-live-smoke.sh
# ============================================================================
# 代码质量
# ============================================================================
check: check-rust check-go check-docs ## 检查代码和状态文档(不编译)
check-rust: ## 检查 Rust 代码
@echo "$(BLUE)Checking Rust code...$(NC)"
cargo check --workspace
check-go: ## 检查 Go 代码
@echo "$(BLUE)Checking Go code...$(NC)"
go vet ./...
check-docs: ## 检查权威状态文档与占位目录声明
@echo "$(BLUE)Checking documentation status claims...$(NC)"
bash scripts/check-doc-status.sh
fmt: fmt-rust fmt-go ## 格式化所有代码
format: fmt ## 格式化所有代码(会修改工作树)
fmt-rust: ## 格式化 Rust 代码
@echo "$(BLUE)Formatting Rust code...$(NC)"
cargo fmt --all
fmt-go: ## 格式化 Go 代码
@echo "$(BLUE)Formatting Go code...$(NC)"
go fmt ./...
lint: lint-rust lint-go ## 运行所有 Linter
lint-rust: ## Rust Clippy 检查
@echo "$(BLUE)Running Clippy...$(NC)"
cargo clippy --workspace --all-targets -- -D warnings
lint-go: ## Go Linter 检查(required
@echo "$(BLUE)Running golangci-lint...$(NC)"
@. scripts/ci-versions.sh; \
command -v golangci-lint >/dev/null 2>&1 || { \
echo "$(YELLOW)required gate failed: golangci-lint $${GOLANGCI_LINT_VERSION} is not installed$(NC)"; \
exit 1; \
}; \
actual="$$(golangci_lint_actual_version)"; \
test "$${actual}" = "$${GOLANGCI_LINT_VERSION}" || { \
echo "$(YELLOW)required gate failed: golangci-lint version required=$${GOLANGCI_LINT_VERSION} actual=$${actual:-unknown}$(NC)"; \
exit 1; \
}; \
XDG_CACHE_HOME="$${XDG_CACHE_HOME:-/tmp/bat-xdg-cache}" golangci-lint run ./...
# ============================================================================
# 清理
# ============================================================================
clean: ## 清理构建产物
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
cargo clean
rm -rf bin/
go clean
# ============================================================================
# 开发环境
# ============================================================================
dev: ## 启动开发环境(数据库等)
@echo "$(BLUE)Starting development environment...$(NC)"
docker compose -f deployments/docker-compose.dev.yml up -d
dev-stop: ## 停止开发环境
@echo "$(BLUE)Stopping development environment...$(NC)"
docker compose -f deployments/docker-compose.dev.yml down
# ============================================================================
# Docker
# ============================================================================
docker-build: ## 构建 Docker 镜像
@echo "$(BLUE)Building Docker images...$(NC)"
docker compose -f deployments/docker-compose.yml build
docker-up: ## 启动 Docker 容器
@echo "$(BLUE)Starting Docker containers...$(NC)"
docker compose -f deployments/docker-compose.yml up -d
docker-down: ## 停止 Docker 容器
@echo "$(BLUE)Stopping Docker containers...$(NC)"
docker compose -f deployments/docker-compose.yml down
# ============================================================================
# 依赖管理
# ============================================================================
deps: ## 安装/更新依赖
@echo "$(BLUE)Updating dependencies...$(NC)"
go mod download
cargo fetch
tidy: ## 整理依赖
@echo "$(BLUE)Tidying dependencies...$(NC)"
go mod tidy
cargo update --workspace
# ============================================================================
# 文档
# ============================================================================
docs: ## 生成文档
@echo "$(BLUE)Generating documentation...$(NC)"
cargo doc --workspace --no-deps --open
# ============================================================================
# CI/CD
# ============================================================================
ci-check: ## 运行只读 required CI 门禁(含固定版本 Go lint)
@bash scripts/ci-check.sh
ci: ci-check ## 运行只读 CI 检查(兼容旧命令名)