netrans/Makefile

59 lines
2.0 KiB
Makefile
Raw Permalink 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.

# Netrans Makefile
# 用户安装与更新入口
.PHONY: help install reinstall update version check clean
# 默认目标
help:
@echo "Netrans 用户任务"
@echo ""
@echo "可用目标:"
@echo " install 首次安装或增量安装"
@echo " update 拉取最新代码并增量安装"
@echo " reinstall 强制全量重装"
@echo " version 查看当前源码版本"
@echo " check 检查基础环境"
@echo " clean 清理本地临时文件"
# 安装或增量安装
install:
bash setup.sh
# 拉取最新版本并增量安装setup.sh 自动判断哪些步骤需要执行)
update:
@git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo "✗ 当前目录不是 git 仓库,请进入 netrans 源码目录后执行 make update"; exit 1; }
@git diff --quiet || { echo "✗ 工作区有未提交修改,请先提交或 stash 后再更新"; exit 1; }
@git diff --cached --quiet || { echo "✗ 暂存区有未提交修改,请先提交或 stash 后再更新"; exit 1; }
@echo "拉取最新版本..."
@git pull --ff-only || { echo "✗ git pull 失败,请检查网络、上游分支或是否存在非快进更新"; exit 1; }
@echo "✓ 代码已更新"
@echo ""
bash setup.sh
# 强制全量重装(删除安装状态快照后重新安装)
reinstall:
@rm -f .install_state
bash setup.sh
version:
@grep -E '^VERSION=' VERSION | head -1 | cut -d'=' -f2-
# 清理临时文件
clean:
@echo "清理临时文件..."
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@find . -type f -name "*.pyo" -delete 2>/dev/null || true
@find . -type f -name "*~" -delete 2>/dev/null || true
@find . -type f -name ".DS_Store" -delete 2>/dev/null || true
@rm -rf build/ dist/ *.egg-info .pytest_cache/ 2>/dev/null || true
@echo "✓ 清理完成"
# 检查环境
check:
@echo "环境检查:"
@python3 --version
@python3 -m pip --version
@git --version
@echo "✓ 基础环境正常"