AnyBot/Makefile

110 lines
3.5 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.

# AnyBot — build and install from source. make help lists everything.
#
# git clone git@git.30cm.net:daniel.w/AnyBot.git && cd AnyBot
# make build (release)
# make install install for you: ~/Applications/AnyBot.app on a Mac, ~/.local/bin on Linux
# make run open it without installing
CARGO ?= cargo
UNAME := $(shell uname -s)
VERSION ?= $(shell git describe --tags --always 2>/dev/null | sed 's/^v//' || echo dev)
TARGET := $(or $(CARGO_TARGET_DIR),target)
APPDIR ?= $(HOME)/Applications
BIN := $(TARGET)/release/anybot
RELAY := $(if $(CARGO_TARGET_DIR),$(CARGO_TARGET_DIR),relay/target)/release/anybot-relay
.PHONY: all build app relay run serve setup relay-run test deps install uninstall hands server dist clean help
all: build
help:
@echo "AnyBot $(VERSION)"
@echo ""
@echo " make 建置 AnyBot 和帳號伺服器(正式版)"
@echo " make run 直接打開 AnyBot(不安裝)"
@echo " make install 安裝:Mac → $(APPDIR)/AnyBot.app;Linux → ~/.local/bin/anybot 和選單"
@echo " make uninstall 移除安裝的程式(你的 Bot 和聊天不會刪)"
@echo " make deps Linux:安裝系統套件(會問 sudo 密碼)"
@echo " make test 跑測試"
@echo ""
@echo " make serve 不開視窗執行(伺服器、一直開著的電腦)"
@echo " make setup 把這台接到你的 AnyBot(終端機裡的引導畫面)"
@echo " make hands Linux:裝好虛擬螢幕等,再接成大腦的手腳"
@echo " make relay-run 在這台跑帳號伺服器(埠 8080,資料在 ./relay-data)"
@echo " make server 在伺服器上架好帳號伺服器 + 大腦 + HTTPS(Docker)"
@echo ""
@echo " make dist 打包發行檔到 dist/(Mac:.app 的 zip;Linux:三個 tar.gz)"
@echo " make clean 清掉建置結果"
build: app relay
app:
$(CARGO) build --release --bin anybot
relay:
cd relay && $(CARGO) build --release
run: app
$(BIN)
serve: app
$(BIN) --serve
setup: app
$(BIN) setup
relay-run: relay
$(RELAY) --port 8080 --data relay-data
test:
$(CARGO) test --bin anybot
cd relay && $(CARGO) test
deps:
ifeq ($(UNAME),Linux)
sh deploy/linux/install.sh --deps-only
else ifeq ($(UNAME),Darwin)
@xcode-select -p >/dev/null 2>&1 || xcode-select --install
@command -v cargo >/dev/null || echo "需要 Rust:curl --proto '=https' -sSf https://sh.rustup.rs | sh"
else
@echo "Windows:請照 docs/install.md 安裝 Rust 和 Visual Studio Build Tools"
endif
install: app
ifeq ($(UNAME),Darwin)
KEEP_APP=1 sh deploy/mac/bundle.sh $(VERSION)
mkdir -p "$(APPDIR)"
rm -rf "$(APPDIR)/AnyBot.app"
mv dist/AnyBot.app "$(APPDIR)/AnyBot.app"
@echo "已安裝 $(APPDIR)/AnyBot.app(第一次打開:按右鍵 › 打開)"
else
sh deploy/linux/install.sh
endif
uninstall:
ifeq ($(UNAME),Darwin)
rm -rf "$(APPDIR)/AnyBot.app"
else
rm -f "$(HOME)/.local/bin/anybot" "$(HOME)/.local/share/applications/anybot.desktop"
rm -f "$(HOME)/.local/share/icons/hicolor/scalable/apps/anybot.svg" "$(HOME)/.local/share/icons/hicolor/256x256/apps/anybot.png" "$(HOME)/.local/share/icons/hicolor/128x128/apps/anybot.png"
endif
@echo "已移除程式。你的 Bot、聊天和設定還在(要全部刪掉請看 docs/install.md)。"
hands: app
sh deploy/linux/hands.sh --deps
server:
cd deploy/server && ./setup.sh
dist: build
ifeq ($(UNAME),Darwin)
sh deploy/mac/bundle.sh $(VERSION)
else
sh deploy/ci/package-linux.sh $(VERSION)
endif
clean:
$(CARGO) clean
cd relay && $(CARGO) clean
rm -rf dist